Esempio n. 1
0
        public override bool HasJobOnThing(Pawn pawn, Thing thing, bool forced = false)
        {
            if (pawn == null)
            {
                return(false);
            }

            if (thing.IsForbidden(pawn))
            {
                return(false);
            }

            if (thing is Blueprint || thing is Frame)
            {
                return(false);
            }
            Building building = thing as Building;

            if (building == null)
            {
                return(false);
            }
            if (!pawn.CanReserve(thing, 1, -1, null, forced))
            {
                return(false);
            }
            CompSteamDrill  compDeepDrill = thing.TryGetComp <CompSteamDrill>();
            CompSteamTrader compTrader    = thing.TryGetComp <CompSteamTrader>();

            return(base.HasJobOnThing(pawn, thing, forced) &&
                   compDeepDrill.CanDrillNow() && !thing.IsBurning());
        }
Esempio n. 2
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            Toil reservation = Toils_Reserve.Reserve(TargetIndex.A, 1, -1);

            yield return(reservation);

            yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.InteractionCell));

            Toil doWork = new Toil
            {
                initAction = delegate
                {
                    workLeft = BaseWorkAmount;
                },
                tickAction = delegate
                {
                    Pawn  actor       = CurToil.actor;
                    float miningSpeed = (SpeedStat == null) ? 1f : pawn.GetStatValue(SpeedStat, true);
                    if (actor.skills != null)
                    {
                        actor.skills.Learn(SkillDefOf.Mining, 0.11f, false);
                    }
                    Thing          thing = (Thing)reservation.actor.CurJob.targetA;
                    CompSteamDrill comp  = thing.TryGetComp <CompSteamDrill>();
                    comp.DrillWorkDone(actor);
                    if (comp.JustProducedLump)
                    {
                        ReadyForNextToil();
                    }
                    return;
                }
            };

            doWork.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch);
            doWork.WithProgressBar(TargetIndex.A, () => ((Thing)reservation.actor.CurJob.targetA).TryGetComp <CompSteamDrill>().PercentDone, false, -0.5f);
            doWork.defaultCompleteMode = ToilCompleteMode.Never;
            yield return(doWork);
        }