public static bool PreFix(ref Toil __result, TargetIndex ind, PathEndMode peMode) { Toil toil = new Toil(); toil.initAction = delegate() { Pawn actor = toil.actor; actor.pather.StartPath(actor.jobs.curJob.GetTarget(ind), peMode); }; toil.AddPreTickAction(delegate() { Pawn actor = toil.actor; if (Gen.IsHashIntervalTick(actor, 240) && actor.jobs.curJob.GetTarget(ind).HasThing) { Thing thing = actor.jobs.curJob.GetTarget(ind).Thing; if (thing is Pawn && GenHostility.HostileTo(actor, thing as Pawn)) { CamoAIUtility.JobFailIfHid(actor, thing as Pawn, actor.jobs.curJob); } } }); toil.defaultCompleteMode = ToilCompleteMode.PatherArrival; __result = toil; return(false); }
public static bool PreFix(ref Toil __result, TargetIndex ind, PathEndMode peMode) { var toil = new Toil(); toil.initAction = delegate { var actor = toil.actor; actor.pather.StartPath(actor.jobs.curJob.GetTarget(ind), peMode); }; toil.AddPreTickAction(delegate { var actor = toil.actor; if (!actor.IsHashIntervalTick(240) || !actor.jobs.curJob.GetTarget(ind).HasThing) { return; } var thing = actor.jobs.curJob.GetTarget(ind).Thing; if (thing is Pawn pawn && actor.HostileTo(pawn)) { CamoAIUtility.JobFailIfHid(actor, pawn, actor.jobs.curJob); } });