/// <summary> /// Gets the specified slot from the specified storage. Null if this item storage does not have /// a slot with the given identifier. /// </summary> /// <param name="itemStorage"></param> /// <param name="slotIdentifier"></param> /// <returns></returns> public static ItemSlot Get(ItemStorage itemStorage, SlotIdentifier slotIdentifier) { if (!itemStorage.HasSlot(slotIdentifier)) { return(null); } var instanceID = itemStorage.GetInstanceID(); slots.TryGetValue(instanceID, out var dict); if (dict == null) { dict = new Dictionary <SlotIdentifier, ItemSlot>(); slots.Add(instanceID, dict); } dict.TryGetValue(slotIdentifier, out var slot); if (slot == null) { slot = new ItemSlot(itemStorage, slotIdentifier); dict.Add(slotIdentifier, slot); } return(slot); }