当前位置: 首页>>代码示例>>C#>>正文


C# MyInventoryBase.GetItemAmount方法代码示例

本文整理汇总了C#中VRage.Game.Entity.MyInventoryBase.GetItemAmount方法的典型用法代码示例。如果您正苦于以下问题:C# MyInventoryBase.GetItemAmount方法的具体用法?C# MyInventoryBase.GetItemAmount怎么用?C# MyInventoryBase.GetItemAmount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VRage.Game.Entity.MyInventoryBase的用法示例。


在下文中一共展示了MyInventoryBase.GetItemAmount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetItemAmountCombined

        public MyFixedPoint GetItemAmountCombined(MyInventoryBase inventory, MyDefinitionId contentId)
        {
            int amount = 0;
            var group = MyDefinitionManager.Static.GetGroupForComponent(contentId, out amount);
            if (group == null)
            {
                MyComponentSubstitutionDefinition substitutions;
                if (MyDefinitionManager.Static.TryGetComponentSubstitutionDefinition(contentId, out substitutions))
                {                    
                    foreach (var providingComponent in substitutions.ProvidingComponents)
                    {
                        amount += (int)inventory.GetItemAmount(providingComponent.Key) / providingComponent.Value;
                    }
                    return amount;
                }

                return inventory.GetItemAmount(contentId);
            }
            else
            {
                Clear();
                inventory.CountItems(m_componentCounts);
                AddItem(group.Id, amount, int.MaxValue);
                Solve(m_componentCounts);
                return GetSolvedItemCount();
            }
        }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:27,代码来源:MyComponentCombiner.cs

示例2: 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();
        }
开发者ID:zrisher,项目名称:SEGarden,代码行数:40,代码来源:GridInventoriesManager.cs


注:本文中的VRage.Game.Entity.MyInventoryBase.GetItemAmount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。