コード例 #1
0
        private void UpdateTemplate(MyGuiScreenInventory sender, MyGuiScreenInventorySaveResult saveresult)
        {
            Debug.Assert(m_selectedTemplate != null);

            m_selectedTemplate.Builder = saveresult.SmallShipsObjectBuilders[saveresult.CurrentIndex].Builder;
            sender.OnSave -= UpdateTemplate;
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
 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);
     }
 }        
コード例 #5
0
        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);
            }
        }
コード例 #6
0
        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);
            }
        }
コード例 #7
0
 private void OnEditBotFromScreen(MyGuiScreenInventory sender, MyGuiScreenInventorySaveResult saveResult)
 {
     MySmallShipBuilderWithName resultBuilder = saveResult.SmallShipsObjectBuilders[saveResult.CurrentIndex];
     m_inventoryBuilder = resultBuilder.Builder;
 }
コード例 #8
0
        private void UpdateTemplate(MyGuiScreenInventory sender, MyGuiScreenInventorySaveResult saveresult)
        {
            Debug.Assert(m_selectedTemplate != null);

            m_selectedTemplate.Builder = saveresult.SmallShipsObjectBuilders[saveresult.CurrentIndex].Builder;
            sender.OnSave -= UpdateTemplate;
        }
コード例 #9
0
        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;
        }
コード例 #10
0
        private void OnEditBotFromScreen(MyGuiScreenInventory sender, MyGuiScreenInventorySaveResult saveResult)
        {
            MySmallShipBuilderWithName resultBuilder = saveResult.SmallShipsObjectBuilders[saveResult.CurrentIndex];

            m_inventoryBuilder = resultBuilder.Builder;
        }