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); }
private bool onInventoryRetrieved(InventoryServiceEvents.InventoryLoaded evt) { Service.Get <EventDispatcher>().RemoveListener <InventoryServiceEvents.InventoryLoaded>(onInventoryRetrieved); DataEntityHandle localPlayerHandle = Service.Get <CPDataEntityCollection>().LocalPlayerHandle; if (!localPlayerHandle.IsNull) { inventoryData = Service.Get <CPDataEntityCollection>().AddComponent <InventoryData>(localPlayerHandle); inventoryData.Inventory = new Dictionary <long, InventoryIconModel <DCustomEquipment> >(); inventoryData.CurrentAvatarEquipment = new List <long>(); setTemplateData(); 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) { } } if (Service.Get <CPDataEntityCollection>().TryGetComponent(localPlayerHandle, out AvatarDetailsData component) && component.Outfit != null) { DCustomOutfit currentAvatarEquipment = default(DCustomOutfit); currentAvatarEquipment.Equipment = component.Outfit; setCurrentAvatarEquipment(currentAvatarEquipment); } } else { Log.LogError(this, "Unable to find the LocalPlayerHandle."); } setDefaultScreen(); string key = SceneTransitionService.SceneArgs.ShowCatalogOnEntry.ToString(); if (Service.Get <SceneTransitionService>().HasSceneArg(key) && (bool)Service.Get <SceneTransitionService>().GetSceneArg(key)) { showCatalog(); } return(false); }