Beispiel #1
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDestroyedOrNull(TargetIndex.A);
            this.FailOnDestroyedNullOrForbidden(TargetIndex.B);
            this.FailOn(() => TransporterUtility.WasLoadingCanceled(((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0065: stateMachine*/)._0024this.Container));
            this.FailOn(delegate
            {
                ThingOwner thingOwner = ((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_007d: stateMachine*/)._0024this.Container.TryGetInnerInteractableThingOwner();
                if (thingOwner != null && !thingOwner.CanAcceptAnyOf(((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_007d: stateMachine*/)._0024this.ThingToCarry))
                {
                    return(true);
                }
                IHaulDestination haulDestination = ((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_007d: stateMachine*/)._0024this.Container as IHaulDestination;
                if (haulDestination != null && !haulDestination.Accepts(((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_007d: stateMachine*/)._0024this.ThingToCarry))
                {
                    return(true);
                }
                return(false);
            });
            Toil getToHaulTarget = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch).FailOnSomeonePhysicallyInteracting(TargetIndex.A);

            yield return(getToHaulTarget);

            /*Error: Unable to find new state assignment for yield return*/;
        }
Beispiel #2
0
        public static Toil CarryHauledThingToContainer()
        {
            Toil gotoDest = new Toil();

            gotoDest.initAction = delegate
            {
                gotoDest.actor.pather.StartPath(gotoDest.actor.jobs.curJob.targetB.Thing, PathEndMode.Touch);
            };
            gotoDest.AddFailCondition(delegate
            {
                Thing thing = gotoDest.actor.jobs.curJob.targetB.Thing;
                if (!thing.Destroyed && !thing.IsForbidden(gotoDest.actor))
                {
                    ThingOwner thingOwner = thing.TryGetInnerInteractableThingOwner();
                    if (thingOwner != null && !thingOwner.CanAcceptAnyOf(gotoDest.actor.carryTracker.CarriedThing, true))
                    {
                        return(true);
                    }
                    return(false);
                }
                return(true);
            });
            gotoDest.defaultCompleteMode = ToilCompleteMode.PatherArrival;
            return(gotoDest);
        }
Beispiel #3
0
        public virtual bool Accepts(Thing thing)
        {
            if (itemFilterComp == null || itemFilterComp.NotSet || itemFilterComp.AcceptsHowMany(thing) > 0)
            {
                return(innerContainer.CanAcceptAnyOf(thing, true));
            }

            return(false);
        }
Beispiel #4
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDestroyedOrNull(TargetIndex.A);
            this.FailOnDestroyedNullOrForbidden(TargetIndex.B);
            this.FailOn(() => TransporterUtility.WasLoadingCanceled(this.Container));
            this.FailOn(delegate()
            {
                ThingOwner thingOwner = this.Container.TryGetInnerInteractableThingOwner();
                bool result;
                if (thingOwner != null && !thingOwner.CanAcceptAnyOf(this.ThingToCarry, true))
                {
                    result = true;
                }
                else
                {
                    IHaulDestination haulDestination = this.Container as IHaulDestination;
                    result = (haulDestination != null && !haulDestination.Accepts(this.ThingToCarry));
                }
                return(result);
            });
            Toil getToHaulTarget = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch).FailOnSomeonePhysicallyInteracting(TargetIndex.A);

            yield return(getToHaulTarget);

            yield return(Toils_Construct.UninstallIfMinifiable(TargetIndex.A).FailOnSomeonePhysicallyInteracting(TargetIndex.A));

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

            yield return(Toils_Haul.JumpIfAlsoCollectingNextTargetInQueue(getToHaulTarget, TargetIndex.A));

            Toil carryToContainer = Toils_Haul.CarryHauledThingToContainer();

            yield return(carryToContainer);

            yield return(Toils_Goto.MoveOffTargetBlueprint(TargetIndex.B));

            Toil prepare = Toils_General.Wait(this.Duration, TargetIndex.B);

            prepare.WithProgressBarToilDelay(TargetIndex.B, false, -0.5f);
            yield return(prepare);

            yield return(Toils_Construct.MakeSolidThingFromBlueprintIfNecessary(TargetIndex.B, TargetIndex.C));

            yield return(Toils_Haul.DepositHauledThingInContainer(TargetIndex.B, TargetIndex.C));

            yield return(Toils_Haul.JumpToCarryToNextContainerIfPossible(carryToContainer, TargetIndex.C));

            yield break;
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDestroyedOrNull(TargetIndex.A);
            this.FailOnDestroyedNullOrForbidden(TargetIndex.B);
            this.FailOn(() => TransporterUtility.WasLoadingCanceled(Container));
            this.FailOn(delegate
            {
                ThingOwner thingOwner = Container.TryGetInnerInteractableThingOwner();
                if (thingOwner != null && !thingOwner.CanAcceptAnyOf(ThingToCarry))
                {
                    return(true);
                }
                IHaulDestination haulDestination = Container as IHaulDestination;
                return((haulDestination != null && !haulDestination.Accepts(ThingToCarry)) ? true : false);
            });
            Toil getToHaulTarget = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch).FailOnSomeonePhysicallyInteracting(TargetIndex.A);

            yield return(getToHaulTarget);

            yield return(Toils_Construct.UninstallIfMinifiable(TargetIndex.A).FailOnSomeonePhysicallyInteracting(TargetIndex.A));

            yield return(Toils_Haul.StartCarryThing(TargetIndex.A, putRemainderInQueue: false, subtractNumTakenFromJobCount: true));

            yield return(Toils_Haul.JumpIfAlsoCollectingNextTargetInQueue(getToHaulTarget, TargetIndex.A));

            Toil carryToContainer = Toils_Haul.CarryHauledThingToContainer();

            yield return(carryToContainer);

            yield return(Toils_Goto.MoveOffTargetBlueprint(TargetIndex.B));

            Toil toil = Toils_General.Wait(Duration, TargetIndex.B);

            toil.WithProgressBarToilDelay(TargetIndex.B);
            yield return(toil);

            yield return(Toils_Construct.MakeSolidThingFromBlueprintIfNecessary(TargetIndex.B, TargetIndex.C));

            yield return(Toils_Haul.DepositHauledThingInContainer(TargetIndex.B, TargetIndex.C));

            yield return(Toils_Haul.JumpToCarryToNextContainerIfPossible(carryToContainer, TargetIndex.C));
        }
