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); } }
private static void HandleSendPortalSettings(GameSession session, PacketReader packet) { CoordB coordB = packet.Read <CoordB>(); // 50400158 = Portal Cube IFieldObject <Cube> cube = session.FieldManager.State.Cubes.Values .FirstOrDefault(x => x.Coord == coordB.ToFloat() && x.Value.Item.Id == 50400158); if (cube is null) { return; } List <Cube> otherPortals = session.FieldManager.State.Cubes.Values .Where(x => x.Value.Item.Id == 50400158 && x.Value.Uid != cube.Value.Uid) .Select(x => x.Value).ToList(); session.Send(HomeActionPacket.SendCubePortalSettings(cube.Value, otherPortals)); }
private static void HandleChangePortalSettings(GameSession session, PacketReader packet) { packet.ReadByte(); CoordB coordB = packet.Read <CoordB>(); packet.ReadByte(); IFieldObject <Cube> fieldCube = session.FieldManager.State.Cubes.Values.FirstOrDefault(x => x.Coord == coordB.ToFloat()); if (fieldCube is null) { return; } Cube cube = fieldCube.Value; cube.PortalSettings.PortalName = packet.ReadUnicodeString(); cube.PortalSettings.Method = (UGCPortalMethod)packet.ReadByte(); cube.PortalSettings.Destination = (UGCPortalDestination)packet.ReadByte(); cube.PortalSettings.DestinationTarget = packet.ReadUnicodeString(); DatabaseManager.Cubes.Update(cube); UpdateAllPortals(session); }