Esempio n. 1
0
        public virtual void TryStoreThing(Thing element)
        {
            if (StoredThing != null)
            {
                if (StoredThing.CanStackWith(element))
                {
                    var num = Mathf.Min(element.stackCount, (StoredThing.def.stackLimit - StoredThing.stackCount));
                    if (OutputSettings.useMax)
                    {
                        num = Mathf.Min(element.stackCount, Mathf.Min((StoredThing.def.stackLimit - StoredThing.stackCount), (OutputSettings.max - StoredThing.stackCount)));
                    }

                    if (num > 0)
                    {
                        var t = element.SplitOff(num);
                        StoredThing.TryAbsorbStack(t, true);
                    }
                }
            }
            else
            {
                var num = element.stackCount;

                if (OutputSettings.useMax)
                {
                    num = Mathf.Min(element.stackCount, OutputSettings.max);
                }
                else if (num > 0)
                {
                    // if this is the entire stack, we just get the stack. Important for belts to do it this way:
                    var t = element.SplitOff(num);
                    GenPlace.TryPlaceThing(t, Position, Map, ThingPlaceMode.Direct);
                }
            }
        }
 public virtual void TryStoreThing(Thing element)
 {
     if (StoredThing != null)
     {
         if (StoredThing.CanStackWith(element))
         {
             //Verse.ThingUtility.TryAsborbStackNumToTake <- That's not a typo, that's an actual method. Seriously. Good thing it's fixed in A17, eh? (LudeonLeaks, 2017)
             var num = Mathf.Min(element.stackCount, Mathf.Min(limit, StoredThing.def.stackLimit) - StoredThing.stackCount);
             if (num > 0)
             {
                 var t = element.SplitOff(num);
                 StoredThing.TryAbsorbStack(t, true);
             }
         }
     }
     else
     {
         var num = Mathf.Min(element.stackCount, limit);
         if (num == element.stackCount)
         {
             element.Position = Position;
         }
         else if (num > 0)
         {
             var t = element.SplitOff(num);
             GenPlace.TryPlaceThing(t, Position, Map, ThingPlaceMode.Direct);
         }
     }
 }
Esempio n. 3
0
        public virtual void TryStoreThing(Thing element)
        {
            if (StoredThing != null)
            {
                if (StoredThing.CanStackWith(element))
                {
                    var num = Mathf.Min(element.stackCount, (StoredThing.def.stackLimit - StoredThing.stackCount));
                    if (OutputSettings.useMax)
                    {
                        num = Mathf.Min(element.stackCount, Mathf.Min((StoredThing.def.stackLimit - StoredThing.stackCount), (OutputSettings.max - StoredThing.stackCount)));
                    }

                    if (num > 0)
                    {
                        var t = element.SplitOff(num);
                        StoredThing.TryAbsorbStack(t, true);
                    }
                }
            }
            else
            {
                var num = element.stackCount;

                if (OutputSettings.useMax)
                {
                    num = Mathf.Min(element.stackCount, OutputSettings.max);
                }

                if (num == element.stackCount)
                {
                    element.Position = Position;
                }
                else if (num > 0)
                {
                    var t = element.SplitOff(num);
                    GenPlace.TryPlaceThing(t, Position, Map, ThingPlaceMode.Direct);
                }
            }
        }