예제 #1
0
파일: Work.cs 프로젝트: tptp7979/NewRatkin
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            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))
                    {
                        result = false;
                    }
                    else
                    {
                        CompPowerPlantHamsterWheel compHW = building.TryGetComp <CompPowerPlantHamsterWheel>();
                        result = (compHW.CanUseNow && /*compHW.user == null &&*/ !building.Position.IsInPrisonCell(pawn.Map) && !building.IsBurning());
                    }
                }
            }
            return(result);
        }
예제 #2
0
파일: Job.cs 프로젝트: tptp7979/NewRatkin
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedNullOrForbidden(TargetIndex.A);
            this.FailOnBurningImmobile(TargetIndex.A);
            this.FailOn(() =>
            {
                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;
        }