public EOInventoryItem(PacketAPI api, int slot, ItemRecord itemData, InventoryItem itemInventoryInfo, EOInventory inventory) : base(null, null, inventory) { m_api = api; m_itemData = itemData; m_inventory = itemInventoryInfo; Slot = slot; UpdateItemLocation(Slot); m_itemgfx = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.Items, 2 * itemData.Graphic, true); m_highlightBG = new Texture2D(Game.GraphicsDevice, DrawArea.Width - 3, DrawArea.Height - 3); Color[] highlight = new Color[(drawArea.Width - 3) * (drawArea.Height - 3)]; for (int i = 0; i < highlight.Length; ++i) { highlight[i] = Color.FromNonPremultiplied(200, 200, 200, 60); } m_highlightBG.SetData(highlight); _initItemLabel(); m_recentClickTimer = new Timer( _state => { if (m_recentClickCount > 0) Interlocked.Decrement(ref m_recentClickCount); }, null, 0, 1000); }
public bool UpdateItem(InventoryItem item) { EOInventoryItem ctrl; if((ctrl = m_childItems.Find(_ctrl => _ctrl.ItemData.ID == item.id)) != null) { ctrl.Inventory = item; ctrl.UpdateItemLabel(); } else { ItemRecord rec = World.Instance.EIF.GetItemRecordByID(item.id); return _addItemToSlot(_getNextOpenSlot(rec.Size), rec, item.amount); } return true; }
public void UpdateInventoryItem(short id, int characterAmount, byte characterWeight, byte characterMaxWeight, bool addToExistingAmount = false) { InventoryItem rec; if ((rec = Inventory.Find(item => item.id == id)).id == id) { InventoryItem newRec = new InventoryItem { amount = addToExistingAmount ? characterAmount + rec.amount : characterAmount, id = id }; if (this == World.Instance.MainPlayer.ActiveCharacter) { //false when AddItem fails to find a good spot if (!EOGame.Instance.Hud.UpdateInventory(newRec)) { EODialog.Show(World.GetString(DATCONST2.STATUS_LABEL_ITEM_PICKUP_NO_SPACE_LEFT), World.GetString(DATCONST2.STATUS_LABEL_TYPE_WARNING), XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader); return; } } //if we can hold it, update local inventory and weight stats if (!Inventory.Remove(rec)) throw new Exception("Unable to remove from inventory!"); if (newRec.amount > 0) { Inventory.Add(newRec); } Weight = characterWeight; MaxWeight = characterMaxWeight; if (this == World.Instance.MainPlayer.ActiveCharacter) EOGame.Instance.Hud.RefreshStats(); } else { //for item_get/chest_get packets, the item may not be in the inventory yet InventoryItem newRec = new InventoryItem {amount = characterAmount, id = id}; if (newRec.amount <= 0) return; Inventory.Add(newRec); if (this == World.Instance.MainPlayer.ActiveCharacter) { //false when AddItem fails to find a good spot if (!EOGame.Instance.Hud.UpdateInventory(newRec)) { EODialog.Show(World.GetString(DATCONST2.STATUS_LABEL_ITEM_PICKUP_NO_SPACE_LEFT), World.GetString(DATCONST2.STATUS_LABEL_TYPE_WARNING), XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader); return; } } Weight = characterWeight; MaxWeight = characterMaxWeight; if (this == World.Instance.MainPlayer.ActiveCharacter) EOGame.Instance.Hud.RefreshStats(); } }
public void UpdateInventoryItem(short id, int characterAmount, bool add = false) { InventoryItem rec; if ((rec = Inventory.Find(item => item.id == id)).id == id) { InventoryItem newRec = new InventoryItem {amount = add ? characterAmount + rec.amount : characterAmount, id = id}; if (!Inventory.Remove(rec)) throw new Exception("Unable to remove from inventory!"); if (newRec.amount > 0) { Inventory.Add(newRec); } if (this == World.Instance.MainPlayer.ActiveCharacter) EOGame.Instance.Hud.UpdateInventory(newRec); } else //if unequipping an item that isn't in the inventory yet { InventoryItem newRec = new InventoryItem {amount = characterAmount, id = id}; Inventory.Add(newRec); if (this == World.Instance.MainPlayer.ActiveCharacter) EOGame.Instance.Hud.UpdateInventory(newRec); } }
public bool UpdateInventory(InventoryItem item) { if (item.amount <= 0) inventory.RemoveItem(item.id); else return inventory.UpdateItem(item); return true; }