public MyMwcObjectBuilder_SmallShip(MyMwcObjectBuilder_SmallShip_TypesEnum shipType,
     MyMwcObjectBuilder_Inventory inventory,
     List<MyMwcObjectBuilder_SmallShip_Weapon> weapons,
     MyMwcObjectBuilder_SmallShip_Engine engine, 
     List<MyMwcObjectBuilder_AssignmentOfAmmo> assignmentOfAmmo,
     MyMwcObjectBuilder_SmallShip_Armor armor,
     MyMwcObjectBuilder_SmallShip_Radar radar,
     float? shipMaxHealth,
     float shipHealthRatio,
     float armorHealth,
     float oxygen,
     float fuel,
     bool reflectorLight,
     bool reflectorLongRange,
     float reflectorShadowDistance,
     int aiPriority)
         : base(inventory)
 {
     ShipType = shipType;
     Weapons = weapons;
     Engine = engine;                        
     AssignmentOfAmmo = assignmentOfAmmo;
     Armor = armor;
     Radar = radar;
     ShipMaxHealth = shipMaxHealth;
     ShipHealthRatio = shipHealthRatio;
     ArmorHealth = armorHealth;
     Oxygen = oxygen;
     Fuel = fuel;
     ReflectorLight = reflectorLight;
     ReflectorLongRange = reflectorLongRange;
     ReflectorShadowDistance = reflectorShadowDistance;
     AIPriority = aiPriority;
 }
 public MyGuiScreenInventorySaveResult(List<MySmallShipBuilderWithName> shipsBuilders, int currentIndex, MyMwcObjectBuilder_Inventory otherSideInventoryBuilder, float money, bool wasAnythingTransfered)
 {
     SmallShipsObjectBuilders = shipsBuilders;
     CurrentIndex = currentIndex;
     OtherSideInventoryObjectBuilder = otherSideInventoryBuilder;
     Money = money;
     WasAnythingTransfered = wasAnythingTransfered;
 }
 public MyMwcObjectBuilder_PrefabContainer(int? templateId, MyMwcObjectBuilder_PrefabContainer_TypesEnum containerType,
     List<MyMwcObjectBuilder_PrefabBase> prefabs, int userOwnerID, MyMwcObjectBuilder_FactionEnum faction, MyMwcObjectBuilder_Inventory inventory)
 {
     TemplateId = templateId;
     ContainerType = containerType;
     Prefabs = prefabs;
     UserOwnerID = userOwnerID;
     Faction = faction;
     Inventory = inventory;
 }
 public MyMwcObjectBuilder_SmallShip_Player(MyMwcObjectBuilder_SmallShip_TypesEnum shipType,
     MyMwcObjectBuilder_Inventory inventory,
     List<MyMwcObjectBuilder_SmallShip_Weapon> weapons,
     MyMwcObjectBuilder_SmallShip_Engine engine,
     List<MyMwcObjectBuilder_AssignmentOfAmmo> assignmentOfAmmo,
     MyMwcObjectBuilder_SmallShip_Armor armor,
     MyMwcObjectBuilder_SmallShip_Radar radar,
     float? shipMaxHealth,
     float shipHealthRatio,
     float armorHealth,
     float electricity,
     float oxygen,
     float fuel,
     bool reflectorLight,
     bool reflectorLongRange,
     float reflectorShadowDistance,
     int aiPriority)
     : base(shipType, inventory, weapons, engine, assignmentOfAmmo, armor, radar, shipMaxHealth, shipHealthRatio, armorHealth, oxygen, fuel, reflectorLight, reflectorLongRange, reflectorShadowDistance, aiPriority)
 {
     DisplayName = "Player";
 }
 private int GetMaxInventoryItems(MyMwcObjectBuilder_Inventory inventoryBuilder)
 {
     int maxItems;
     if (inventoryBuilder != null)
     {
         maxItems = inventoryBuilder.MaxItems;
     }
     else
     {
         maxItems = MyInventory.DEFAULT_MAX_ITEMS;
     }
     return maxItems;
 }
 private int CreateInventoryItemAddToRepository(MyMwcObjectBuilder_Base builder, MyMwcObjectBuilder_Inventory owner)
 {
     return CreateInventoryItemAddToRepository(builder, 1f, owner);
 }
        private void SaveInventoryItemsToObjectBuilders(ref List<MySmallShipBuilderWithName> shipBuilders, ref MyMwcObjectBuilder_Inventory otherSideInventoryBuilder)
        {
            for (int i = 0; i < m_smallShipsBuilders.Count; i++)
            {
                SaveIntentoryItemsToObjectBuilder(i);
                //shipBuilders.Add(shipBuilder);
            }

            if (otherSideInventoryBuilder != null)
            {
                otherSideInventoryBuilder.InventoryItems.Clear();
                foreach (int id in m_otherSideInventoryItemIDs)
                {
                    otherSideInventoryBuilder.InventoryItems.Add(GetInventoryItemObjectBuilderFromRepository(id));
                }
            }
        }
 private int CreateInventoryItemAddToRepository(MyMwcObjectBuilder_InventoryItem inventoryItem, MyMwcObjectBuilder_Inventory owner) 
 {
     MyInventoryItem item = MyInventory.CreateInventoryItemFromInventoryItemObjectBuilder(inventoryItem);
     item.Owner = owner;
     return m_itemsRepository.AddItem(item);
 }
 private int CreateInventoryItemAddToRepository(MyMwcObjectBuilder_Base builder, float amount, MyMwcObjectBuilder_Inventory owner)
 {
     MyInventoryItem item = MyInventory.CreateInventoryItemFromObjectBuilder(builder, amount);
     item.Owner = owner;
     return m_itemsRepository.AddItem(item);
 }
 internal MyMwcObjectBuilder_PrefabContainer()
     : base()
 {
     Inventory = new MyMwcObjectBuilder_Inventory();
 }
 internal MyMwcObjectBuilder_CargoBox() : base() 
 {
     Inventory = new MyMwcObjectBuilder_Inventory();            
 }
        void CreateCargoBoxWithDroppedItems(IEnumerable<int> droppedItemIDs, MySmallShip dropper)
        {
            var worldMatrix = Matrix.CreateWorld(
                dropper.WorldVolume.Center, 
                dropper.GetForward(), 
                dropper.GetUp());

            var items = new List<MyMwcObjectBuilder_InventoryItem>();
            foreach (var droppedItemID in droppedItemIDs)
            {
                var inventoryItem = m_itemsRepository.GetItem(droppedItemID);
                items.Add(new MyMwcObjectBuilder_InventoryItem(inventoryItem.GetInventoryItemObjectBuilder(false), inventoryItem.Amount));
            }
            var inventory = new MyMwcObjectBuilder_Inventory(items, MyInventory.DEFAULT_MAX_ITEMS);

            var cargoBoxBuilder = new MyMwcObjectBuilder_CargoBox(inventory)
                {
                    CargoBoxType = MyMwcObjectBuilder_CargoBox_TypesEnum.DroppedItems
                };
            cargoBoxBuilder.PersistentFlags |= MyPersistentEntityFlags.ActivatedOnAllDifficulties;

            var cargoBox = MyEntities.CreateFromObjectBuilderAndAdd(null, cargoBoxBuilder, worldMatrix);

            var matrix = cargoBox.WorldMatrix;
            matrix.Translation += 0.8f * dropper.WorldVolume.Radius * dropper.GetForward();
            matrix.Translation -= 0.5f * dropper.WorldVolume.Radius * dropper.GetUp();
            cargoBox.WorldMatrix = matrix;

            cargoBoxBuilder.EntityId = cargoBox.EntityId.ToNullableUInt();
            if (MyMultiplayerGameplay.IsRunning)
            {
                MyMultiplayerGameplay.Static.NewEntity(cargoBoxBuilder, cargoBox.WorldMatrix);
                MyMultiplayerGameplay.Static.HookEntity(cargoBox);
            }
        }
 public MyMwcObjectBuilder_CargoBox(MyMwcObjectBuilder_Inventory inventory)            
 {
     Inventory = inventory;            
 }
 public MyMwcObjectBuilder_Drone()
 {
     Inventory = new MyMwcObjectBuilder_Inventory(new List<MyMwcObjectBuilder_InventoryItem>(), 1);
     Faction = MyMwcObjectBuilder_FactionEnum.None;
 }
        /// <summary>
        /// This constructor use only for bot's spawnpoints
        /// </summary>
        /// <param name="smallShipBuilder">Small ship's builder</param>
        /// <param name="otherSidesInventoryBuilder">Other side's inventory builder</param>
        /// <param name="otherSideInventoryName">Other side's inventory name</param>y
        public MyGuiScreenInventory(List<MySmallShipBuilderWithName> smallShipBuilders, int currentShipBuilderIndex, MyMwcObjectBuilder_Inventory otherSidesInventoryBuilder, StringBuilder otherSideInventoryName, bool resetWasAnythingTrasferedAfterComboboxChanged = false)
            : this(smallShipBuilders, currentShipBuilderIndex, 0f, false, otherSidesInventoryBuilder, otherSideInventoryName, MyGuiScreenInventoryType.GodEditor, resetWasAnythingTrasferedAfterComboboxChanged)
        {

        }
        public static MyMwcObjectBuilder_SmallShip_Player CreateDeathmatchShip(MyMwcObjectBuilder_FactionEnum faction)
        {
            List<MyMwcObjectBuilder_SmallShip_Weapon> weapons = new List<MyMwcObjectBuilder_SmallShip_Weapon>();
            List<MyMwcObjectBuilder_SmallShip_Ammo> ammo = new List<MyMwcObjectBuilder_SmallShip_Ammo>();
            List<MyMwcObjectBuilder_AssignmentOfAmmo> assignments = new List<MyMwcObjectBuilder_AssignmentOfAmmo>(
                new MyMwcObjectBuilder_AssignmentOfAmmo[]
            {
                new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Primary, MyMwcObjectBuilder_AmmoGroupEnum.Bullet, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic),
                new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Secondary, MyMwcObjectBuilder_AmmoGroupEnum.Missile, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_Basic),
                new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Third, MyMwcObjectBuilder_AmmoGroupEnum.Cannon, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Basic),
                new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Fourth, MyMwcObjectBuilder_AmmoGroupEnum.UniversalLauncherFront, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Basic),
                new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Fifth, MyMwcObjectBuilder_AmmoGroupEnum.UniversalLauncherBack, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Basic),
            }
            );

            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Autocanon));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Autocanon));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Missile_Launcher));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Cannon));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Shotgun));
            //weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Drilling_Device_Crusher));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Drilling_Device_Nuclear));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Universal_Launcher_Front));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Harvesting_Device));
            ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic));
            ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_BioChem));
            ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Automatic_Rifle_With_Silencer_High_Speed));
            ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_High_Speed));
            ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Basic));
            ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_Basic));
            ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Shotgun_Basic));
            ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Basic));

            MyMwcObjectBuilder_Inventory inventory = new MyMwcObjectBuilder_Inventory(new List<MyMwcObjectBuilder_InventoryItem>(), 1000);
            foreach (MyMwcObjectBuilder_SmallShip_Ammo ammoItem in ammo)
            {
                inventory.InventoryItems.Add(new MyMwcObjectBuilder_InventoryItem(ammoItem, 1000));
            }
            inventory.InventoryItems.Add(new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Radar(MyMwcObjectBuilder_SmallShip_Radar_TypesEnum.Radar_1), 1));
            var ship = new MyMwcObjectBuilder_SmallShip_Player(
                ChooseShip(faction),
                inventory,
                weapons,
                new MyMwcObjectBuilder_SmallShip_Engine(MyMwcObjectBuilder_SmallShip_Engine_TypesEnum.PowerCells_1),
                assignments,
                null,
                new MyMwcObjectBuilder_SmallShip_Radar(MyMwcObjectBuilder_SmallShip_Radar_TypesEnum.Radar_1),
                null,
                MyGameplayConstants.HEALTH_RATIO_MAX,
                100f,
                float.MaxValue,
                float.MaxValue,
                float.MaxValue,
                true, false, MyLightsConstants.MAX_SPOTLIGHT_SHADOW_RANGE, 0);

            ship.Faction = faction;
            return ship;
        }
 protected MyMwcObjectBuilder_Ship(MyMwcObjectBuilder_Inventory inventory)
     : this()
 {
     Inventory = inventory;
 }
        private MyMwcObjectBuilder_SmallShip_Player CreatePlayerShip()
        {
            List<MyMwcObjectBuilder_SmallShip_Weapon> weapons = new List<MyMwcObjectBuilder_SmallShip_Weapon>();
            List<MyMwcObjectBuilder_SmallShip_Ammo> ammo = new List<MyMwcObjectBuilder_SmallShip_Ammo>();
            List<MyMwcObjectBuilder_AssignmentOfAmmo> assignments = new List<MyMwcObjectBuilder_AssignmentOfAmmo>();

            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Autocanon));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Autocanon));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Missile_Launcher));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Cannon));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Shotgun));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Drilling_Device_Crusher));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Universal_Launcher_Front));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Harvesting_Device));
            ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic));
            ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_BioChem));
            ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Automatic_Rifle_With_Silencer_High_Speed));
            ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_High_Speed));
            ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Basic));
            ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Tunnel_Buster));
            ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_Basic));
            ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Guided_Missile_Engine_Detection));
            ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Guided_Missile_Visual_Detection));
            ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Shotgun_Basic));
            ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Hologram));
            ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Basic));
            ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Smart));
            assignments.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Primary, MyMwcObjectBuilder_AmmoGroupEnum.Bullet, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic));
            assignments.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Secondary, MyMwcObjectBuilder_AmmoGroupEnum.Missile, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_Basic));
            assignments.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Third, MyMwcObjectBuilder_AmmoGroupEnum.UniversalLauncherFront, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Basic));
            assignments.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Fourth, MyMwcObjectBuilder_AmmoGroupEnum.UniversalLauncherBack, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Smart));
            assignments.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Fifth, MyMwcObjectBuilder_AmmoGroupEnum.Bullet, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic));

            MyMwcObjectBuilder_Inventory inventory = new MyMwcObjectBuilder_Inventory(new List<MyMwcObjectBuilder_InventoryItem>(), 1000);
            foreach (MyMwcObjectBuilder_SmallShip_Ammo ammoItem in ammo)
            {
                inventory.InventoryItems.Add(new MyMwcObjectBuilder_InventoryItem(ammoItem, 1000));
            }
            //inventory.InventoryItems.Add(new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_FoundationFactory(), 1));            
            inventory.InventoryItems.Add(new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Radar(MyMwcObjectBuilder_SmallShip_Radar_TypesEnum.Radar_1), 1));

            //inventory.InventoryItems.Add(new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Harvesting_Device), 1));

            //return new MyMwcObjectBuilder_SmallShip_Player(
            //    MyMwcObjectBuilder_SmallShip_TypesEnum.GETTYSBURG, 
            //    weapons,
            //    new MyMwcObjectBuilder_SmallShip_Engine(MyMwcObjectBuilder_SmallShip_Engine_TypesEnum.Chemical_1), 
            //    ammo, 
            //    null,
            //    assignments);
            return new MyMwcObjectBuilder_SmallShip_Player(
                MyMwcObjectBuilder_SmallShip_TypesEnum.GETTYSBURG,
                inventory,
                weapons,
                new MyMwcObjectBuilder_SmallShip_Engine(MyMwcObjectBuilder_SmallShip_Engine_TypesEnum.PowerCells_1),
                assignments,
                null,
                new MyMwcObjectBuilder_SmallShip_Radar(MyMwcObjectBuilder_SmallShip_Radar_TypesEnum.Radar_1),
                null,
                MyGameplayConstants.HEALTH_RATIO_MAX,
                100f,
                float.MaxValue,
                float.MaxValue,
                float.MaxValue,
                true, false, MyLightsConstants.MAX_SPOTLIGHT_SHADOW_RANGE, 0);
        }
        //  Create a bot ship, which is a special computer-controlled type of miner ship.
        public MySmallShipBot CreateFakeBot(string hudLabelText, MyMwcObjectBuilder_SmallShip_TypesEnum shipType, Vector3 position, float health, Vector3? diffuseColor, MyMwcObjectBuilder_FactionEnum faction)
        {
            List<MyMwcObjectBuilder_SmallShip_Weapon> weapons = new List<MyMwcObjectBuilder_SmallShip_Weapon>();
            List<MyMwcObjectBuilder_AssignmentOfAmmo> assignments = new List<MyMwcObjectBuilder_AssignmentOfAmmo>();

            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Autocanon));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Autocanon));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Cannon));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Cannon));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Shotgun));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Drilling_Device_Crusher));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Universal_Launcher_Front));
            //ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(10000, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic));
            //ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(500, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_BioChem));
            //ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(1000, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Tunnel_Buster));
            //ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(10, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Automatic_Rifle_With_Silencer_High_Velocity));
            //ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(10000, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_High_Velocity));
            //ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(500000, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Basic));
            //ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(100000, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Tunnel_Buster));
            //ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(5, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Guided_Missile_Engine_Detection));
            //ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(5, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Guided_Missile_Visual_Detection));
            //ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(50, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Shotgun_Basic));
            //ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(5, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Hologram));
            //ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(15, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Basic));
            //ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(15, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Smart));
            assignments.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Primary, MyMwcObjectBuilder_AmmoGroupEnum.Cannon, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Basic));
            assignments.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Secondary, MyMwcObjectBuilder_AmmoGroupEnum.Cannon, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Basic));
            assignments.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Third, MyMwcObjectBuilder_AmmoGroupEnum.Bullet, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic));
            assignments.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Fourth, MyMwcObjectBuilder_AmmoGroupEnum.Bullet, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Automatic_Rifle_With_Silencer_BioChem));
            assignments.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Fifth, MyMwcObjectBuilder_AmmoGroupEnum.Bullet, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic));

            List<MyMwcObjectBuilder_InventoryItem> inventoryItems = new List<MyMwcObjectBuilder_InventoryItem>();
            MyMwcObjectBuilder_Inventory inventory = new MyMwcObjectBuilder_Inventory(inventoryItems, 1024);

            inventory.InventoryItems.Add(new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Automatic_Rifle_With_Silencer_High_Speed), 1000));
            inventory.InventoryItems.Add(new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic), 1000));
            inventory.InventoryItems.Add(new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Basic), 30));
            inventory.InventoryItems.Add(new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Tunnel_Buster), 10));
            inventory.InventoryItems.Add(new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Guided_Missile_Engine_Detection), 10));
            inventory.InventoryItems.Add(new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Guided_Missile_Visual_Detection), 10));


            MySmallShipBot bot = (MySmallShipBot)MyEntities.CreateFromObjectBuilderAndAdd(hudLabelText,
                //new MyMwcObjectBuilder_SmallShip_Bot(shipType, 
                //    weapons,
                //    new MyMwcObjectBuilder_SmallShip_Engine(MyMwcObjectBuilder_SmallShip_Engine_TypesEnum.Chemical_1), 
                //    ammo, 
                //    assignments,
                //    null,
                //    faction
                //    ),
                new MyMwcObjectBuilder_SmallShip_Bot(shipType,
                    inventory,
                    weapons,
                    new MyMwcObjectBuilder_SmallShip_Engine(MyMwcObjectBuilder_SmallShip_Engine_TypesEnum.Chemical_1),
                    assignments,
                    null,
                    null,
                    null,
                    health,
                    1000f,
                    float.MaxValue,
                    float.MaxValue,
                    true,
                    false,
                    faction,
                    MyAITemplateEnum.AGGRESIVE,
                    0,
                    1000,
                    1000,
                    MyPatrolMode.CYCLE,
                    null,
                    BotBehaviorType.IDLE,
                    MyLightsConstants.MAX_SPOTLIGHT_SHADOW_RANGE,
                    0, false, true),
                    Matrix.CreateWorld(position, Vector3.Backward, Vector3.Up)
               );

            /*
            bot.Inventory.AddInventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Remote_Camera), 50, true);
            bot.Inventory.AddInventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Hologram), 50, true);
            bot.Inventory.AddInventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Basic), 1500, true);
            bot.Inventory.AddInventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Smart), 1500, true);
                */
            //MyEntities.TestEntityAfterInsertionForCollision(bot);

            //System.Diagnostics.Debug.Assert(bot.MaxHealth > health);
            //bot.DoDamage(0, bot.MaxHealth - health, 0, MyDamageType.Unknown, MyAmmoType.Unknown, null);
            bot.Faction = faction;

            return bot;
        }
        //  Use only for quick test, random sandbox or trailer animations
        //  Never initialize as player ship! We can have only 1 player ship in the game
        public MySmallShip CreateFakeMinerShip(string hudLabelText, MyMwcObjectBuilder_SmallShip_TypesEnum shipType, Vector3 position, bool isPlayerShip, float health)
        {
            List<MyMwcObjectBuilder_SmallShip_Weapon> weapons = new List<MyMwcObjectBuilder_SmallShip_Weapon>();
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Autocanon));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Autocanon));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Missile_Launcher));
            //weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Missile_Launcher));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Harvesting_Device));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Drilling_Device_Crusher));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Universal_Launcher_Front));

            List<MyMwcObjectBuilder_AssignmentOfAmmo> assignmentOfAmmo = new List<MyMwcObjectBuilder_AssignmentOfAmmo>();
            assignmentOfAmmo.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Primary, MyMwcObjectBuilder_AmmoGroupEnum.Bullet, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic));
            assignmentOfAmmo.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Secondary, MyMwcObjectBuilder_AmmoGroupEnum.Missile, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_Basic));

            var inventory = new MyMwcObjectBuilder_Inventory(new List<MyMwcObjectBuilder_InventoryItem>()
            {
                new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic), 10000),
                new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_Basic), 10000),
            }, 1000);

            MySmallShip smallShipEntity;
            if (!isPlayerShip)
            {
                var shipBuilder = new MyMwcObjectBuilder_SmallShip(shipType,
                        inventory,
                        weapons,
                        new MyMwcObjectBuilder_SmallShip_Engine(MyMwcObjectBuilder_SmallShip_Engine_TypesEnum.PowerCells_1),
                        assignmentOfAmmo,
                        new MyMwcObjectBuilder_SmallShip_Armor(MyMwcObjectBuilder_SmallShip_Armor_TypesEnum.Basic),
                        null,
                        MyGameplayConstants.MAXHEALTH_SMALLSHIP,
                        1f,
                        100f,
                        float.MaxValue,
                        float.MaxValue,
                        true,
                        false,
                        MyLightsConstants.MAX_SPOTLIGHT_SHADOW_RANGE, 0);

                shipBuilder.Faction = MyMwcObjectBuilder_FactionEnum.Euroamerican;

                smallShipEntity = (MySmallShip)MyEntities.CreateFromObjectBuilderAndAdd(hudLabelText,
                    //new MyMwcObjectBuilder_SmallShip(shipType, 
                    //    weapons,
                    //    new MyMwcObjectBuilder_SmallShip_Engine(MyMwcObjectBuilder_SmallShip_Engine_TypesEnum.Chemical_1), 
                    //    ammo, 
                    //    assignmentOfAmmo,
                    //    null),
                    shipBuilder,
                    Matrix.CreateWorld(position, Vector3.Forward, Vector3.Up));
            }
            else
            {
                Vector3 forward = new Vector3(-0.664f, 0.556f, -0.499f);
                Vector3 up = new Vector3(0.437f, 0.856f, 0.340f);

                smallShipEntity = (MySmallShip)MyEntities.CreateFromObjectBuilderAndAdd(hudLabelText,
                    //new MyMwcObjectBuilder_SmallShip_Player(
                    //    shipType, 
                    //    weapons,
                    //    new MyMwcObjectBuilder_SmallShip_Engine(MyMwcObjectBuilder_SmallShip_Engine_TypesEnum.Chemical_1), 
                    //    ammo, 
                    //    null, 
                    //    assignmentOfAmmo),
                    new MyMwcObjectBuilder_SmallShip_Player(
                        shipType,
                        null,
                        weapons,
                        new MyMwcObjectBuilder_SmallShip_Engine(MyMwcObjectBuilder_SmallShip_Engine_TypesEnum.Chemical_1),
                        assignmentOfAmmo,
                        null,
                        null,
                        null,
                        MyGameplayConstants.HEALTH_RATIO_MAX,
                        100f,
                        float.MaxValue,
                        float.MaxValue,
                        float.MaxValue,
                        true, false, MyLightsConstants.MAX_SPOTLIGHT_SHADOW_RANGE, 0),
                    Matrix.CreateWorld(position, forward, up));
            }

            smallShipEntity.Inventory.AddInventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Automatic_Rifle_With_Silencer_High_Speed), 10, true);
            smallShipEntity.Inventory.AddInventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic), 10000, true);
            smallShipEntity.Inventory.AddInventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Armor_Piercing_Incendiary), 10000, true);
            smallShipEntity.Inventory.AddInventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_Basic), 500, true);
            smallShipEntity.Inventory.AddInventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Basic), 500, true);
            smallShipEntity.Inventory.AddInventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Tunnel_Buster), 1000, true);
            smallShipEntity.Inventory.AddInventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Guided_Missile_Engine_Detection), 5, true);
            smallShipEntity.Inventory.AddInventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Guided_Missile_Visual_Detection), 5, true);
            smallShipEntity.Inventory.AddInventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Remote_Camera), 5, true);
            smallShipEntity.Inventory.AddInventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Hologram), 5, true);
            smallShipEntity.Inventory.AddInventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Basic), 15, true);
            smallShipEntity.Inventory.AddInventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Smart), 15, true);

            return smallShipEntity;
        }
        public MyGuiScreenInventory(List<MySmallShipBuilderWithName> smallShipsBuilders, int currentShipBuilderIndex, float money, bool tradeForMoney,
            MyMwcObjectBuilder_Inventory otherSidesInventoryBuilder, StringBuilder otherSideInventoryName, MyGuiScreenInventoryType inventoryScreenType, bool resetWasAnythingTrasferedAfterComboboxChanged = false)
            : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, new Vector2(1.0f, 1.0f), true, MyGuiManager.GetInventoryScreenBackgroundTexture())
        {
            ScreenTimeout = TimeSpan.MaxValue;
            m_isInventoryLocked = true;
            m_resetWasAnythingTrasferedAfterComboboxChanged = resetWasAnythingTrasferedAfterComboboxChanged;
            m_isTransferingInProgress = false;
            m_wasAnythingTrasfered = false;

            m_smallShipsBuilders = smallShipsBuilders;
            m_smallShipsInventoryItemIDs = new List<MySmallShipInventoryItemIDs>(smallShipsBuilders.Count);
            m_currentShipBuilderIndex = currentShipBuilderIndex;
            m_otherSideInventoryBuilder = otherSidesInventoryBuilder;
            if (m_otherSideInventoryBuilder != null)
            {
                m_otherSideInventoryItemIDs = new List<int>();
            }
            m_shipInventoryHideList = new List<int>();
            m_otherSideInventoryHideList = new List<int>();
            m_tradeForMoney = tradeForMoney;
            m_inventoryScreenType = inventoryScreenType;

            m_itemsRepository = new MyInventoryItemsRepository();
            m_removedInventoryItemIDs = new List<int>();

            LoadInventoryItemsFromObjectBuilders();

            if (m_inventoryScreenType == MyGuiScreenInventoryType.GodEditor)
            {
                AddCaption(MyTextsWrapperEnum.ShipCustomizationCaption, new Vector2(0, 0.005f));
            }
            else
            {
                AddCaption(MyTextsWrapperEnum.ShipInventoryCaption, new Vector2(0, 0.005f));
            }
            m_enableBackgroundFade = false;
            m_backgroundFadeColor = Vector4.Zero;

            OnEnterCallback += OnOkClickDelegate;

            m_shipTexture = GetShipTexture();
            m_shipPanel = new MyGuiControlPanel(this, new Vector2(0.005f, -0.2347f), new Vector2(480 / 1600f, 367 / 1200f), MyGuiConstants.SCREEN_BACKGROUND_COLOR,
                    m_shipTexture, null, null, null,
                    MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
            Controls.Add(m_shipPanel);

            InitControls(otherSideInventoryName);

            FillOtherSideInventoryListbox();
            FillShipCustomizationListboxes(m_currentShipBuilderIndex);
            FillShipsCombobox();
            SwitchToShip(m_currentShipBuilderIndex);

            SetMoney(money);
            if (m_tradeForMoney) 
            {
                UpdateOtherSideInventoryListboxForTrading();
            }
            MyAudio.AddCue2D(MySoundCuesEnum.GuiWheelControlOpen);
        }
Esempio n. 22
0
        public void Init(string hudLabelText, MyMwcObjectBuilder_CargoBox objectBuilder, Matrix matrix)
        {
            Flags |= EntityFlags.EditableInEditor;

            StringBuilder hudLabelTextSb = (hudLabelText == null) ? MyTextsWrapper.Get(MyTextsWrapperEnum.CargoBox) : new StringBuilder(hudLabelText);

            // We want to make cargo box "lazy" to prevent rapid movement
            const float cargoBoxMass = 5000.0f;
            const float cargoAngularDamping = 0.5f;

            var modelLod0Enum = GetModelLod0EnumFromType(objectBuilder.CargoBoxType);

            base.Init(hudLabelTextSb, modelLod0Enum, null, null, null, objectBuilder);
            base.InitBoxPhysics(MyMaterialType.METAL, ModelLod0, cargoBoxMass, cargoAngularDamping, MyConstants.COLLISION_LAYER_DEFAULT, RigidBodyFlag.RBF_RBO_STATIC);
            this.Physics.LinearDamping = 0.7f;
            this.Physics.MaxLinearVelocity = 350;
            this.Physics.MaxAngularVelocity = 5;

            m_inventoryTemplate = objectBuilder.Inventory;
            if (m_inventoryTemplate != null)
            {
                Inventory.Init(m_inventoryTemplate);
            }
            CargoBoxType = objectBuilder.CargoBoxType;

            SetWorldMatrix(matrix);

            Save = true;
            this.Physics.Enabled = true;
            UpdateState();
        }
        //  Read this object from message-in
        internal override bool Read(BinaryReader binaryReader, EndPoint senderEndPoint, int gameVersion)
        {
            if (base.Read(binaryReader, senderEndPoint, gameVersion) == false) return NetworkError();

            //  TemplateId
            bool? isTemplateId = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);
            if (isTemplateId == null) return NetworkError();
            if (isTemplateId.Value)
            {
                TemplateId = MyMwcMessageIn.ReadInt32Ex(binaryReader, senderEndPoint);
            }
            else
            {
                TemplateId = null;
            }
            
            //  Container Type
            MyMwcObjectBuilder_PrefabContainer_TypesEnum? containerType = MyMwcMessageIn.ReadObjectBuilderPrefabContainerTypesEnumEx(binaryReader, senderEndPoint);
            if (containerType == null) return NetworkError();
            ContainerType = containerType.Value;
            MyMwcLog.IfNetVerbose_AddToLog("ContainerType: " + ContainerType);

            // Faction
            Faction = (MyMwcObjectBuilder_FactionEnum)MyMwcMessageIn.ReadInt32Ex(binaryReader, senderEndPoint);
            // Faction must be defined
            System.Diagnostics.Debug.Assert(Enum.IsDefined(typeof(MyMwcObjectBuilder_FactionEnum), Faction));

            //  Prefabs
            int? countPrefabs = MyMwcMessageIn.ReadInt32Ex(binaryReader, senderEndPoint);
            if (countPrefabs == null) return NetworkError();
            MyMwcLog.IfNetVerbose_AddToLog("countPrefabs: " + countPrefabs);
            Prefabs = new List<MyMwcObjectBuilder_PrefabBase>(countPrefabs.Value);
            for (int i = 0; i < countPrefabs; i++)
            {
                MyMwcObjectBuilder_PrefabBase prefab = MyMwcObjectBuilder_Base.ReadAndCreateNewObject(binaryReader, senderEndPoint) as MyMwcObjectBuilder_PrefabBase;
                if (prefab == null) return NetworkError();
                if (prefab.Read(binaryReader, senderEndPoint, gameVersion) == false) return NetworkError();
                Prefabs.Add(prefab);
            }

            //  Inventory
            bool? isInventory = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);
            if (isInventory == null) return NetworkError();
            if (isInventory.Value)
            {
                Inventory = MyMwcObjectBuilder_Base.ReadAndCreateNewObject(binaryReader, senderEndPoint) as MyMwcObjectBuilder_Inventory;
                if (Inventory == null) return NetworkError();
                if (Inventory.Read(binaryReader, senderEndPoint, gameVersion) == false) return NetworkError();
            }
            else
            {
                Inventory = null;
            }


            bool? hasDisplayName = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);
            if (!hasDisplayName.HasValue) return NetworkError();
            if (hasDisplayName.Value)
            {
                string displayName = MyMwcMessageIn.ReadStringEx(binaryReader, senderEndPoint);
                if (displayName == null) return NetworkError();
                MyMwcLog.IfNetVerbose_AddToLog("DisplayName: " + displayName);
                DisplayName = displayName;
            }
            else
            {
                MyMwcLog.IfNetVerbose_AddToLog("DisplayName: " + "null");
                DisplayName = null;
            }

            //  Use Properties
            bool? hasUseProperties = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);
            if (hasUseProperties == null) return NetworkError();
            if (hasUseProperties.Value)
            {
                UseProperties = MyMwcObjectBuilder_Base.ReadAndCreateNewObject(binaryReader, senderEndPoint) as MyMwcObjectBuilder_EntityUseProperties;
                if (UseProperties == null) return NetworkError();
                if (UseProperties.Read(binaryReader, senderEndPoint, gameVersion) == false) return NetworkError();
            }
            else
            {
                UseProperties = null;
            }

            //  Alarm On
            bool? alarmOn = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);
            if (alarmOn == null) return NetworkError();
            AlarmOn = alarmOn.Value;
            MyMwcLog.IfNetVerbose_AddToLog("AlarmOn: " + AlarmOn);

            //  Refill time
            bool? refillTime = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);
            if (refillTime == null) return NetworkError();
            if (refillTime.Value)
            {
                RefillTime = MyMwcMessageIn.ReadInt32Ex(binaryReader, senderEndPoint);
            }
            else
            {
                RefillTime = null;
            }

            return true;
        }
 public MyMwcObjectBuilder_SmallShip_Bot(MyMwcObjectBuilder_SmallShip_TypesEnum shipType,
     MyMwcObjectBuilder_Inventory inventory,
     List<MyMwcObjectBuilder_SmallShip_Weapon> weapons,
     MyMwcObjectBuilder_SmallShip_Engine engine, 
     List<MyMwcObjectBuilder_AssignmentOfAmmo> assignmentOfAmmo,
     MyMwcObjectBuilder_SmallShip_Armor armor,
     MyMwcObjectBuilder_SmallShip_Radar radar,            
     float? shipMaxHealth,
     float shipHealthRatio,
     float armorHealth,
     float oxygen,
     float fuel,
     bool reflectorLight,
     bool reflectorLongRange,
     MyMwcObjectBuilder_FactionEnum shipFaction,
     MyAITemplateEnum aiTemplate,
     float aggressivity,
     float seeDistance,
     float sleepDistance,
     MyPatrolMode patrolMode,
     uint? leader,
     BotBehaviorType idleBehavior,
     float reflectorShadowDistance,
     int aiPriority,
     bool leaderLostEnabled,
     bool activeAI)
     : base(shipType, inventory, weapons, engine, assignmentOfAmmo, armor, radar, shipMaxHealth, shipHealthRatio, armorHealth, oxygen, fuel, reflectorLight, reflectorLongRange, reflectorShadowDistance, aiPriority)
 {
     Faction = shipFaction;
     AITemplate = aiTemplate;
     Aggressivity = aggressivity;
     SeeDistance = seeDistance;
     SleepDistance = sleepDistance;
     PatrolMode = patrolMode;
     Leader = leader;
     IdleBehavior = idleBehavior;
     LeaderLostEnabled = leaderLostEnabled;
     ActiveAI = activeAI;
     SlowDown = 1;
 }