Ejemplo n.º 1
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            yield return(Toils_General.Wait(10, TargetIndex.None));

            yield return(new Toil
            {
                initAction = delegate()
                {
                    if (!this.pawn.inventory.UnloadEverything)
                    {
                        base.EndJobWith(JobCondition.Succeeded);
                    }
                    else
                    {
                        ThingCount firstUnloadableThing = this.pawn.inventory.FirstUnloadableThing;
                        IntVec3 c;
                        if (!StoreUtility.TryFindStoreCellNearColonyDesperate(firstUnloadableThing.Thing, this.pawn, out c))
                        {
                            Thing thing;
                            this.pawn.inventory.innerContainer.TryDrop(firstUnloadableThing.Thing, ThingPlaceMode.Near, firstUnloadableThing.Count, out thing, null, null);
                            base.EndJobWith(JobCondition.Succeeded);
                        }
                        else
                        {
                            this.job.SetTarget(TargetIndex.A, firstUnloadableThing.Thing);
                            this.job.SetTarget(TargetIndex.B, c);
                            this.countToDrop = firstUnloadableThing.Count;
                        }
                    }
                }
            });

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

            yield return(Toils_Goto.GotoCell(TargetIndex.B, PathEndMode.Touch));

            yield return(new Toil
            {
                initAction = delegate()
                {
                    Thing thing = this.job.GetTarget(TargetIndex.A).Thing;
                    if (thing == null || !this.pawn.inventory.innerContainer.Contains(thing))
                    {
                        base.EndJobWith(JobCondition.Incompletable);
                        return;
                    }
                    if (!this.pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation) || !thing.def.EverStorable(false))
                    {
                        this.pawn.inventory.innerContainer.TryDrop(thing, ThingPlaceMode.Near, this.countToDrop, out thing, null, null);
                        base.EndJobWith(JobCondition.Succeeded);
                    }
                    else
                    {
                        this.pawn.inventory.innerContainer.TryTransferToContainer(thing, this.pawn.carryTracker.innerContainer, this.countToDrop, out thing, true);
                        this.job.count = this.countToDrop;
                        this.job.SetTarget(TargetIndex.A, thing);
                    }
                    thing.SetForbidden(false, false);
                }
            });

            Toil carryToCell = Toils_Haul.CarryHauledThingToCell(TargetIndex.B);

            yield return(carryToCell);

            yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.B, carryToCell, true));

            yield break;
        }
