Exemplo n.º 1
0
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            CompGenomorpher comp = t.TryGetComp <CompGenomorpher>();

            if (!comp.BringIngredients)
            {
                return(JobMaker.MakeJob(JobDefOf.Vomit));
            }

            List <Thing> chosenThings = new List <Thing> ();

            chosenThings.Add(comp.genomeDominant);
            chosenThings.Add(comp.genomeSecondary);
            chosenThings.Add(comp.frame);
            chosenThings.Add(comp.booster);

            Job job = JobMaker.MakeJob(InternalDefOf.GR_InsertIngredients, t);

            job.targetQueueB = new List <LocalTargetInfo>(chosenThings.Count);
            job.count        = 1;
            for (int i = 0; i < chosenThings.Count; i++)
            {
                Thing chosenThing = chosenThings[i];
                if (chosenThing != null)
                {
                    job.targetQueueB.Add(chosenThing);
                }
            }
            job.haulMode = HaulMode.ToCellNonStorage;

            return(job);
        }
Exemplo n.º 2
0
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            CompGenomorpher comp = t.TryGetComp <CompGenomorpher>();

            if (!comp.BringIngredients)
            {
                return(false);
            }

            if (!t.IsForbidden(pawn))
            {
                LocalTargetInfo target = t;
                if (pawn.CanReserve(target, 1, 1, null, forced))
                {
                    if (pawn.Map.designationManager.DesignationOn(t, DesignationDefOf.Deconstruct) != null)
                    {
                        return(false);
                    }
                    if (!pawn.CanReserve(comp.genomeDominant) || !pawn.CanReserve(comp.genomeSecondary) || !pawn.CanReserve(comp.frame) || (comp.booster != null && !pawn.CanReserve(comp.booster)))
                    {
                        comp.duration        = -1;
                        comp.progress        = -1f;
                        comp.growthCell      = null;
                        comp.genomeDominant  = null;
                        comp.genomeSecondary = null;
                        comp.frame           = null;
                        comp.booster         = null;
                        return(false);
                    }

                    return(!t.IsBurning());
                }
            }
            return(false);
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            CompGenomorpher comp = job.GetTarget(TargetIndex.A).Thing.TryGetComp <CompGenomorpher>();


            this.FailOnDespawnedNullOrForbidden(TargetIndex.A);
            this.FailOnBurningImmobile(TargetIndex.A);


            foreach (LocalTargetInfo target in job.GetTargetQueue(TargetIndex.B))
            {
                yield return(Toils_General.DoAtomic(delegate
                {
                    job.SetTarget(TargetIndex.B, target);

                    job.count = 1;
                }));

                yield return(Toils_Reserve.Reserve(TargetIndex.B, 1, 1).FailOnDespawnedNullOrForbidden(TargetIndex.B));

                yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.ClosestTouch).FailOnDespawnedNullOrForbidden(TargetIndex.B).FailOnSomeonePhysicallyInteracting(TargetIndex.B));

                yield return(Toils_Haul.StartCarryThing(TargetIndex.B, false, true, false).FailOnDestroyedNullOrForbidden(TargetIndex.B));

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

                yield return(Toils_General.Wait(200, TargetIndex.None).FailOnDestroyedNullOrForbidden(TargetIndex.B).FailOnDestroyedNullOrForbidden(TargetIndex.A).FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch).WithProgressBarToilDelay(TargetIndex.A, false, -0.5f));

                yield return(Toils_General.DoAtomic(delegate
                {
                    Pawn actor = this.GetActor();
                    actor.carryTracker.TryDropCarriedThing(actor.Position, ThingPlaceMode.Near, out _, (thing, i) => thing.DeSpawn());
                }));
            }
            yield return(Toils_General.DoAtomic(delegate
            {
                comp.StartGrowthProcess();
            }));



            yield break;
        }
 public Window_DesignateGrowthCell(CompGenomorpher comp)
 {
     this.comp          = comp;
     this.doCloseButton = false;
     this.forcePause    = true;
 }