using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using RimWorld; using Verse; using AlienRace; using UnityEngine; using rjw; namespace Rimworld_Animations_Patch { public class CompPawnSexData : ThingComp { public HandAnimationDef handAnimationDef = null; public Graphic handGraphic = null; public List hands = new List(); public float sizeOfPenis = 0f; public float sizeOfBreasts = 0f; public Dictionary bodyAddonData = new Dictionary(); public Dictionary bodyAddonDataPortraits = new Dictionary(); private Pawn pawn { get { return parent as Pawn; } } private bool initialized; // Refresh graphics on load public override void CompTick() { if (initialized == false) { pawn?.Drawer?.renderer?.graphics?.ResolveAllGraphics(); //if (pawn?.jobs?.curDriver is JobDriver_SexBaseInitiator && pawn.pather.Moving == false) //{ (pawn.jobs.curDriver as JobDriver_SexBaseInitiator).Start(); } initialized = true; } } public BodyAddonData GetBodyAddonData(AlienPartGenerator.BodyAddon bodyAddon, bool isPortrait) { if (pawn == null || (pawn.Map != Find.CurrentMap && pawn.holdingOwner == null) || bodyAddon == null) return null; if (isPortrait) { if (bodyAddonDataPortraits.TryGetValue(bodyAddon, out BodyAddonData bodyAddonDatum) == false) { bodyAddonDatum = new BodyAddonData(pawn, bodyAddon, true); bodyAddonDataPortraits.Add(bodyAddon, bodyAddonDatum); } return bodyAddonDatum; } else { if (bodyAddonData.TryGetValue(bodyAddon, out BodyAddonData bodyAddonDatum) == false) { bodyAddonDatum = new BodyAddonData(pawn, bodyAddon); bodyAddonData.Add(bodyAddon, bodyAddonDatum); } return bodyAddonDatum; } } public void UpdateBodyAddonVisibility() { foreach (KeyValuePair kvp in bodyAddonData) { kvp.Value?.UpdateVisibility(); } foreach (KeyValuePair kvp in bodyAddonDataPortraits) { kvp.Value?.UpdateVisibility(); } } public void UpdateBodyPartCountAndSize() { hands = pawn?.health?.hediffSet?.GetNotMissingParts()?.Where(x => x.def.tags.Contains(RimWorld.BodyPartTagDefOf.ManipulationLimbCore))?.ToList(); Hediff hediffPenis = pawn?.health?.hediffSet?.hediffs?.FirstOrDefault(x => x.def.defName.Contains("penis", StringComparison.OrdinalIgnoreCase) == true); sizeOfPenis = hediffPenis != null ? hediffPenis.Severity : 0f; Hediff hediffBreasts = pawn?.health?.hediffSet?.hediffs?.FirstOrDefault(x => x.def.defName.Contains("breasts", StringComparison.OrdinalIgnoreCase) == true); sizeOfBreasts = hediffBreasts != null ? hediffBreasts.Severity : 0f; } public int GetNumberOfHands() { if (hands.NullOrEmpty()) return 0; return hands.Count; } } }