protected StringBuilder GetEntityName(MyEntity entity) { if (!string.IsNullOrEmpty(entity.DisplayName)) { return(new StringBuilder(entity.GetCorrectDisplayName())); } else { if (entity is MyPrefabLargeWeapon && (entity as MyPrefabLargeWeapon).GetGun() != null) { MyLargeShipGunBase gun = (entity as MyPrefabLargeWeapon).GetGun(); if (gun is MyLargeShipAutocannon) { return(MyTextsWrapper.Get(MyTextsWrapperEnum.Autocannon)); } else if (gun is MyLargeShipCIWS) { return(MyTextsWrapper.Get(MyTextsWrapperEnum.CIWS)); } else if (gun is MyLargeShipMachineGun) { return(MyTextsWrapper.Get(MyTextsWrapperEnum.MachineGun)); } else if (gun is MyLargeShipMissileLauncherGun) { return(MyTextsWrapper.Get(MyTextsWrapperEnum.MissileLauncher)); } } else if (entity is MyPrefabCamera) { return(MyTextsWrapper.Get(MyTextsWrapperEnum.Camera)); } else if (entity is MyPrefabAlarm) { return(MyTextsWrapper.Get(MyTextsWrapperEnum.Alarm)); } else if (entity is MyPrefabBankNode) { return(MyTextsWrapper.Get(MyTextsWrapperEnum.BankNode)); } else if (entity is MyPrefabGenerator) { return(MyTextsWrapper.Get(MyTextsWrapperEnum.Generator)); } else if (entity is MyPrefabScanner) { return(MyTextsWrapper.Get(MyTextsWrapperEnum.Scanner)); } else if (entity is MyPrefabContainer) { return(MyTextsWrapper.Get(MyTextsWrapperEnum.Alarm)); } else if (entity is MyPrefabKinematic) { MyPrefabKinematic pk = (MyPrefabKinematic)entity; return(MyTextsWrapper.Get(MyTextsWrapperEnum.Door)); } return(new StringBuilder()); } }
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); } } }