private void UpdateTemplate(MyGuiScreenInventory sender, MyGuiScreenInventorySaveResult saveresult) { Debug.Assert(m_selectedTemplate != null); m_selectedTemplate.Builder = saveresult.SmallShipsObjectBuilders[saveresult.CurrentIndex].Builder; sender.OnSave -= UpdateTemplate; }
private void AddTemplate(MyGuiScreenInventory sender, MyGuiScreenInventorySaveResult saveresult) { var newID = MySmallShipTemplates.GenerateNewID(); MySmallShipTemplates.AddTemplate(new MySmallShipTemplate( newID, new StringBuilder(m_newName), saveresult.SmallShipsObjectBuilders[saveresult.CurrentIndex].Builder, false)); UpdateControls(); sender.OnSave -= AddTemplate; }
private void OnAddBotFromScreen(MyGuiScreenInventory sender, MyGuiScreenInventorySaveResult saveResult) { bool isTemplate = !saveResult.WasAnythingTransfered && saveResult.SmallShipsObjectBuilders[saveResult.CurrentIndex].UserData != null; MySmallShipBuilderWithName resultBuilder = saveResult.SmallShipsObjectBuilders[saveResult.CurrentIndex]; if (isTemplate) { AddBot(resultBuilder.Builder, (MySmallShipTemplate)resultBuilder.UserData); } else { AddBot(resultBuilder.Builder); } }
private static void Save(MyGuiScreenInventory sender, MyGuiScreenInventorySaveResult saveResult) { // save money if (m_tradeForMoney) { m_player.Money = saveResult.Money; } bool isTradingWithMotherShip = IsTradingWithMothership(); List <MyInventoryItem> itemsToMothership = new List <MyInventoryItem>(); // save ships for (int i = 0; i < saveResult.SmallShipsObjectBuilders.Count; i++) { MyMwcObjectBuilder_SmallShip shipBuilder = saveResult.SmallShipsObjectBuilders[i].Builder; if (i == saveResult.CurrentIndex) { if (m_curentIndex == saveResult.CurrentIndex) { // we want init weapons only when weapons are not same if (!WeaponBuildersAreSame(m_player.Ship.Weapons.GetWeaponsObjectBuilders(true), shipBuilder.Weapons)) { m_player.Ship.Weapons.Init(shipBuilder.Weapons, shipBuilder.AssignmentOfAmmo); } m_player.Ship.Inventory.Init(shipBuilder.Inventory); m_player.Ship.Armor = shipBuilder.Armor; m_player.Ship.Engine = shipBuilder.Engine; } else { var oldShip = m_player.Ship; m_player.Ship.MarkForClose(); if (MyMultiplayerGameplay.IsRunning) { MyMultiplayerGameplay.Static.Respawn(shipBuilder, m_player.Ship.WorldMatrix); } else { var ship = MyEntities.CreateFromObjectBuilderAndAdd(null, shipBuilder, m_player.Ship.WorldMatrix); } // Update bots - bot logic runs on host MyBotCoordinator.ChangeShip(oldShip, m_player.Ship); } } else { if (isTradingWithMotherShip) { MyInventoryItem shipInventoryItem = MyInventory.CreateInventoryItemFromObjectBuilder(shipBuilder); itemsToMothership.Add(shipInventoryItem); //m_shipsInventoryOwner.Inventory.AddInventoryItem(shipInventoryItem); } } } // save other side inventory if (m_inventoryScreenType != MyGuiScreenInventoryType.GodEditor) { if (m_otherSideInventoryOwner != null) { if (isTradingWithMotherShip) { for (int i = saveResult.OtherSideInventoryObjectBuilder.InventoryItems.Count - 1; i >= 0; i--) { MyMwcObjectBuilder_InventoryItem itemBuilder = saveResult.OtherSideInventoryObjectBuilder.InventoryItems[i]; if (itemBuilder.IsTemporaryItem) { saveResult.OtherSideInventoryObjectBuilder.InventoryItems.RemoveAt(i); // because smallships was added when ships were saved if (itemBuilder.ItemObjectBuilder.GetObjectBuilderType() != MyMwcObjectBuilderTypeEnum.SmallShip_Player) { itemsToMothership.Add(MyInventory.CreateInventoryItemFromInventoryItemObjectBuilder(itemBuilder)); } } } } m_otherSideInventoryOwner.Inventory.Init(saveResult.OtherSideInventoryObjectBuilder); } } if (isTradingWithMotherShip) { m_shipsInventoryOwner.Inventory.AddInventoryItems(itemsToMothership); } }
private static void Save(MyGuiScreenInventory sender, MyGuiScreenInventorySaveResult saveResult) { // save money if (m_tradeForMoney) { m_player.Money = saveResult.Money; } bool isTradingWithMotherShip = IsTradingWithMothership(); List<MyInventoryItem> itemsToMothership = new List<MyInventoryItem>(); // save ships for (int i = 0; i < saveResult.SmallShipsObjectBuilders.Count; i++) { MyMwcObjectBuilder_SmallShip shipBuilder = saveResult.SmallShipsObjectBuilders[i].Builder; if (i == saveResult.CurrentIndex) { if (m_curentIndex == saveResult.CurrentIndex) { // we want init weapons only when weapons are not same if (!WeaponBuildersAreSame(m_player.Ship.Weapons.GetWeaponsObjectBuilders(true), shipBuilder.Weapons)) { m_player.Ship.Weapons.Init(shipBuilder.Weapons, shipBuilder.AssignmentOfAmmo); } m_player.Ship.Inventory.Init(shipBuilder.Inventory); m_player.Ship.Armor = shipBuilder.Armor; m_player.Ship.Engine = shipBuilder.Engine; } else { var oldShip = m_player.Ship; m_player.Ship.MarkForClose(); if (MyMultiplayerGameplay.IsRunning) { MyMultiplayerGameplay.Static.Respawn(shipBuilder, m_player.Ship.WorldMatrix); } else { var ship = MyEntities.CreateFromObjectBuilderAndAdd(null, shipBuilder, m_player.Ship.WorldMatrix); } // Update bots - bot logic runs on host MyBotCoordinator.ChangeShip(oldShip, m_player.Ship); } } else { if (isTradingWithMotherShip) { MyInventoryItem shipInventoryItem = MyInventory.CreateInventoryItemFromObjectBuilder(shipBuilder); itemsToMothership.Add(shipInventoryItem); //m_shipsInventoryOwner.Inventory.AddInventoryItem(shipInventoryItem); } } } // save other side inventory if (m_inventoryScreenType != MyGuiScreenInventoryType.GodEditor) { if (m_otherSideInventoryOwner != null) { if (isTradingWithMotherShip) { for (int i = saveResult.OtherSideInventoryObjectBuilder.InventoryItems.Count - 1; i >= 0; i--) { MyMwcObjectBuilder_InventoryItem itemBuilder = saveResult.OtherSideInventoryObjectBuilder.InventoryItems[i]; if (itemBuilder.IsTemporaryItem) { saveResult.OtherSideInventoryObjectBuilder.InventoryItems.RemoveAt(i); // because smallships was added when ships were saved if (itemBuilder.ItemObjectBuilder.GetObjectBuilderType() != MyMwcObjectBuilderTypeEnum.SmallShip_Player) { itemsToMothership.Add(MyInventory.CreateInventoryItemFromInventoryItemObjectBuilder(itemBuilder)); } } } } m_otherSideInventoryOwner.Inventory.Init(saveResult.OtherSideInventoryObjectBuilder); } } if (isTradingWithMotherShip) { m_shipsInventoryOwner.Inventory.AddInventoryItems(itemsToMothership); } }
private void OnEditBotFromScreen(MyGuiScreenInventory sender, MyGuiScreenInventorySaveResult saveResult) { MySmallShipBuilderWithName resultBuilder = saveResult.SmallShipsObjectBuilders[saveResult.CurrentIndex]; m_inventoryBuilder = resultBuilder.Builder; }