Ejemplo n.º 2
0
            public bool MoveNext()
            {
                uint num = (uint)this.$PC;

                this.$PC = -1;
                switch (num)
                {
                case 0u:
                    this.$current = Toils_General.Wait(10, TargetIndex.None);
                    if (!this.$disposing)
                    {
                        this.$PC = 1;
                    }
                    return(true);

                case 1u:
                {
                    Toil pickItem = new Toil();
                    pickItem.initAction = delegate()
                    {
                        if (!this.pawn.inventory.UnloadEverything)
                        {
                            base.EndJobWith(JobCondition.Succeeded);
                        }
                        else
                        {
                            ThingCount firstUnloadableThing = this.pawn.inventory.FirstUnloadableThing;
                            IntVec3    c;
                            if (!StoreUtility.TryFindStoreCellNearColonyDesperate(firstUnloadableThing.Thing, this.pawn, out c))
                            {
                                Thing thing;
                                this.pawn.inventory.innerContainer.TryDrop(firstUnloadableThing.Thing, ThingPlaceMode.Near, firstUnloadableThing.Count, out thing, null, null);
                                base.EndJobWith(JobCondition.Succeeded);
                            }
                            else
                            {
                                this.job.SetTarget(TargetIndex.A, firstUnloadableThing.Thing);
                                this.job.SetTarget(TargetIndex.B, c);
                                this.countToDrop = firstUnloadableThing.Count;
                            }
                        }
                    };
                    this.$current = pickItem;
                    if (!this.$disposing)
                    {
                        this.$PC = 2;
                    }
                    return(true);
                }

                case 2u:
                    this.$current = Toils_Reserve.Reserve(TargetIndex.B, 1, -1, null);
                    if (!this.$disposing)
                    {
                        this.$PC = 3;
                    }
                    return(true);

                case 3u:
                    this.$current = Toils_Goto.GotoCell(TargetIndex.B, PathEndMode.Touch);
                    if (!this.$disposing)
                    {
                        this.$PC = 4;
                    }
                    return(true);

                case 4u:
                {
                    Toil dropOrStartCarrying = new Toil();
                    dropOrStartCarrying.initAction = delegate()
                    {
                        Thing thing = this.job.GetTarget(TargetIndex.A).Thing;
                        if (thing == null || !this.pawn.inventory.innerContainer.Contains(thing))
                        {
                            base.EndJobWith(JobCondition.Incompletable);
                            return;
                        }
                        if (!this.pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation) || !thing.def.EverStorable(false))
                        {
                            this.pawn.inventory.innerContainer.TryDrop(thing, ThingPlaceMode.Near, this.countToDrop, out thing, null, null);
                            base.EndJobWith(JobCondition.Succeeded);
                        }
                        else
                        {
                            this.pawn.inventory.innerContainer.TryTransferToContainer(thing, this.pawn.carryTracker.innerContainer, this.countToDrop, out thing, true);
                            this.job.count = this.countToDrop;
                            this.job.SetTarget(TargetIndex.A, thing);
                        }
                        thing.SetForbidden(false, false);
                    };
                    this.$current = dropOrStartCarrying;
                    if (!this.$disposing)
                    {
                        this.$PC = 5;
                    }
                    return(true);
                }

                case 5u:
                    carryToCell   = Toils_Haul.CarryHauledThingToCell(TargetIndex.B);
                    this.$current = carryToCell;
                    if (!this.$disposing)
                    {
                        this.$PC = 6;
                    }
                    return(true);

                case 6u:
                    this.$current = Toils_Haul.PlaceHauledThingInCell(TargetIndex.B, carryToCell, true);
                    if (!this.$disposing)
                    {
                        this.$PC = 7;
                    }
                    return(true);

                case 7u:
                    this.$PC = -1;
                    break;
                }
                return(false);
            }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            yield return(Toils_General.Wait(10));

            Toil toil = new Toil();

            toil.initAction = delegate
            {
                if (!pawn.inventory.UnloadEverything)
                {
                    EndJobWith(JobCondition.Succeeded);
                }
                else
                {
                    ThingCount firstUnloadableThing = pawn.inventory.FirstUnloadableThing;
                    if (!StoreUtility.TryFindStoreCellNearColonyDesperate(firstUnloadableThing.Thing, pawn, out var storeCell))
                    {
                        pawn.inventory.innerContainer.TryDrop(firstUnloadableThing.Thing, ThingPlaceMode.Near, firstUnloadableThing.Count, out var _);
                        EndJobWith(JobCondition.Succeeded);
                    }
                    else
                    {
                        job.SetTarget(TargetIndex.A, firstUnloadableThing.Thing);
                        job.SetTarget(TargetIndex.B, storeCell);
                        countToDrop = firstUnloadableThing.Count;
                    }
                }
            };
            yield return(toil);

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

            yield return(Toils_Goto.GotoCell(TargetIndex.B, PathEndMode.Touch));

            Toil toil2 = new Toil();

            toil2.initAction = delegate
            {
                Thing lastResultingThing = job.GetTarget(TargetIndex.A).Thing;
                if (lastResultingThing == null || !pawn.inventory.innerContainer.Contains(lastResultingThing))
                {
                    EndJobWith(JobCondition.Incompletable);
                }
                else
                {
                    if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation) || !lastResultingThing.def.EverStorable(willMinifyIfPossible: false))
                    {
                        pawn.inventory.innerContainer.TryDrop(lastResultingThing, ThingPlaceMode.Near, countToDrop, out lastResultingThing);
                        EndJobWith(JobCondition.Succeeded);
                    }
                    else
                    {
                        pawn.inventory.innerContainer.TryTransferToContainer(lastResultingThing, pawn.carryTracker.innerContainer, countToDrop, out lastResultingThing);
                        job.count = countToDrop;
                        job.SetTarget(TargetIndex.A, lastResultingThing);
                    }
                    lastResultingThing.SetForbidden(value: false, warnOnFail: false);
                }
            };
            yield return(toil2);

            Toil carryToCell = Toils_Haul.CarryHauledThingToCell(TargetIndex.B);

            yield return(carryToCell);

            yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.B, carryToCell, storageMode: true));
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedOrNull(TargetIndex.A);
            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch));

            yield return(Toils_General.Wait(10, TargetIndex.None));

            yield return(new Toil
            {
                initAction = delegate
                {
                    Pawn otherPawn = this.$this.OtherPawn;
                    if (!otherPawn.inventory.UnloadEverything)
                    {
                        this.$this.EndJobWith(JobCondition.Succeeded);
                    }
                    else
                    {
                        ThingCount firstUnloadableThing = otherPawn.inventory.FirstUnloadableThing;
                        IntVec3 c;
                        if (!firstUnloadableThing.Thing.def.EverStorable(false) || !this.$this.pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation) || !StoreUtility.TryFindStoreCellNearColonyDesperate(firstUnloadableThing.Thing, this.$this.pawn, out c))
                        {
                            Thing thing;
                            otherPawn.inventory.innerContainer.TryDrop(firstUnloadableThing.Thing, ThingPlaceMode.Near, firstUnloadableThing.Count, out thing, null, null);
                            this.$this.EndJobWith(JobCondition.Succeeded);
                            if (thing != null)
                            {
                                thing.SetForbidden(false, false);
                            }
                        }
                        else
                        {
                            Thing thing2;
                            otherPawn.inventory.innerContainer.TryTransferToContainer(firstUnloadableThing.Thing, this.$this.pawn.carryTracker.innerContainer, firstUnloadableThing.Count, out thing2, true);
                            this.$this.job.count = thing2.stackCount;
                            this.$this.job.SetTarget(TargetIndex.B, thing2);
                            this.$this.job.SetTarget(TargetIndex.C, c);
                            firstUnloadableThing.Thing.SetForbidden(false, false);
                        }
                    }
                }
            });

            yield return(Toils_Reserve.Reserve(TargetIndex.C, 1, -1, null));

            Toil carryToCell = Toils_Haul.CarryHauledThingToCell(TargetIndex.C);

            yield return(carryToCell);

            yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.C, carryToCell, true));
        }
