本文整理汇总了C#中MyInventory.AddInventoryItems方法的典型用法代码示例。如果您正苦于以下问题:C# MyInventory.AddInventoryItems方法的具体用法?C# MyInventory.AddInventoryItems怎么用?C# MyInventory.AddInventoryItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyInventory
的用法示例。
在下文中一共展示了MyInventory.AddInventoryItems方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadGameInventory
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);
}
}
}