Exemple #1
0
        public bool GetOwnerInventoryAtLocation(int locationID, int ownerID, out ItemInventoryByOwnerID inventory)
        {
            lock (this.MetaInventories)
            {
                inventory = null;

                return
                    (this.MetaInventories.TryGetValue(locationID, out Dictionary <int, ItemInventoryByOwnerID> inventories) == true &&
                     inventories.TryGetValue(ownerID, out inventory) == true);
            }
        }
Exemple #2
0
        public ItemInventory RegisterMetaInventoryForOwnerID(ItemInventory inventory, int ownerID)
        {
            lock (this.MetaInventories)
                lock (this.MetaInventoriesByOwner)
                {
                    // ensure the indexes already exists in the dictionary
                    this.MetaInventories.TryAdd(inventory.ID, new Dictionary <int, ItemInventoryByOwnerID>());
                    this.MetaInventoriesByOwner.TryAdd(ownerID, new List <ItemInventoryByOwnerID>());

                    // only create a new meta inventory if there is none already registered for that owner in that location
                    if (this.MetaInventories[inventory.ID].TryGetValue(ownerID, out ItemInventoryByOwnerID metaInventory) == false)
                    {
                        metaInventory = new ItemInventoryByOwnerID(ownerID, inventory);

                        this.MetaInventories[inventory.ID][ownerID] = metaInventory;
                        this.MetaInventoriesByOwner[ownerID].Add(metaInventory);
                    }

                    return(metaInventory);
                }
        }