private bool InventoryRemove(MyCubeBlock cube, MyInventory inventory) { try { MyInventory oldInventory; if (InventoryMonitor.TryRemove(cube, out oldInventory)) { inventory.InventoryContentChanged -= CheckAmmoInventory; int monitors; if (Session.InventoryMonitors.TryGetValue(inventory, out monitors)) { if (--monitors < 0) { MyConcurrentList <MyPhysicalInventoryItem> removedPhysical; MyConcurrentList <BetterInventoryItem> removedBetter; if (Session.InventoryItems.TryRemove(inventory, out removedPhysical)) { Session.PhysicalItemListPool.Return(removedPhysical); } if (Session.AmmoThreadItemList.TryRemove(inventory, out removedBetter)) { Session.BetterItemsListPool.Return(removedBetter); } Session.InventoryMonitors.Remove(inventory); } else { Session.InventoryMonitors[inventory] = monitors; } } else { return(false); } } } catch (Exception ex) { Log.Line($"Exception in InventoryRemove: {ex}"); } return(true); }