public static void Handle(Entities.GameClient client, DataPacket packet) { using (var warehouse = new WarehousePacket(packet)) { Data.Warehouse wh; if (client.Warehouses.TryGetValue((ushort)warehouse.WarehouseID, out wh)) { switch (warehouse.Action) { case Enums.WarehouseAction.Display: { wh.SendAll(); break; } case Enums.WarehouseAction.Add: { if (wh.FreeSpaces == 20) { return; } if (client.Inventory.ContainsByUID(warehouse.Identifier)) { Data.ItemInfo item = client.Inventory.RemoveItemByUID(warehouse.Identifier); if (item != null) { wh.AddItem(item); } } break; } case Enums.WarehouseAction.Remove: { if (client.Inventory.FreeSpaces == 40) { return; } if (wh.ContainsByUID(warehouse.Identifier)) { Data.ItemInfo item = wh.RemoveItemByUID(warehouse.Identifier); if (item != null) { client.Inventory.AddItem(item); //warehouse.WhType = 10; client.Send(warehouse); } } break; } } } } }
public static void Handle(Entities.GameClient client, DataPacket packet) { using (var warehouse = new WarehousePacket(packet)) { Data.Warehouse wh; if (client.Warehouses.TryGetValue((ushort)warehouse.WarehouseID, out wh)) { switch (warehouse.Action) { case Enums.WarehouseAction.Display: { wh.SendAll(); break; } case Enums.WarehouseAction.Add: { if (wh.FreeSpaces == 20) return; if (client.Inventory.ContainsByUID(warehouse.Identifier)) { Data.ItemInfo item = client.Inventory.RemoveItemByUID(warehouse.Identifier); if (item != null) { wh.AddItem(item); } } break; } case Enums.WarehouseAction.Remove: { if (client.Inventory.FreeSpaces == 40) return; if (wh.ContainsByUID(warehouse.Identifier)) { Data.ItemInfo item = wh.RemoveItemByUID(warehouse.Identifier); if (item != null) { client.Inventory.AddItem(item); //warehouse.WhType = 10; client.Send(warehouse); } } break; } } } } }