public override void AddItems(Sandbox.Game.Entities.Character.MyCharacter character)
        {
            System.Diagnostics.Debug.Assert((character.GetInventory(0) as MyInventory) != null, "Null or unexpected inventory type returned!");
            (character.GetInventory(0) as MyInventory).Clear();

            if (InventoryContentGenerated)
            {
                MyContainerTypeDefinition cargoContainerDefinition = MyDefinitionManager.Static.GetContainerTypeDefinition(InventoryContainerTypeId.SubtypeName);
                if (cargoContainerDefinition != null)
                {
                    (character.GetInventory(0) as MyInventory).GenerateContent(cargoContainerDefinition);
                }
                else
                {
                    System.Diagnostics.Debug.Fail("CargoContainer type definition " + InventoryContainerTypeId + " wasn't found.");
                }
            }
        }
        public override void AddItems(Sandbox.Game.Entities.Character.MyCharacter character)
        {
            base.AddItems(character);
            var ob = MyObjectBuilderSerializer.CreateNewObject<MyObjectBuilder_PhysicalGunObject>(StartingWeaponDefinitionId.SubtypeName);
            if (character.WeaponTakesBuilderFromInventory(StartingWeaponDefinitionId))
            {
                System.Diagnostics.Debug.Assert((character.GetInventory(0) as MyInventory) != null, "Null or unexpected inventory type!");
                (character.GetInventory(0) as MyInventory).AddItems(1, ob);
            }

            // else // allowing the inventory items to be added
            {
                foreach (var weaponDef in InventoryItems)
                {
                    ob = MyObjectBuilderSerializer.CreateNewObject<MyObjectBuilder_PhysicalGunObject>(weaponDef.SubtypeName);
                    System.Diagnostics.Debug.Assert((character.GetInventory(0) as MyInventory) != null, "Null or unexpected inventory type!");
                    (character.GetInventory(0) as MyInventory).AddItems(1, ob);
                }
            }

            character.SwitchToWeapon(StartingWeaponDefinitionId);

            {
                MyDefinitionId weaponDefinitionId;
                weaponDefinitionId = new MyDefinitionId(typeof(MyObjectBuilder_WeaponDefinition), StartingWeaponDefinitionId.SubtypeName);

                MyWeaponDefinition weaponDefinition;

                if (MyDefinitionManager.Static.TryGetWeaponDefinition(weaponDefinitionId, out weaponDefinition)) //GetWeaponDefinition(StartingWeaponId);
                {
                    if (weaponDefinition.HasAmmoMagazines())
                    {
                        var ammo = MyObjectBuilderSerializer.CreateNewObject<MyObjectBuilder_AmmoMagazine>(weaponDefinition.AmmoMagazinesId[0].SubtypeName);
                        System.Diagnostics.Debug.Assert((character.GetInventory(0) as MyInventory) != null, "Null or unexpected inventory type!");
                        (character.GetInventory(0) as MyInventory).AddItems(3, ammo);
                    }
                }
            }
        }
        public static bool InventoryAdd(Sandbox.Game.Entities.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;
        }