コード例 #1
0
        //JobDriver_HaulToContainer is Job 'HaulToContainer'
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Building_GrowerBase grower = t as Building_GrowerBase;

            if (grower == null)
            {
                return(false);
            }

            if (!grower.GrowerProps.productRequireManualExtraction)
            {
                return(false);
            }

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

            if (!pawn.CanReserve(t))
            {
                return(false);
            }

            if (grower.status != CrafterStatus.Finished)
            {
                return(false);
            }

            return(true);
        }
        //JobDriver_HaulToContainer is Job 'HaulToContainer'
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Building_GrowerBase grower = t as Building_GrowerBase;

            if (grower == null)
            {
                return(false);
            }

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

            if (!pawn.CanReserve(t))
            {
                return(false);
            }

            if (grower.status != CrafterStatus.Filling)
            {
                return(false);
            }

            if (grower.orderProcessor.PendingRequests.Count() <= 0)
            {
                return(false);
            }

            return(IngredientUtility.FindClosestRequestForThingOrderProcessor(grower.orderProcessor, pawn) is Thing cloestThing && pawn.CanReserve(cloestThing));
        }
コード例 #3
0
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Building_GrowerBase grower = t as Building_GrowerBase;

            Job job = new Job(QEJobDefOf.QE_ExtractFromGrowerJob, t);

            return(job);
        }
