private bool onInventoryRetrieved(InventoryServiceEvents.InventoryLoaded evt) { Service.Get <EventDispatcher>().RemoveListener <InventoryServiceEvents.InventoryLoaded>(onInventoryRetrieved); DataEntityHandle localPlayerHandle = Service.Get <CPDataEntityCollection>().LocalPlayerHandle; if (!localPlayerHandle.IsNull) { InventoryData inventoryData = Service.Get <CPDataEntityCollection>().AddComponent <InventoryData>(localPlayerHandle); inventoryData.Inventory = new Dictionary <long, InventoryIconModel <DCustomEquipment> >(); inventoryData.CurrentAvatarEquipment = new List <long>(); for (int i = 0; i < evt.Inventory.Count; i++) { try { DCustomEquipment data = CustomEquipmentResponseAdaptor.ConvertResponseToCustomEquipment(evt.Inventory[i]); InventoryIconModel <DCustomEquipment> value = new InventoryIconModel <DCustomEquipment>(data.Id, data, isEquipped: false, isMemberItem: true); inventoryData.Inventory.Add(data.Id, value); } catch (KeyNotFoundException) { } } } else { Log.LogError(this, "Unable to find the LocalPlayerHandle."); } if (callback != null) { callback(); callback = null; } return(false); }
public void SetDisplayedInventoryToCategory(string categoryKey, bool ignoreHiddenItems) { long[] equipmentIdsForCategory = InventoryData.GetEquipmentIdsForCategory(categoryKey); DisplayedInventory = new List <long>(equipmentIdsForCategory); if (ignoreHiddenItems) { removeAllHiddenItemsFromDisplayedInventory(); } DisplayedInventory.Sort(compareInventoryIdByCreationDate); InventoryContext.EventBus.DispatchEvent(new InventoryModelEvents.DisplayedInventoryUpdated(DisplayedInventory.Count)); }
public void SetInventory(InventoryData inventoryData) { InventoryData = inventoryData; getHiddenItems(); memberInventory = new List <long>(); nonmemberInventory = new List <long>(); foreach (KeyValuePair <long, InventoryIconModel <DCustomEquipment> > item in InventoryData.Inventory) { if (item.Value.IsMemberItem) { memberInventory.Add(item.Key); } else { nonmemberInventory.Add(item.Key); } } }