public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            //Log.Message("WorkGiver_HamsterWheel.HasJobOnThing");
            Building building = t as Building;
            bool     flag     = building == null;
            bool     result;

            if (flag)
            {
                result = false;
            }
            else
            {
                if (building.IsForbidden(pawn))
                {
                    result = false;
                }
                else
                {
                    LocalTargetInfo target = building;
                    if (!pawn.CanReserve(target, 1, -1, null, forced))
                    {
                        //Log.Message("WorkGiver_HamsterWheel.pawn.CanReserve = false");
                        result = false;
                    }
                    else
                    {
                        //Log.Message("WorkGiver_HamsterWheel.pawn.CanReserve = true");
                        CompPowerPlantHamsterWheel compHW = building.TryGetComp <CompPowerPlantHamsterWheel>();
                        result = (compHW.CanUseNow && !building.Position.IsInPrisonCell(pawn.Map) && !building.IsBurning());
                    }
                }
            }
            return(result);
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedNullOrForbidden(TargetIndex.A);
            this.FailOnBurningImmobile(TargetIndex.A);
            this.FailOn(delegate()
            {
                CompPowerPlantHamsterWheel compHW = job.targetA.Thing.TryGetComp <CompPowerPlantHamsterWheel>();

                return(!compHW.CanUseNow);
            });
            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell));

            Toil work = new Toil();

            work.initAction = delegate()
            {
                Pawn     actor    = work.actor;
                Building building = (Building)actor.CurJob.targetA.Thing;
                CompPowerPlantHamsterWheel comp = building.GetComp <CompPowerPlantHamsterWheel>();
                comp.StartTurnning(actor.GetStatValue(StatDefOf.MoveSpeed, true), actor);
            };
            work.tickAction = delegate()
            {
                if (Current.Game.tickManager.TicksGame % 10 == 0)
                {
                    Pawn actor = work.actor;
                    Traverse.Create(actor.Drawer).Field <JitterHandler>("jitterer").Value.AddOffset(0.07f, Rand.Range(0, 360));
                }
            };
            work.AddFinishAction(delegate()
            {
                Pawn actor        = work.actor;
                Building building = (Building)actor.CurJob.targetA.Thing;
                CompPowerPlantHamsterWheel comp = building.GetComp <CompPowerPlantHamsterWheel>();
                comp.UsingDone();
            });
            work.defaultCompleteMode = ToilCompleteMode.Delay;
            work.defaultDuration     = 4000;
            work.FailOnCannotTouch(TargetIndex.A, PathEndMode.InteractionCell);
            yield return(work);

            yield break;
        }