private static void HandleReplaceCube(GameSession session, PacketReader packet) { CoordB coord = packet.Read <CoordB>(); packet.Skip(1); int replacementItemId = packet.ReadInt(); long replacementItemUid = packet.ReadLong(); byte unk = packet.ReadByte(); long unk2 = packet.ReadLong(); // maybe part of rotation? float zRotation = packet.ReadFloat(); CoordF rotation = new CoordF(); rotation.Z = zRotation; int plotNumber = MapMetadataStorage.GetPlotNumber(session.Player.MapId, coord); if (plotNumber < 0) { return; } //TODO: Add and remove appropriate items to warehouse inventory and furnishing inventory //TODO: If itemUid is not found, send player to purchase the item Item item = new Item(replacementItemId); Cube cube = new Cube(item, plotNumber); IFieldObject <Cube> fieldCube = session.FieldManager.RequestFieldObject(cube); fieldCube.Coord = coord.ToFloat(); fieldCube.Rotation = rotation; session.FieldManager.BroadcastPacket(ResponseCubePacket.ReplaceCube(session.FieldPlayer, fieldCube)); session.FieldManager.AddCube(fieldCube, session.FieldPlayer); }
private static void HandleAddFurnishing(GameSession session, PacketReader packet) { CoordB coord = packet.Read <CoordB>(); byte padding = packet.ReadByte(); int itemId = packet.ReadInt(); long itemUid = packet.ReadLong(); byte padding2 = packet.ReadByte(); CoordF rotation = packet.Read <CoordF>(); int plotNumber = MapMetadataStorage.GetPlotNumber(session.Player.MapId, coord); if (plotNumber < 0) { return; } // TODO: Check if player has rights to this plot FurnishingShopMetadata shopMetadata = FurnishingShopMetadataStorage.GetMetadata(itemId); if (shopMetadata == null || !shopMetadata.Buyable) { return; } if (itemUid == 0) // player needs to purchase { if (!PurchaseFurnishingItem(session, shopMetadata)) { return; } Item item = new Item(itemId); //TODO: Add and remove appropriate item to warehouse inventory and furnishing inventory Cube cube = new Cube(item, plotNumber); IFieldObject <Cube> fieldCube = session.FieldManager.RequestFieldObject(cube); fieldCube.Coord = coord.ToFloat(); fieldCube.Rotation = rotation; session.FieldManager.AddCube(fieldCube, session.FieldPlayer); } }