Beispiel #6
0
 public virtual bool Accepts(Thing thing)
 {
     return(innerContainer.CanAcceptAnyOf(thing));
 }
Beispiel #7
0
            public bool MoveNext()
            {
                uint num = (uint)this.$PC;

                this.$PC = -1;
                switch (num)
                {
                case 0u:
                    this.FailOnDestroyedOrNull(TargetIndex.A);
                    this.FailOnDestroyedNullOrForbidden(TargetIndex.B);
                    this.FailOn(() => TransporterUtility.WasLoadingCanceled(base.Container));
                    this.FailOn(delegate()
                    {
                        ThingOwner thingOwner = base.Container.TryGetInnerInteractableThingOwner();
                        bool result;
                        if (thingOwner != null && !thingOwner.CanAcceptAnyOf(base.ThingToCarry, true))
                        {
                            result = true;
                        }
                        else
                        {
                            IHaulDestination haulDestination = base.Container as IHaulDestination;
                            result = (haulDestination != null && !haulDestination.Accepts(base.ThingToCarry));
                        }
                        return(result);
                    });
                    getToHaulTarget = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch).FailOnSomeonePhysicallyInteracting(TargetIndex.A);
                    this.$current   = getToHaulTarget;
                    if (!this.$disposing)
                    {
                        this.$PC = 1;
                    }
                    return(true);

                case 1u:
                    this.$current = Toils_Construct.UninstallIfMinifiable(TargetIndex.A).FailOnSomeonePhysicallyInteracting(TargetIndex.A);
                    if (!this.$disposing)
                    {
                        this.$PC = 2;
                    }
                    return(true);

                case 2u:
                    this.$current = Toils_Haul.StartCarryThing(TargetIndex.A, false, true, false);
                    if (!this.$disposing)
                    {
                        this.$PC = 3;
                    }
                    return(true);

                case 3u:
                    this.$current = Toils_Haul.JumpIfAlsoCollectingNextTargetInQueue(getToHaulTarget, TargetIndex.A);
                    if (!this.$disposing)
                    {
                        this.$PC = 4;
                    }
                    return(true);

                case 4u:
                    carryToContainer = Toils_Haul.CarryHauledThingToContainer();
                    this.$current    = carryToContainer;
                    if (!this.$disposing)
                    {
                        this.$PC = 5;
                    }
                    return(true);

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

                case 6u:
                    prepare = Toils_General.Wait(base.Duration, TargetIndex.B);
                    prepare.WithProgressBarToilDelay(TargetIndex.B, false, -0.5f);
                    this.$current = prepare;
                    if (!this.$disposing)
                    {
                        this.$PC = 7;
                    }
                    return(true);

                case 7u:
                    this.$current = Toils_Construct.MakeSolidThingFromBlueprintIfNecessary(TargetIndex.B, TargetIndex.C);
                    if (!this.$disposing)
                    {
                        this.$PC = 8;
                    }
                    return(true);

                case 8u:
                    this.$current = Toils_Haul.DepositHauledThingInContainer(TargetIndex.B, TargetIndex.C);
                    if (!this.$disposing)
                    {
                        this.$PC = 9;
                    }
                    return(true);

                case 9u:
                    this.$current = Toils_Haul.JumpToCarryToNextContainerIfPossible(carryToContainer, TargetIndex.C);
                    if (!this.$disposing)
                    {
                        this.$PC = 10;
                    }
                    return(true);

                case 10u:
                    this.$PC = -1;
                    break;
                }
                return(false);
            }
