public static IEnumerable <Toil> MakeNewToils(object __instance, float drillInTickMultiplier = 1f) { JobDriver jd = (JobDriver)__instance; jd.EndOnDespawnedOrNull(TargetIndex.A); Toil toil = Toils_Misc.FindRandomAdjacentReachableCell(TargetIndex.A, TargetIndex.B); yield return(toil); yield return(Toils_Reserve.Reserve(TargetIndex.B)); yield return(Toils_Goto.GotoCell(TargetIndex.B, PathEndMode.OnCell)); Toil supervise = new Toil(); supervise.tickAction = delegate() { LocalTargetInfo TargetA = Traverse.Create(__instance).Property("TargetA").GetValue <LocalTargetInfo>(); jd.pawn.rotationTracker.FaceCell(TargetA.Thing.OccupiedRect().ClosestCellTo(jd.pawn.Position)); Pawn actor = supervise.actor; actor.skills.Learn(SkillDefOf.Construction, 0.275f); float statValue = actor.GetStatValue(StatDefOf.ConstructionSpeed); //CompOilDerrick compOilDerrick = TargetA.Thing.TryGetComp<CompOilDerrick>(); object compOilDerrick = null; { // getting compOilDerrick ThingWithComps thingWithComps = TargetA.Thing as ThingWithComps; if (thingWithComps != null) { var found = thingWithComps.AllComps?.Where(x => x.GetType().ToString().StartsWith("CompOilDerrick")).FirstOrDefault(); if (found != null) { compOilDerrick = found; } } } bool flag = compOilDerrick != null; if (flag) { bool flag2 = !Traverse.Create(compOilDerrick).Property("WorkingNow").GetValue <bool>(); if (flag2) { jd.EndJobWith(JobCondition.Incompletable); } // compOilDerrick.Drill(statValue); Traverse.Create(compOilDerrick).Method("Drill", statValue * drillInTickMultiplier).GetValue(); bool isDilled = Traverse.Create(compOilDerrick).Property("IsDilled").GetValue <bool>(); if (isDilled) { jd.EndJobWith(JobCondition.Succeeded); } } }; supervise.handlingFacing = true; supervise.defaultCompleteMode = ToilCompleteMode.Never; supervise.activeSkill = (() => SkillDefOf.Construction); yield return(supervise); }