/// <summary> /// Move the specified thing to the ground. /// </summary> /// <param name="thingToMove">Thing to move.</param> /// <param name="posTo">Position to move to.</param> /// <param name="thingsPrepared">A reference to the things /// already prepared.</param> private void MoveToGround() { Thing topThing = map.GetTopThing(posTo); Item topItem = null; if (topThing.IsOfType(Constants.TYPE_STACKABLE)) { topItem = (Item)topThing; } bool stackable = false; bool addItem = true; if (topItem != null && itemToMove != null && topItem.ItemID == itemToMove.ItemID) //Both stackable items of same type { stackable = true; if (topItem.Count + itemToMove.Count > MAX_STACK_COUNT) { byte countRemainder = (byte)(MAX_STACK_COUNT - topItem.Count); topItem.Count += countRemainder; itemToMove.Count -= countRemainder; } else { topItem.Count += itemToMove.Count; addItem = false; } } ThingSet tSet = map.GetThingsInVicinity(posTo); byte stackpos = map.GetStackPosition(itemToMove, posTo); if (stackable) { foreach (Thing thing in tSet.GetThings()) { thing.UpdateItem(posTo, topItem, map.GetStackPosition(topItem, posTo)); } } if (addItem) { map.AddThing(itemToMove, posTo); foreach (Thing thing in tSet.GetThings()) { thing.AddThingToGround(itemToMove, posTo, map.GetStackPosition(itemToMove, posTo)); } } }