コード例 #4
0
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Building_GrowerBase grower = t as Building_GrowerBase;

            if (grower == null)
            {
                return(false);
            }

            IMaintainableGrower maintanable = grower as IMaintainableGrower;

            if (maintanable == null)
            {
                return(false);
            }

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

            if (!pawn.CanReserve(t))
            {
                return(false);
            }

            if (grower.status != CrafterStatus.Crafting)
            {
                return(false);
            }

            bool maintainScience = true;

            if (maintanable.ScientistMaintence > 0.49f)
            {
                if (maintanable.ScientistMaintence > 0.90f)
                {
                    maintainScience = false;
                }
                maintainScience = forced;
            }

            bool maintainDoctor = true;

            if (maintanable.DoctorMaintence > 0.49f)
            {
                if (maintanable.DoctorMaintence > 0.90f)
                {
                    maintainDoctor = false;
                }
                maintainDoctor = forced;
            }

            bool maintainAtAll = maintainScience || maintainDoctor;

            return(maintainAtAll);
        }
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Building_GrowerBase grower = t as Building_GrowerBase;
            Thing fillThing            = IngredientUtility.FindClosestRequestForThingOrderProcessor(grower.orderProcessor, pawn);
            int   fillCount            = grower.orderProcessor.PendingRequests.First(req => req.ThingMatches(fillThing)).amount;

            Job job = new Job(QEJobDefOf.QE_DepositIntoGrowerJob, t, fillThing);

            job.count = fillCount;
            return(job);
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            //Conditions and reserve
            this.FailOn(delegate()
            {
                return(TargetThingA is Building_GrowerBase vat && vat.status != CrafterStatus.Filling);
            });
            this.FailOnDestroyedNullOrForbidden(TargetIndex.A);
            this.FailOnDestroyedNullOrForbidden(TargetIndex.B);
            yield return(Toils_Reserve.Reserve(TargetIndex.A));

            Toil reserveIngredient = Toils_Reserve.Reserve(TargetIndex.B);

            yield return(reserveIngredient);

            //Go and get the thing to carry.
            yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.OnCell));

            Toil carryThing = Toils_Haul.StartCarryThing(TargetIndex.B, subtractNumTakenFromJobCount: true);

            carryThing.AddFinishAction(
                delegate()
            {
                Building_GrowerBase grower = TargetThingA as Building_GrowerBase;
                if (grower != null)
                {
                    grower.Notify_StartedCarryThing(GetActor());
                }
            });
            yield return(carryThing);

            //Opportunistically haul a nearby ingredient of same ThingDef. Checks 8 square radius.
            yield return(Toils_Haul.CheckForGetOpportunityDuplicate(reserveIngredient, TargetIndex.B, TargetIndex.None, takeFromValidStorage: true));

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

            yield return(Toils_General.WaitWith(TargetIndex.A, 100, true));

            yield return(new Toil()
            {
                initAction = delegate()
                {
                    Building_GrowerBase grower = TargetThingA as Building_GrowerBase;
                    if (grower != null)
                    {
                        grower.FillThing(GetActor().carryTracker.CarriedThing);
                    }
                }
            });
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            //Conditions and reserve
            this.FailOn(delegate()
            {
                return(TargetThingA is Building_GrowerBase vat && vat.status != CrafterStatus.Filling);
            });
            this.FailOnDestroyedNullOrForbidden(TargetIndex.A);
            this.FailOnDestroyedNullOrForbidden(TargetIndex.B);
            yield return(Toils_Reserve.Reserve(TargetIndex.A));

            yield return(Toils_Reserve.Reserve(TargetIndex.B));

            //Go and get the thing to carry.
            yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.OnCell));

            Toil carryThing = Toils_Haul.StartCarryThing(TargetIndex.B, subtractNumTakenFromJobCount: true);

            carryThing.AddFinishAction(
                delegate()
            {
                Building_GrowerBase grower = TargetThingA as Building_GrowerBase;
                if (grower != null)
                {
                    grower.Notify_StartedCarryThing(GetActor());
                }
            });
            yield return(carryThing);

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

            yield return(Toils_General.WaitWith(TargetIndex.A, 100, true));

            yield return(new Toil()
            {
                initAction = delegate()
                {
                    Building_GrowerBase grower = TargetThingA as Building_GrowerBase;
                    if (grower != null)
                    {
                        grower.FillThing(GetActor().carryTracker.CarriedThing);
                    }
                }
            });
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedNullOrForbidden(TargetIndex.A);
            this.FailOnDestroyedOrNull(TargetIndex.A);
            yield return(Toils_Reserve.Reserve(TargetIndex.A));

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

            yield return(Toils_General.WaitWith(TargetIndex.A, 200, true));

            yield return(new Toil()
            {
                initAction = delegate()
                {
                    Building_GrowerBase grower = TargetThingA as Building_GrowerBase;
                    if (grower != null)
                    {
                        Pawn actor = GetActor();
                        Thing product = grower.ExtractProduct(actor);
                        if (!product.Spawned)
                        {
                            GenPlace.TryPlaceThing(product, grower.InteractionCell, grower.Map, ThingPlaceMode.Near);
                        }

                        if (product is Pawn)
                        {
                            EndJobWith(JobCondition.Succeeded);
                        }
                        else
                        {
                            //job.SetTarget(TargetIndex.B, product);
                            IntVec3 storeCell;
                            IHaulDestination haulDestination;
                            if (StoreUtility.TryFindBestBetterStorageFor(product, actor, product.Map, StoragePriority.Unstored, actor.Faction, out storeCell, out haulDestination, false))
                            {
                                if (storeCell.IsValid || haulDestination != null)
                                {
                                    actor.jobs.StartJob(HaulAIUtility.HaulToStorageJob(actor, product), JobCondition.Succeeded);
                                }
                            }
                        }
                    }
                }
            });
        }
コード例 #9
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedNullOrForbidden(TargetIndex.A);
            this.FailOnDestroyedOrNull(TargetIndex.A);
            yield return(Toils_Reserve.Reserve(TargetIndex.A));

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

            yield return(Toils_General.WaitWith(TargetIndex.A, 200, true));

            yield return(new Toil()
            {
                initAction = delegate()
                {
                    Building_GrowerBase grower = TargetThingA as Building_GrowerBase;
                    if (grower != null)
                    {
                        grower.TryExtractProduct(GetActor());

                        EndJobWith(JobCondition.Succeeded);
                    }
                }
            });
        }