public static void AIUPatch_UpdateDiscomfortAfterWearing(Pawn_ApparelTracker __instance) { //Every time you put on something, update the discomfort cache. DiscomfortComp comp = DiscomfortUtility.Comp(__instance.pawn); if (comp != null) { comp.Refresh(); } }
public override void Initialize(CompProperties props) { pawn = parent as Pawn; cachedDiscomfort = DiscomfortUtility.CalculateDiscomfort(pawn); /*if (cachedDiscomfort >= 1f) * { * tickWhenUncomfortable = Find.TickManager.TicksGame; * currentlyUncomfortable = true; * }*/ }
public void Refresh() { cachedDiscomfort = DiscomfortUtility.CalculateDiscomfort(pawn); if (currentlyUncomfortable && cachedDiscomfort < 1f) { currentlyUncomfortable = false; } else if (currentlyUncomfortable == false && cachedDiscomfort >= 1f) { currentlyUncomfortable = true; } }
public override void TransformValue(StatRequest req, ref float val) { if (req.HasThing) { Pawn pawn = req.Thing as Pawn; DiscomfortComp comp = DiscomfortUtility.Comp(pawn); if (comp == null) { Log.Error("[ArmorIsUncomfortable]Couldn't find a DiscomfortComp on " + pawn.Name.ToStringFull); } else { val = comp.discomfort; } } }
public override void NeedInterval() { DiscomfortComp discomfortComp = DiscomfortUtility.Comp(this.pawn); if (discomfortComp == null) { return; } if (discomfortComp.currentlyUncomfortable == true) { //As discomfort gets higher, the rate of discomfort increase slows, but it still should be possible to reach 0f. float discomfortPace; discomfortPace = Mathf.Max(1f, (CurLevel + 0.1f)); CurLevel -= ((discomfortComp.discomfort * 0.1f) / (16.5f * AIUCore.hoursUntilUncomfortable) * discomfortPace); } else { CurLevel += (1f / AIUCore.hoursUntilComfortable) * (150f / 2500f); } //Every 150 ticks, apparel comfort is decreased by (0.1 * current discomfort) / (400 * discomfort multiplier) }
protected override ThoughtState CurrentStateInternal(Pawn p) { Need_ApparelComfort comfortNeed = p.needs.TryGetNeed <Need_ApparelComfort>(); if (comfortNeed == null) { return(false); } DiscomfortComp comp = DiscomfortUtility.Comp(p); if (comp == null) { return(false); } comp.Update(); int severity = comp.severity - 1; if (severity <= -1) { return(false); } severity = Mathf.Clamp(severity, 0, ThoughtDefOfAIU.UncomfortableApparel.stages.Count - 1); return(ThoughtState.ActiveAtStage(severity)); }