public static Toil GoToPlatform(TargetIndex bedIndex) { Toil gotoBed = new Toil(); gotoBed.initAction = delegate { Pawn actor = gotoBed.actor; Building_Bed bed = (Building_Bed)actor.CurJob.GetTarget(bedIndex).Thing; IntVec3 bedSleepingSlotPosFor = RestUtility.GetBedSleepingSlotPosFor(actor, bed); if (actor.Position == bedSleepingSlotPosFor) { actor.jobs.curDriver.ReadyForNextToil(); } else { actor.pather.StartPath(bedSleepingSlotPosFor, PathEndMode.OnCell); } }; gotoBed.tickAction = delegate { Pawn actor = gotoBed.actor; Building_Bed building_Bed = (Building_Bed)actor.CurJob.GetTarget(bedIndex).Thing; Pawn curOccupantAt = building_Bed.GetCurOccupantAt(actor.pather.Destination.Cell); if (curOccupantAt != null && curOccupantAt != actor) { actor.pather.StartPath(RestUtility.GetBedSleepingSlotPosFor(actor, building_Bed), PathEndMode.OnCell); } }; gotoBed.defaultCompleteMode = ToilCompleteMode.PatherArrival; gotoBed.FailOnPlatformNoLongerUsable(bedIndex); //gotoBed.FailOnBedNoLongerUsable(bedIndex); return(gotoBed); }
public override void CompTickRare() { Building_Bed parentAsBed = (Building_Bed)this.parent; if (parentAsBed != null) { Pawn pawn = parentAsBed.GetCurOccupantAt(parentAsBed.Position); if (pawn?.health?.hediffSet?.hediffs.Find(h => h.def.defName == "Hypothermia") is Hediff hediff && hediff != null) { hediff.Severity -= 0.01f; } } }