本文整理汇总了C#中VRage.Game.Entity.MyInventoryBase.GetItems方法的典型用法代码示例。如果您正苦于以下问题:C# MyInventoryBase.GetItems方法的具体用法?C# MyInventoryBase.GetItems怎么用?C# MyInventoryBase.GetItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VRage.Game.Entity.MyInventoryBase
的用法示例。
在下文中一共展示了MyInventoryBase.GetItems方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BeforeContentsChanged
/*
private void BeforeContentsChanged(MyInventoryBase inventory) {
Log.Trace("BeforeContentsChanged called on inventory " + inventory.Entity.ToString(), "BeforeContentsChanged");
}
*/
private void OnContentsChanged(MyInventoryBase inventory)
{
Log.Trace("Updating inventory cache with inventory " + inventory.Entity.ToString(), "OnContentsChanged");
ItemCountsAggregate cachedCount;
if (!InventoryTotals.TryGetValue(inventory, out cachedCount)) {
Log.Error("Received an update for inventory we're not tracking.", "UpdateInventory");
return;
}
ItemCountsAggregate originalCounts = cachedCount.Copy();
Totals -= originalCounts;
if (WatchedItems != null) {
foreach (var id in WatchedItems) {
cachedCount.Set(id, inventory.GetItemAmount(id));
}
}
else {
foreach (var item in inventory.GetItems()) {
cachedCount.Set(item.Content.GetObjectId(), item.Amount);
}
}
Totals += cachedCount;
if (SkipNextNotify) {
SkipNextNotify = false;
}
else {
NotifyContentsChanged(cachedCount - originalCounts);
}
//DebugPrint();
}