Beispiel #8
0
 public static bool TryAdd(ThingOwner <Thing> __instance, ref bool __result, Thing item, bool canMergeWithExistingStacks = true)
 {
     if (item == null)
     {
         Log.Warning("Tried to add null item to ThingOwner.", false);
         __result = false;
         return(false);
     }
     if (!(item is Thing obj))
     {
         __result = false;
         return(false);
     }
     if (__instance.Contains(item))
     {
         Log.Warning("Tried to add " + item.ToStringSafe <Thing>() + " to ThingOwner but this item is already here.", false);
         __result = false;
         return(false);
     }
     if (item.holdingOwner != null)
     {
         Log.Warning("Tried to add " + item.ToStringSafe <Thing>() + " to ThingOwner but this thing is already in another container. owner=" + __instance.Owner.ToStringSafe <IThingHolder>() + ", current container owner=" + item.holdingOwner.Owner.ToStringSafe <IThingHolder>() + ". Use TryAddOrTransfer, TryTransferToContainer, or remove the item before adding it.", false);
         __result = false;
         return(false);
     }
     if (!__instance.CanAcceptAnyOf(item, canMergeWithExistingStacks))
     {
         __result = false;
         return(false);
     }
     if (canMergeWithExistingStacks)
     {
         for (int index = 0; index < innerList(__instance).Count; ++index)
         {
             Thing inner = innerList(__instance)[index];
             if (inner.CanStackWith(item))
             {
                 int count = Mathf.Min(item.stackCount, inner.def.stackLimit - inner.stackCount);
                 if (count > 0)
                 {
                     Thing other      = item.SplitOff(count);
                     int   stackCount = inner.stackCount;
                     inner.TryAbsorbStack(other, true);
                     if (inner.stackCount > stackCount)
                     {
                         NotifyAddedAndMergedWith(__instance, (Thing)inner, inner.stackCount - stackCount);
                     }
                     if (item.Destroyed || item.stackCount == 0)
                     {
                         __result = true;
                         return(false);
                     }
                 }
             }
         }
     }
     if (__instance.Count >= maxStacks(__instance))
     {
         __result = false;
         return(false);
     }
     item.holdingOwner = (ThingOwner)__instance;
     lock (innerList(__instance))
     {
         innerList(__instance).Add(obj);
     }
     NotifyAdded(__instance, (Thing)obj);
     __result = true;
     return(false);
 }