private void OnInventoryDropItemMessage(InventoryDropItemMessage msg) { var item = GetItem(msg.ItemID); if (item == null) { return; // TODO: Throw smthg? /fasbat } if (_equipment.IsItemEquipped(item)) { _equipment.UnequipItem(item); SendVisualInventory(this._owner); } else { var sourceGrid = (item.InvLoc.EquipmentSlot == 0 ? _inventoryGrid : _stashGrid); sourceGrid.RemoveItem(item); } item.CurrentState = ItemState.Dropping; item.Unreveal(_owner); item.SetNewWorld(_owner.World); item.Drop(null, _owner.Position); if (item.DBInventory != null) { _dbInventoriesToDelete.Add(item.DBInventory); } item.DBInventory = null; item.CurrentState = ItemState.Normal; AcceptMoveRequest(item); }
public string DropAll(string[] @params, MooNetClient invokerClient) { if (invokerClient == null) { return("You can not invoke this command from console."); } if (invokerClient.InGameClient == null) { return("You can only invoke this command while ingame."); } var player = invokerClient.InGameClient.Player; var bpItems = new List <Item>(player.Inventory.GetBackPackItems()); foreach (var item in bpItems) { var msg = new InventoryDropItemMessage { ItemID = item.DynamicID }; player.Inventory.Consume(invokerClient.InGameClient, msg); } return(string.Format("Dropped {0} Items for you", bpItems.Count)); }
private void OnInventoryDropItemMessage(InventoryDropItemMessage msg) { InventoryItem inv_item; if (!this.Contains(msg.ItemID)) { if (this._equipment.ItemsEquiped.ContainsKey(msg.ItemID)) { inv_item = (InventoryItem)this._equipment.ItemsEquiped[msg.ItemID]; } else { Logging.LogManager.DefaultLogger.Error("Trying to DROP an item that is not in inventory or equipment!"); return; } } else { inv_item = (InventoryItem)this.Items[msg.ItemID]; } if (inv_item.EquipmentSlot == EquipmentSlotId.Inventory) { //Inventory to ground!, so delete from inventory and drop item! if (!this.Contains(inv_item.DynamicID)) { Logging.LogManager.DefaultLogger.Error("Trying to DROP an item, from inventory to the ground but it is not in the inventory!"); return; } if (!this.removeItem(inv_item)) { Logging.LogManager.DefaultLogger.Error("could not remove item!, inventory to ground operation"); return; } Map currentPlayerMap = (this.Owner as Player).World; Item item = ItemFactory.CreateItem(inv_item.SNOId); currentPlayerMap.Enter(item, this.Owner.Position); DestroyInventoryItemMessage destroymsg = new DestroyInventoryItemMessage(); destroymsg.InventorySlot = new InventorySlot(0, 0); destroymsg.ItemID = inv_item.DynamicID; destroymsg.inventoryWindowId = (int)InventoryWindowsID.PlayerInventory; destroymsg.SNO = inv_item.SNOId; (this.Owner as Player).GameClient.SendMessage(destroymsg); //this.broadcastVisualEquipment(); } else { //Equipment to ground!, so delete from inventory and drop item! } }