/// <summary> /// find the original offset without setMax /// </summary> /// <param name="hSet"></param> /// <param name="capacity"></param> /// <returns></returns> static float GetTotalCapacityOffset(HediffSet hSet, PawnCapacityDef capacity) { float num = capacity.Worker.CalculateCapacityLevel(hSet); float num3 = 1f; for (int i = 0; i < hSet.hediffs.Count; i++) { Hediff hediff = hSet.hediffs[i]; List <PawnCapacityModifier> capMods = hediff.CapMods; if (capMods != null) { for (int j = 0; j < capMods.Count; j++) { PawnCapacityModifier pawnCapacityModifier = capMods[j]; if (pawnCapacityModifier.capacity == capacity) { num += pawnCapacityModifier.offset; num3 *= pawnCapacityModifier.postFactor; } } } } num *= num3; return(num); }
public CapModSaveable(PawnCapacityModifier cm) { capacity = cm.capacity; offset = cm.offset; setMax = cm.setMax; postFactor = cm.postFactor; }
public void CheckBodyparts() { int eyes = 2; List <Hediff> hediffs = pawn.health.hediffSet.hediffs; for (int i = 0; i < hediffs.Count; i++) { Hediff hediff = hediffs[i]; if (hediff != null && hediff.Part != null) { if (hediff.Part.def != null && hediff.Part.def == BodyPartDefOf.Eye) { if (hediff.def == RimWorld.HediffDefOf.MissingBodyPart) { eyes--; } else if (hediff.CurStage != null && hediff.CurStage.capMods != null) { List <PawnCapacityModifier> capMods = hediff.CurStage.capMods; for (int j = 0; j < capMods.Count; j++) { PawnCapacityModifier capMod = capMods[j]; if (capMod != null && capMod.offset <= -0.5f) { eyes--; } } } } } if (eyes <= 0) { break; } } if (eyes == 0) { this.Severity = 0.001f; // 0 } else if (eyes == 1) { this.Severity = 0.25f; // -0.25 } else { this.Severity = 0.5f; // -0.5 } }
static Harmony_RJW() { HarmonyInstance harmony = HarmonyInstance.Create("rimworld.baby_and_children.rjw_patch"); try { ((Action)(() => { if ((AccessTools.Method( typeof(xxx), nameof(xxx.is_human)) == null)) { //Log.Message("[From BnC] RJW Not Detected"); return; } Log.Message("[From BnC] RimJobWorld Detected"); AnotherModCheck.RJW_On = true; //Patch harmony.Patch( typeof(Hediff_SimpleBaby).GetMethod("PostMake"), new HarmonyMethod(typeof(rjw_Patches).GetMethod(nameof(rjw_Patches.PostMake_Pre)))); HediffDef PostPregnancy = DefDatabase <HediffDef> .GetNamed("BnC_RJW_PostPregnancy"); PawnCapacityModifier cap = new PawnCapacityModifier(); cap.capacity = DefDatabase <PawnCapacityDef> .GetNamed("Reproduction"); cap.setMax = 0.1f; PostPregnancy.stages[0].capMods.Add(cap); }))(); } catch (TypeLoadException) { } }