private void Client_PacketRecieved(Packet packet) { if (packet.Type == PacketType.PlaySong) { PlaySong playSong = packet.SpecificPacket as PlaySong; var desiredLevel = Plugin.masterLevelList.First(x => x.levelID == playSong.levelId); var desiredCharacteristic = desiredLevel.previewDifficultyBeatmapSets.GetBeatmapCharacteristics().First(x => x.serializedName == playSong.characteristic.SerializedName); var desiredDifficulty = (BeatmapDifficulty)playSong.difficulty; SaberUtilities.PlaySong(desiredLevel, desiredCharacteristic, desiredDifficulty, playSong); } else if (packet.Type == PacketType.LoadSong) { LoadSong loadSong = packet.SpecificPacket as LoadSong; Action <IBeatmapLevel> SongLoaded = (loadedLevel) => { var loadedSong = new LoadedSong(); var beatmapLevel = new PreviewBeatmapLevel(); beatmapLevel.Characteristics = loadedLevel.beatmapLevelData.difficultyBeatmapSets.ToList().Select(x => { var characteristic = new Characteristic(); characteristic.SerializedName = x.beatmapCharacteristic.serializedName; characteristic.difficulties = loadedLevel.beatmapLevelData.difficultyBeatmapSets .First(y => y.beatmapCharacteristic.serializedName == x.beatmapCharacteristic.serializedName) .difficultyBeatmaps.Select(y => (Characteristic.BeatmapDifficulty)y.difficulty).ToArray(); return(characteristic); }).ToArray(); beatmapLevel.LevelId = loadedLevel.levelID; beatmapLevel.Name = loadedLevel.songName; beatmapLevel.Loaded = true; loadedSong.level = beatmapLevel; client.Send(new Packet(loadedSong).ToBytes()); }; LoadSong(loadSong.levelId, SongLoaded); } else if (packet.Type == PacketType.Command) { Command command = packet.SpecificPacket as Command; if (command.commandType == Command.CommandType.ReturnToMenu) { SaberUtilities.ReturnToMenu(); } } }
private void Client_PacketRecieved(Packet packet) { if (packet.Type == PacketType.PlaySong) { PlaySong playSong = packet.SpecificPacket as PlaySong; var desiredLevel = Plugin.masterLevelList.First(x => x.levelID == playSong.levelId); var desiredCharacteristic = desiredLevel.beatmapCharacteristics.First(x => x.serializedName == playSong.characteristic.SerializedName); var desiredDifficulty = (BeatmapDifficulty)playSong.difficulty; var playerSpecificSettings = new PlayerSpecificSettings(); playerSpecificSettings.advancedHud = playSong.playerSettings.advancedHud; playerSpecificSettings.leftHanded = playSong.playerSettings.leftHanded; playerSpecificSettings.noTextsAndHuds = playSong.playerSettings.noTextsAndHuds; playerSpecificSettings.reduceDebris = playSong.playerSettings.reduceDebris; playerSpecificSettings.staticLights = playSong.playerSettings.staticLights; var gameplayModifiers = new GameplayModifiers(); gameplayModifiers.batteryEnergy = playSong.gameplayModifiers.batteryEnergy; gameplayModifiers.disappearingArrows = playSong.gameplayModifiers.disappearingArrows; gameplayModifiers.failOnSaberClash = playSong.gameplayModifiers.failOnSaberClash; gameplayModifiers.fastNotes = playSong.gameplayModifiers.fastNotes; gameplayModifiers.ghostNotes = playSong.gameplayModifiers.ghostNotes; gameplayModifiers.instaFail = playSong.gameplayModifiers.instaFail; gameplayModifiers.noBombs = playSong.gameplayModifiers.noBombs; gameplayModifiers.noFail = playSong.gameplayModifiers.noFail; gameplayModifiers.noObstacles = playSong.gameplayModifiers.noObstacles; gameplayModifiers.songSpeed = (GameplayModifiers.SongSpeed)playSong.gameplayModifiers.songSpeed; SaberUtilities.PlaySong(desiredLevel, desiredCharacteristic, desiredDifficulty, gameplayModifiers, playerSpecificSettings); } else if (packet.Type == PacketType.LoadSong) { LoadSong loadSong = packet.SpecificPacket as LoadSong; Action <IBeatmapLevel> SongLoaded = (loadedLevel) => { var loadedSong = new LoadedSong(); var beatmapLevel = new PreviewBeatmapLevel(); beatmapLevel.Characteristics = loadedLevel.beatmapCharacteristics.ToList().Select(x => { var characteristic = new Characteristic(); characteristic.SerializedName = x.serializedName; characteristic.difficulties = loadedLevel.beatmapLevelData.difficultyBeatmapSets .First(y => y.beatmapCharacteristic.serializedName == x.serializedName) .difficultyBeatmaps.Select(y => (Characteristic.BeatmapDifficulty)y.difficulty).ToArray(); return(characteristic); }).ToArray(); beatmapLevel.LevelId = loadedLevel.levelID; beatmapLevel.Name = loadedLevel.songName; beatmapLevel.Loaded = true; loadedSong.level = beatmapLevel; client.Send(new Packet(loadedSong).ToBytes()); }; LoadSong(loadSong.levelId, SongLoaded); } else if (packet.Type == PacketType.Command) { Command command = packet.SpecificPacket as Command; if (command.commandType == Command.CommandType.ReturnToMenu) { SaberUtilities.ReturnToMenu(); } } }