Ejemplo n.º 5
0
            public bool MoveNext()
            {
                uint num = (uint)this.$PC;

                this.$PC = -1;
                switch (num)
                {
                case 0u:
                    this.FailOnDespawnedOrNull(TargetIndex.A);
                    this.$current = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch);
                    if (!this.$disposing)
                    {
                        this.$PC = 1;
                    }
                    return(true);

                case 1u:
                    this.$current = Toils_General.Wait(10, TargetIndex.None);
                    if (!this.$disposing)
                    {
                        this.$PC = 2;
                    }
                    return(true);

                case 2u:
                {
                    Toil dropOrStartCarrying = new Toil();
                    dropOrStartCarrying.initAction = delegate()
                    {
                        Pawn otherPawn = base.OtherPawn;
                        if (!otherPawn.inventory.UnloadEverything)
                        {
                            base.EndJobWith(JobCondition.Succeeded);
                        }
                        else
                        {
                            ThingCount firstUnloadableThing = otherPawn.inventory.FirstUnloadableThing;
                            IntVec3    c;
                            if (!firstUnloadableThing.Thing.def.EverStorable(false) || !this.pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation) || !StoreUtility.TryFindStoreCellNearColonyDesperate(firstUnloadableThing.Thing, this.pawn, out c))
                            {
                                Thing thing;
                                otherPawn.inventory.innerContainer.TryDrop(firstUnloadableThing.Thing, ThingPlaceMode.Near, firstUnloadableThing.Count, out thing, null, null);
                                base.EndJobWith(JobCondition.Succeeded);
                                if (thing != null)
                                {
                                    thing.SetForbidden(false, false);
                                }
                            }
                            else
                            {
                                Thing thing2;
                                otherPawn.inventory.innerContainer.TryTransferToContainer(firstUnloadableThing.Thing, this.pawn.carryTracker.innerContainer, firstUnloadableThing.Count, out thing2, true);
                                this.job.count = thing2.stackCount;
                                this.job.SetTarget(TargetIndex.B, thing2);
                                this.job.SetTarget(TargetIndex.C, c);
                                firstUnloadableThing.Thing.SetForbidden(false, false);
                            }
                        }
                    };
                    this.$current = dropOrStartCarrying;
                    if (!this.$disposing)
                    {
                        this.$PC = 3;
                    }
                    return(true);
                }

                case 3u:
                    this.$current = Toils_Reserve.Reserve(TargetIndex.C, 1, -1, null);
                    if (!this.$disposing)
                    {
                        this.$PC = 4;
                    }
                    return(true);

                case 4u:
                    carryToCell   = Toils_Haul.CarryHauledThingToCell(TargetIndex.C);
                    this.$current = carryToCell;
                    if (!this.$disposing)
                    {
                        this.$PC = 5;
                    }
                    return(true);

                case 5u:
                    this.$current = Toils_Haul.PlaceHauledThingInCell(TargetIndex.C, carryToCell, true);
                    if (!this.$disposing)
                    {
                        this.$PC = 6;
                    }
                    return(true);

                case 6u:
                    this.$PC = -1;
                    break;
                }
                return(false);
            }
