/// <summary> /// Handles a request to move an item within the inventory. /// This covers moving items within the backpack, from equipment /// slot to backpack and from backpack to equipment slot /// </summary> public void HandleInventoryRequestMoveMessage(InventoryRequestMoveMessage request) { Item item = _owner.World.GetItem(request.ItemID); // Request to equip item from backpack if (request.Location.EquipmentSlot != 0) { System.Diagnostics.Debug.Assert(_inventoryStash.Contains(request.ItemID) || _equipment.IsItemEquipped(request.ItemID), "Request to equip unknown item"); int targetEquipSlot = request.Location.EquipmentSlot; if (IsValidEquipmentRequest(item, targetEquipSlot)) { Item oldEquipItem = _equipment.GetEquipment(targetEquipSlot); // check if equipment slot is empty if (oldEquipItem == null) { // determine if item is in backpack or switching item from position with target originally empty if (_inventoryStash.Contains(item)) _inventoryStash.RemoveItem(item); else _equipment.UnequipItem(item); _equipment.EquipItem(item, targetEquipSlot); AcceptMoveRequest(item); } else { // check if item is already equipped at another equipmentslot if (_equipment.IsItemEquipped(item)) { // switch both items if (!IsValidEquipmentRequest(oldEquipItem, item.EquipmentSlot)) return; int oldEquipmentSlot = _equipment.UnequipItem(item); _equipment.EquipItem(item, targetEquipSlot); _equipment.EquipItem(oldEquipItem, oldEquipmentSlot); } else { // equip item and place other item in the backpack _inventoryStash.RemoveItem(item); _equipment.EquipItem(item, targetEquipSlot); _inventoryStash.AddItem(oldEquipItem); } AcceptMoveRequest(item); AcceptMoveRequest(oldEquipItem); } SendVisualInventory(this._owner); } } // Request to move an item (from backpack or equipmentslot) else { if (_inventoryStash.FreeSpace(item, request.Location.Row, request.Location.Column)) { if (_equipment.IsItemEquipped(item)) { _equipment.UnequipItem(item); // Unequip the item SendVisualInventory(this._owner); } else { _inventoryStash.RemoveItem(item); } _inventoryStash.AddItem(item, request.Location.Row, request.Location.Column); AcceptMoveRequest(item); } } }
/// <summary> /// Handles a request to move an item within the inventory. /// This covers moving items within the backpack, from equipment /// slot to backpack and from backpack to equipment slot /// </summary> public void HandleInventoryRequestMoveMessage(InventoryRequestMoveMessage request) { // Request to equip item from backpack if (request.Field1.Field1 != 0) { System.Diagnostics.Debug.Assert(Contains(request.Field0) || isItemEquipped(request.Field0), "Request to equip unknown item"); // TODO find out swapping items, so no equipping when the slot is occupied if (request.Field1.Field1 < EquipmentSlots && this.equipment[request.Field1.Field1] == 0) { Logger.Debug("Equip Item {0}", request.AsText()); RemoveItem(request.Field0); EquipItem(request.Field0, request.Field1.Field1); AcceptMoveRequest(request.Field0, request.Field1); RefreshVisual(request.Field1.Field0); } } // Request to move an item (from backpack or equipmentslot) else { if (FreeSpace(request.Field0, request.Field1.Field3, request.Field1.Field2)) { if (isItemEquipped(request.Field0)) { Logger.Debug("Unequip item {0}", request.AsText()); UnequipItem(request.Field0); RefreshVisual(request.Field1.Field0); } else { RemoveItem(request.Field0); } AddItem(request.Field0, request.Field1.Field3, request.Field1.Field2); AcceptMoveRequest(request.Field0, request.Field1); } } }
/// <summary> /// Handles a request to move an item within the inventory. /// This covers moving items within the backpack, from equipment /// slot to backpack and from backpack to equipment slot /// </summary> public void HandleInventoryRequestMoveMessage(InventoryRequestMoveMessage request) { // TODO Normal inventory movement does not require setting of inv loc msg! Just Tick. /fasbat Item item = GetItem(request.ItemID); if (item == null) return; // Request to equip item from backpack if (request.Location.EquipmentSlot != 0 && request.Location.EquipmentSlot != (int) EquipmentSlotId.Stash) { var sourceGrid = (item.InvLoc.EquipmentSlot == 0 ? _inventoryGrid : item.InvLoc.EquipmentSlot == (int)EquipmentSlotId.Stash ? _stashGrid : null); System.Diagnostics.Debug.Assert((sourceGrid != null && sourceGrid.Contains(request.ItemID)) || _equipment.IsItemEquipped(request.ItemID), "Request to equip unknown item"); int targetEquipSlot = request.Location.EquipmentSlot; if (IsValidEquipmentRequest(item, targetEquipSlot)) { Item oldEquipItem = _equipment.GetEquipment(targetEquipSlot); // check if equipment slot is empty if (oldEquipItem == null) { // determine if item is in backpack or switching item from position with target originally empty if (sourceGrid != null) sourceGrid.RemoveItem(item); else _equipment.UnequipItem(item); _equipment.EquipItem(item, targetEquipSlot); AcceptMoveRequest(item); } else { // check if item is already equipped at another equipmentslot if (_equipment.IsItemEquipped(item)) { // switch both items if (!IsValidEquipmentRequest(oldEquipItem, item.EquipmentSlot)) return; int oldEquipmentSlot = _equipment.UnequipItem(item); _equipment.EquipItem(item, targetEquipSlot); _equipment.EquipItem(oldEquipItem, oldEquipmentSlot); } else { // equip item and place other item in the backpack sourceGrid.RemoveItem(item); _equipment.EquipItem(item, targetEquipSlot); sourceGrid.AddItem(oldEquipItem); } AcceptMoveRequest(item); AcceptMoveRequest(oldEquipItem); } SendVisualInventory(this._owner); } } // Request to move an item (from backpack or equipmentslot) else { if (request.Location.EquipmentSlot == 0) { // check if not unsocketting rune for (int i = 0; i < _skillSocketRunes.Length; i++) { if (_skillSocketRunes[i] == request.ItemID) { if (_inventoryGrid.FreeSpace(item, request.Location.Row, request.Location.Column)) { RemoveRune(i); _inventoryGrid.AddItem(item, request.Location.Row, request.Location.Column); if (item.InvLoc.EquipmentSlot != request.Location.EquipmentSlot) AcceptMoveRequest(item); } return; } } } var destGrid = (request.Location.EquipmentSlot == 0 ? _inventoryGrid : _stashGrid); if (destGrid.FreeSpace(item, request.Location.Row, request.Location.Column)) { if (_equipment.IsItemEquipped(item)) { _equipment.UnequipItem(item); // Unequip the item SendVisualInventory(this._owner); } else { var sourceGrid = (item.InvLoc.EquipmentSlot == 0 ? _inventoryGrid : _stashGrid); sourceGrid.RemoveItem(item); } destGrid.AddItem(item, request.Location.Row, request.Location.Column); if (item.InvLoc.EquipmentSlot != request.Location.EquipmentSlot) AcceptMoveRequest(item); } } }
/// <summary> /// Handles a request to move an item within the inventory. /// This covers moving items within the backpack, from equipment /// slot to backpack and from backpack to equipment slot /// </summary> public void HandleInventoryRequestMoveMessage(InventoryRequestMoveMessage request) { Item item = _owner.World.GetItem(request.ItemID); // Request to equip item from backpack if (request.Location.EquipmentSlot != 0) { System.Diagnostics.Debug.Assert(Contains(request.ItemID) || IsItemEquipped(request.ItemID), "Request to equip unknown item"); // TODO find out swapping items, so no equipping when the slot is occupied if (request.Location.EquipmentSlot < EquipmentSlots && this._equipment[request.Location.EquipmentSlot] == 0) { Logger.Debug("Equip Item {0}", request.AsText()); RemoveItem(item); EquipItem(item, request.Location.EquipmentSlot); AcceptMoveRequest(item); RefreshVisual(_owner.DynamicID); } } // Request to move an item (from backpack or equipmentslot) else { if (FreeSpace(item, request.Location.Row, request.Location.Column)) { if (IsItemEquipped(item)) { Logger.Debug("Unequip item {0}", request.AsText()); UnequipItem(item); // Unequip the item RefreshVisual(_owner.DynamicID); // Refresh the visual equipment for the player } else { RemoveItem(item); } AddItem(item, request.Location.Row, request.Location.Column); AcceptMoveRequest(item); } } }