public static Toil WaitWith(TargetIndex targetInd, int ticks, bool useProgressBar = false, bool maintainPosture = false) { Toil toil = new Toil(); toil.initAction = delegate { toil.actor.pather.StopDead(); Pawn pawn = toil.actor.CurJob.GetTarget(targetInd).Thing as Pawn; if (pawn != null) { if (pawn == toil.actor) { Log.Warning("Executing WaitWith toil but otherPawn is the same as toil.actor", false); } else { Pawn pawn2 = pawn; int ticks2 = ticks; bool maintainPosture2 = maintainPosture; PawnUtility.ForceWait(pawn2, ticks2, null, maintainPosture2); } } }; toil.FailOnDespawnedOrNull(targetInd); toil.FailOnCannotTouch(targetInd, PathEndMode.Touch); toil.defaultCompleteMode = ToilCompleteMode.Delay; toil.defaultDuration = ticks; if (useProgressBar) { toil.WithProgressBarToilDelay(targetInd, false, -0.5f); } return(toil); }