Ejemplo n.º 6
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedOrNull(TargetIndex.A);
            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch));

            yield return(Toils_General.Wait(10));

            Toil toil = new Toil();

            toil.initAction = delegate
            {
                Pawn otherPawn = OtherPawn;
                if (!otherPawn.inventory.UnloadEverything)
                {
                    EndJobWith(JobCondition.Succeeded);
                }
                else
                {
                    ThingCount firstUnloadableThing = otherPawn.inventory.FirstUnloadableThing;
                    if (!firstUnloadableThing.Thing.def.EverStorable(willMinifyIfPossible: false) || !pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation) || !StoreUtility.TryFindStoreCellNearColonyDesperate(firstUnloadableThing.Thing, pawn, out var storeCell))
                    {
                        otherPawn.inventory.innerContainer.TryDrop(firstUnloadableThing.Thing, ThingPlaceMode.Near, firstUnloadableThing.Count, out var lastResultingThing);
                        EndJobWith(JobCondition.Succeeded);
                        lastResultingThing?.SetForbidden(value: false, warnOnFail: false);
                    }
                    else
                    {
                        otherPawn.inventory.innerContainer.TryTransferToContainer(firstUnloadableThing.Thing, pawn.carryTracker.innerContainer, firstUnloadableThing.Count, out var resultingTransferredItem);
                        job.count = resultingTransferredItem.stackCount;
                        job.SetTarget(TargetIndex.B, resultingTransferredItem);
                        job.SetTarget(TargetIndex.C, storeCell);
                        firstUnloadableThing.Thing.SetForbidden(value: false, warnOnFail: false);
                    }
                }
            };
            yield return(toil);

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

            Toil carryToCell = Toils_Haul.CarryHauledThingToCell(TargetIndex.C);

            yield return(carryToCell);

            yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.C, carryToCell, storageMode: true));
        }