예제 #1
0
        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);
        }
예제 #2
0
 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));
 }
예제 #3
0
 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);
         }
     }
 }