using System.Collections.Generic; using Verse; using HarmonyLib; using UnityEngine; using System; using RimWorld; namespace rjwcum { [HarmonyPatch(typeof(PawnRenderer))] [HarmonyPatch("RenderPawnAt")] [HarmonyPatch(new Type[] { typeof(Vector3), typeof(Rot4?), typeof(bool) })] class Patch_RenderPawnOverlay { [HarmonyPostfix] static void DrawCum(PawnRenderer __instance, Vector3 drawLoc, Rot4? rotOverride, bool neverAimWeapon) { if (!CumBase.cum_overlays) return; Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue(); // Get the pawn instance if (pawn.RaceProps.Humanlike) // Only draw for humans { // Find the cum controller hediff Hediff_CumController cumController = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.Hediff_CumController) as Hediff_CumController; if (cumController != null) { // Ensure correct rotation and drawing location adjustments Quaternion quat = Quaternion.identity; quat.ToAngleAxis(out float angle, out Vector3 axis); // Adjustments if the pawn is sleeping in a bed Building_Bed buildingBed = pawn.CurrentBed(); if (buildingBed != null) { AltitudeLayer altLayer = (AltitudeLayer)Mathf.Max((int)buildingBed.def.altitudeLayer, 15); Vector3 bedAdjustedLoc = pawn.Position.ToVector3ShiftedWithAltitude(altLayer); bedAdjustedLoc.y += 0.03734375f; // Adjust the height to ensure overlay displays correctly drawLoc.y = bedAdjustedLoc.y; } // Apply a random offset to drawLoc.y to ensure it renders with variability drawLoc.y += UnityEngine.Random.Range(0.05f, 0.15f); // Draw the cum overlays using the cum controller's method cumController.DrawCum(drawLoc, quat, false, angle, false); } } } } }