private static void LoadGameInventory(ref MyInventory otherSideInventory, ref StringBuilder otherSideInventoryName, ref List <MySmallShipBuilderWithName> shipsObjectBuilders) { if (MySession.PlayerShip.TradeDetector != null && m_detectedEntity == null) { m_detectedEntity = MySession.PlayerShip.TradeDetector.GetNearestEntity(); } if (m_detectedEntity != null) { if (m_detectedAction == null) { m_detectedAction = (MySmallShipInteractionActionEnum)MySession.PlayerShip.TradeDetector.GetNearestEntityCriterias(); } m_otherSideInventoryOwner = m_detectedEntity as IMyInventory; otherSideInventory = m_otherSideInventoryOwner.Inventory; string entityName; if (m_detectedEntity is MyPrefabHangar) { entityName = ((m_detectedEntity) as MyPrefabHangar).GetOwner().GetCorrectDisplayName(); } else { entityName = m_detectedEntity.GetCorrectDisplayName(); } switch (m_detectedAction) { case MySmallShipInteractionActionEnum.TradeForFree: if (IsTradingWithMothership()) { List <MyInventoryItem> inventoryItems = new List <MyInventoryItem>(); foreach (MyInventoryItem inventoryItem in m_shipsInventoryOwner.Inventory.GetInventoryItems()) { if (inventoryItem.ObjectBuilderType == MyMwcObjectBuilderTypeEnum.SmallShip_Player) { shipsObjectBuilders.Add(new MySmallShipBuilderWithName(inventoryItem.GetInventoryItemObjectBuilder(false) as MyMwcObjectBuilder_SmallShip_Player)); } else if (inventoryItem.ObjectBuilderType == MyMwcObjectBuilderTypeEnum.SmallShip_HackingTool) { inventoryItem.CanBeMoved = false; } else { continue; } inventoryItem.IsTemporaryItem = true; inventoryItems.Add(inventoryItem); } //m_shipsInventoryOwner.Inventory.RemoveInventoryItems(inventoryItems); //m_shipsInventoryOwner.Inventory.RemoveInventoryItems(MyMwcObjectBuilderTypeEnum.SmallShip_Player, null); //m_shipsInventoryOwner.Inventory.ClearInventoryItems(false); m_shipsInventoryOwner.Inventory.RemoveInventoryItems(inventoryItems, false); otherSideInventory.AddInventoryItems(inventoryItems); } break; case MySmallShipInteractionActionEnum.TradeForMoney: m_tradeForMoney = true; if (m_detectedEntity is MySmallShipBot) { otherSideInventory.PriceCoeficient = 3f; } break; case MySmallShipInteractionActionEnum.Blocked: case MySmallShipInteractionActionEnum.Build: case MySmallShipInteractionActionEnum.Loot: case MySmallShipInteractionActionEnum.Examine: case MySmallShipInteractionActionEnum.ExamineEmpty: break; default: throw new MyMwcExceptionApplicationShouldNotGetHere(); } otherSideInventoryName = new StringBuilder(); if (string.IsNullOrEmpty(entityName)) { otherSideInventoryName.Append(MyTextsWrapper.Get(MyTextsWrapperEnum.OtherSide)); } else { otherSideInventoryName.Append(entityName); //otherSideInventoryName.Append(MyTextsWrapper.Get(MyTextsWrapperEnum.OtherSideInventory)); } if (OpeningInventoryScreen != null) { OpeningInventoryScreen(m_detectedEntity, m_detectedAction.Value); } } }
private static void LoadGameInventory(ref MyInventory otherSideInventory, ref StringBuilder otherSideInventoryName, ref List<MySmallShipBuilderWithName> shipsObjectBuilders) { if (MySession.PlayerShip.TradeDetector != null && m_detectedEntity == null) { m_detectedEntity = MySession.PlayerShip.TradeDetector.GetNearestEntity(); } if (m_detectedEntity != null) { if (m_detectedAction == null) { m_detectedAction = (MySmallShipInteractionActionEnum)MySession.PlayerShip.TradeDetector.GetNearestEntityCriterias(); } m_otherSideInventoryOwner = m_detectedEntity as IMyInventory; otherSideInventory = m_otherSideInventoryOwner.Inventory; string entityName; if (m_detectedEntity is MyPrefabHangar) { entityName = ((m_detectedEntity) as MyPrefabHangar).GetOwner().GetCorrectDisplayName(); } else { entityName = m_detectedEntity.GetCorrectDisplayName(); } switch (m_detectedAction) { case MySmallShipInteractionActionEnum.TradeForFree: if (IsTradingWithMothership()) { List<MyInventoryItem> inventoryItems = new List<MyInventoryItem>(); foreach (MyInventoryItem inventoryItem in m_shipsInventoryOwner.Inventory.GetInventoryItems()) { if (inventoryItem.ObjectBuilderType == MyMwcObjectBuilderTypeEnum.SmallShip_Player) { shipsObjectBuilders.Add(new MySmallShipBuilderWithName(inventoryItem.GetInventoryItemObjectBuilder(false) as MyMwcObjectBuilder_SmallShip_Player)); } else if (inventoryItem.ObjectBuilderType == MyMwcObjectBuilderTypeEnum.SmallShip_HackingTool) { inventoryItem.CanBeMoved = false; } else { continue; } inventoryItem.IsTemporaryItem = true; inventoryItems.Add(inventoryItem); } //m_shipsInventoryOwner.Inventory.RemoveInventoryItems(inventoryItems); //m_shipsInventoryOwner.Inventory.RemoveInventoryItems(MyMwcObjectBuilderTypeEnum.SmallShip_Player, null); //m_shipsInventoryOwner.Inventory.ClearInventoryItems(false); m_shipsInventoryOwner.Inventory.RemoveInventoryItems(inventoryItems, false); otherSideInventory.AddInventoryItems(inventoryItems); } break; case MySmallShipInteractionActionEnum.TradeForMoney: m_tradeForMoney = true; if (m_detectedEntity is MySmallShipBot) { otherSideInventory.PriceCoeficient = 3f; } break; case MySmallShipInteractionActionEnum.Blocked: case MySmallShipInteractionActionEnum.Build: case MySmallShipInteractionActionEnum.Loot: case MySmallShipInteractionActionEnum.Examine: case MySmallShipInteractionActionEnum.ExamineEmpty: break; default: throw new MyMwcExceptionApplicationShouldNotGetHere(); } otherSideInventoryName = new StringBuilder(); if (string.IsNullOrEmpty(entityName)) { otherSideInventoryName.Append(MyTextsWrapper.Get(MyTextsWrapperEnum.OtherSide)); } else { otherSideInventoryName.Append(entityName); //otherSideInventoryName.Append(MyTextsWrapper.Get(MyTextsWrapperEnum.OtherSideInventory)); } if (OpeningInventoryScreen != null) { OpeningInventoryScreen(m_detectedEntity, m_detectedAction.Value); } } }