Exemple #1
0
 // Equip a wearable item
 public void Equip(Item thing)
 {
     Equipped.Add(thing);
 }
            public void UpdateInventoryCache()
            {
                using (new PerformanceLogger("UpdateCachedInventoryData"))
                {
                    Clear();

                    if (!ZetaDia.IsInGame || ZetaDia.Me == null || !ZetaDia.Me.IsValid || ZetaDia.CPlayer == null || !ZetaDia.CPlayer.IsValid)
                    {
                        return;
                    }



                    //var itemList = ZetaDia.Actors.GetActorsOfType<ACDItem>();
                    // Using backpack only for now, as grabbing all ACDItems is just slow and we don't have a use for them yet.
                    //var itemList = ZetaDia.Me.Inventory.Backpack;
                    //var inventory = ZetaDia.Me.Inventory;
                    //Equipped = inventory.Equipped.ToList();
                    //EquippedIds = new HashSet<int>(Equipped.Select(i => i.ActorSNO));
                    //Backpack = inventory.Backpack.ToList();
                    //Stash = inventory.StashItems.ToList();

                    KanaisCubeIds = new HashSet <int>(ZetaDia.CPlayer.KanaisPowersAssignedActorSnoIds);

                    // this turns out to be much faster than accessing ZetaDia.Me.Inventory
                    foreach (var item in ZetaDia.Actors.GetActorsOfType <ACDItem>().ToList())
                    {
                        if (!item.IsValid)
                        {
                            continue;
                        }

                        switch (item.InventorySlot)
                        {
                        case InventorySlot.BackpackItems:
                            Backpack.Add(item);
                            break;

                        //case InventorySlot.SharedStash:
                        //    Stash.Add(item);
                        //    break;

                        case InventorySlot.Bracers:
                        case InventorySlot.Feet:
                        case InventorySlot.Hands:
                        case InventorySlot.Head:
                        case InventorySlot.Waist:
                        case InventorySlot.Shoulders:
                        case InventorySlot.Torso:
                        case InventorySlot.LeftFinger:
                        case InventorySlot.RightFinger:
                        case InventorySlot.RightHand:
                        case InventorySlot.LeftHand:
                        case InventorySlot.Legs:
                        case InventorySlot.Neck:
                        case InventorySlot.Socket:
                            Equipped.Add(item);
                            EquippedIds.Add(item.ActorSNO);
                            break;

                        //case InventorySlot.Buyback:
                        //case InventorySlot.None:
                        default:
                            if ((int)item.InventorySlot == 19)
                            {
                                Equipped.Add(item);
                                EquippedIds.Add(item.ActorSNO);
                            }
                            //Other.Add(item);
                            break;
                        }
                    }

                    //IsGroundItemOverload = (Ground.Count > 50);

                    //Logger.Log(TrinityLogLevel.Debug, LogCategory.CacheManagement,
                    //    "Refreshed Inventory: Backpack={0} Stash={1} Equipped={2} Ground={3}",
                    //    Backpack.Count,
                    //    Stash.Count,
                    //    Equipped.Count,
                    //    Ground.Count);
                }
            }