Exemplo n.º 1
0
        public bool TryDrop(Thing thing, IntVec3 dropLoc, Map map, ThingPlaceMode mode, int count, out Thing resultingThing, Action <Thing, int> placedAction = null, Predicate <IntVec3> nearPlaceValidator = null)
        {
            bool result;

            if (!this.Contains(thing))
            {
                Log.Error("Tried to drop " + thing.ToStringSafe <Thing>() + " but it's not here.", false);
                resultingThing = null;
                result         = false;
            }
            else
            {
                if (thing.stackCount < count)
                {
                    Log.Error(string.Concat(new object[]
                    {
                        "Tried to drop ",
                        count,
                        " of ",
                        thing,
                        " while only having ",
                        thing.stackCount
                    }), false);
                    count = thing.stackCount;
                }
                if (count == thing.stackCount)
                {
                    if (GenDrop.TryDropSpawn(thing, dropLoc, map, mode, out resultingThing, placedAction, nearPlaceValidator))
                    {
                        this.Remove(thing);
                        result = true;
                    }
                    else
                    {
                        result = false;
                    }
                }
                else
                {
                    Thing thing2 = thing.SplitOff(count);
                    if (GenDrop.TryDropSpawn(thing2, dropLoc, map, mode, out resultingThing, placedAction, nearPlaceValidator))
                    {
                        result = true;
                    }
                    else
                    {
                        thing.TryAbsorbStack(thing2, false);
                        result = false;
                    }
                }
            }
            return(result);
        }
 public bool TryDrop(Thing thing, IntVec3 dropLoc, Map map, ThingPlaceMode mode, out Thing lastResultingThing, Action <Thing, int> placedAction = null, Predicate <IntVec3> nearPlaceValidator = null)
 {
     if (!this.Contains(thing))
     {
         Log.Error(this.owner.ToStringSafe <IThingHolder>() + " container tried to drop  " + thing.ToStringSafe <Thing>() + " which it didn't contain.", false);
         lastResultingThing = null;
         return(false);
     }
     if (GenDrop.TryDropSpawn(thing, dropLoc, map, mode, out lastResultingThing, placedAction, nearPlaceValidator))
     {
         this.Remove(thing);
         return(true);
     }
     return(false);
 }