コード例 #1
0
ファイル: SessionSupport.cs プロジェクト: keleios/WeaponCore
        internal void StartAmmoTask()
        {
            InventoryUpdate = true;
            if (ITask.valid && ITask.Exceptions != null)
            {
                TaskHasErrors(ref ITask, "ITask");
            }

            for (int i = GridsToUpdateInvetories.Count - 1; i >= 0; i--)
            {
                for (int j = 0; j < GridsToUpdateInvetories[i].Inventories.Count; j++)
                {
                    var inventory = GridsToUpdateInvetories[i].Inventories[j];
                    InventoryItems[inventory].AddRange(inventory.GetItems());
                }
            }

            DefIdsComparer.Clear();
            GridsToUpdateInvetories.Clear();
            GridsToUpdateInvetoriesIndexer.Clear();

            ITask = MyAPIGateway.Parallel.StartBackground(ProccessAmmoMoves, ProccessAmmoCallback);
        }
コード例 #2
0
        internal void StartAmmoTask()
        {
            InventoryUpdate = true;
            if (ITask.valid && ITask.Exceptions != null)
            {
                TaskHasErrors(ref ITask, "ITask");
            }

            StallReporter.Start("StartAmmoTask", 3);
            foreach (var ai in GridsToUpdateInventories)
            {
                var logged = 0;
                foreach (var inventory in ai.InventoryMonitor.Values)
                {
                    var items = inventory?.GetItems();
                    if (items != null)
                    {
                        MyConcurrentList <MyPhysicalInventoryItem> phyItemList;
                        if (InventoryItems.TryGetValue(inventory, out phyItemList))
                        {
                            phyItemList.AddRange(items);
                        }
                        else if (logged++ == 0)
                        {
                            Log.Line($"phyItemList and inventory.entity is null in StartAmmoTask - grid:{ai.MyGrid.DebugName} - aiMarked:{ai.MarkedForClose} - cTick:{Tick - ai.AiCloseTick} - mTick:{Tick - ai.AiMarkedTick} - sTick:{Tick - ai.CreatedTick}");
                        }
                    }
                }
            }
            StallReporter.End();

            DefIdsComparer.Clear();
            GridsToUpdateInventories.Clear();

            ITask = MyAPIGateway.Parallel.StartBackground(ProccessAmmoMoves, ProccessAmmoCallback);
        }