Exemplo n.º 1
0
        public static bool InventoryAdd(VRage.Game.Entity.MyEntity entity, MyFixedPoint amount, MyDefinitionId definitionId)
        {
            var itemAdded = false;
            var count     = entity.InventoryCount;

            // Try to find the right inventory to put the item into.
            // Ie., Refinery has 2 inventories. One for ore, one for ingots.
            for (int i = 0; i < count; i++)
            {
                var inventory = entity.GetInventory(i);
                if (inventory.CanItemsBeAdded(amount, definitionId))
                {
                    itemAdded = true;
                    Support.InventoryAdd(inventory, amount, definitionId);
                    break;
                }
            }

            return(itemAdded);
        }