private void EnergyDidChangeEvent(float health) { health *= 100; if (MapData.Modifiers["noFailOn0Energy"] && health <= 0) { MapData.LevelFailed = true; MapData.ModifiersMultiplier += -50 / 100f; MapData.Send(); } if (health < LiveData.PlayerHealth) { LiveData.Combo = 0; } LiveData.PlayerHealth = health; LiveData.Send(); }
public void Dispose() { #region Unsubscribe from events timer.Elapsed -= TimerElapsedEvent; beatmapObjectManager.noteWasCutEvent -= NoteWasCutEvent; beatmapObjectManager.noteWasMissedEvent -= NoteWasMissedEvent; gameEnergyCounter.gameEnergyDidChangeEvent -= EnergyDidChangeEvent; if (scoreController is ScoreController && multiplayerController is MultiplayerController) //In a multiplayer lobby { scoreController.scoreDidChangeEvent -= ScoreDidChangeEvent; scoreController.immediateMaxPossibleScoreDidChangeEvent -= ImmediateMaxPossibleScoreDidChangeEvent; multiplayerController.stateChangedEvent -= MultiplayerController_stateChangedEvent; } else if (IsLegacyReplay() && relativeScoreAndImmediateRankCounter is RelativeScoreAndImmediateRankCounter) //In a legacy replay. { relativeScoreAndImmediateRankCounter.relativeScoreOrImmediateRankDidChangeEvent -= RelativeScoreOrImmediateRankDidChangeEvent; } else if (scoreController is ScoreController && pauseController is PauseController && standardLevelGameplayManager is StandardLevelGameplayManager) //Singleplayer/New replay. { scoreController.scoreDidChangeEvent -= ScoreDidChangeEvent; //In replay mode this does not fire so 'RelativeScoreOrImmediateRankDidChangeEvent' will read from the UI scoreController.immediateMaxPossibleScoreDidChangeEvent -= ImmediateMaxPossibleScoreDidChangeEvent; pauseController.didPauseEvent -= LevelPausedEvent; pauseController.didResumeEvent -= LevelUnpausedEvent; pauseController.didReturnToMenuEvent -= LevelQuitEvent; standardLevelGameplayManager.levelFailedEvent -= LevelFailedEvent; standardLevelGameplayManager.levelFinishedEvent -= LevelFinishedEvent; } #endregion timer.Stop(); MapData.InLevel = false; MapData.Send(); }
private void LevelUnpausedEvent() { timer.Start(); MapData.LevelPaused = false; MapData.Send(); }
private void LevelPausedEvent() { timer.Stop(); MapData.LevelPaused = true; MapData.Send(); }
public void SetupMapDataAndMisc() { PlayerData playerData = Resources.FindObjectsOfTypeAll <PlayerDataModel>().FirstOrDefault().playerData; IBeatmapLevel levelData = gameplayCoreSceneSetupData.difficultyBeatmap.level; bool isCustomLevel = true; string mapHash = string.Empty; try { mapHash = levelData.levelID.Split('_')[2]; } catch { isCustomLevel = false; } isCustomLevel = isCustomLevel && mapHash.Length == 40 ? true : false; var difficultyData = SongCore.Collections.RetrieveDifficultyData(gameplayCoreSceneSetupData.difficultyBeatmap); MapData.Hash = isCustomLevel ? mapHash : null; MapData.SongName = levelData.songName; MapData.SongSubName = levelData.songSubName; MapData.SongAuthor = levelData.songAuthorName; MapData.Mapper = levelData.levelAuthorName; MapData.BPM = Convert.ToInt32(Math.Round(levelData.beatsPerMinute)); MapData.Length = Convert.ToInt32(Math.Round(audioTimeSyncController.songLength)); PlayerLevelStatsData playerLevelStats = playerData.GetPlayerLevelStatsData(levelData.levelID, gameplayCoreSceneSetupData.difficultyBeatmap.difficulty, gameplayCoreSceneSetupData.difficultyBeatmap.parentDifficultyBeatmapSet.beatmapCharacteristic); MapData.PreviousRecord = playerLevelStats.highScore; MapData.MapType = gameplayCoreSceneSetupData.difficultyBeatmap.parentDifficultyBeatmapSet.beatmapCharacteristic.serializedName; MapData.Difficulty = gameplayCoreSceneSetupData.difficultyBeatmap.difficulty.ToString("g"); MapData.NJS = gameplayCoreSceneSetupData.difficultyBeatmap.noteJumpMovementSpeed; MapData.CustomDifficultyLabel = difficultyData?._difficultyLabel ?? null; SongDataCoreCurrent sdc = new SongDataCoreCurrent { available = isCustomLevel ? SongDataCore.Plugin.Songs.IsDataAvailable() : false }; if (sdc.available) { BeatStarSong map; SongDataCore.Plugin.Songs.Data.Songs.TryGetValue(mapHash, out map); sdc.map = map; if (sdc.map != null) { Dictionary <string, BeatStarSongDifficultyStats> diffs = sdc.map.characteristics[(BeatStarCharacteristics)Enum.Parse(typeof(BeatStarCharacteristics), gameplayCoreSceneSetupData.difficultyBeatmap.parentDifficultyBeatmapSet.beatmapCharacteristic.serializedName)]; sdc.stats = diffs[MapData.Difficulty == "ExpertPlus" ? "Expert+" : MapData.Difficulty]; MapData.PP = sdc.stats.pp; MapData.Star = sdc.stats.star; } else { sdc.available = false; } } if (sdc.available) { MapData.BSRKey = sdc.map.key; if (levelData is CustomPreviewBeatmapLevel customLevel) { MapData.coverImage = GetBase64CoverImage(customLevel); } else { getBeatsaverMap(); } } else { getBeatsaverMap(); } void getBeatsaverMap() { Task.Run(async() => { Beatmap bm = await beatSaver.Hash(mapHash); if (bm != null) { MapData.BSRKey = bm.Key; MapData.coverImage = BeatSaver.BaseURL + bm.CoverURL; } else { MapData.BSRKey = null; } MapData.Send(); }); } if (MapData.Hash != previousStaticData.Hash) { MapData.PreviousBSR = previousStaticData.BSRKey; } MapData.Modifiers.Add("noFailOn0Energy", gameplayCoreSceneSetupData.gameplayModifiers.noFailOn0Energy); MapData.Modifiers.Add("oneLife", gameplayCoreSceneSetupData.gameplayModifiers.instaFail); MapData.Modifiers.Add("fourLives", gameplayCoreSceneSetupData.gameplayModifiers.energyType == GameplayModifiers.EnergyType.Battery); MapData.Modifiers.Add("noBombs", gameplayCoreSceneSetupData.gameplayModifiers.noBombs); MapData.Modifiers.Add("noWalls", gameplayCoreSceneSetupData.gameplayModifiers.enabledObstacleType == GameplayModifiers.EnabledObstacleType.NoObstacles); MapData.Modifiers.Add("noArrows", gameplayCoreSceneSetupData.gameplayModifiers.noArrows); MapData.Modifiers.Add("ghostNotes", gameplayCoreSceneSetupData.gameplayModifiers.ghostNotes); MapData.Modifiers.Add("disappearingArrows", gameplayCoreSceneSetupData.gameplayModifiers.disappearingArrows); MapData.Modifiers.Add("smallNotes", gameplayCoreSceneSetupData.gameplayModifiers.smallCubes); MapData.Modifiers.Add("proMode", gameplayCoreSceneSetupData.gameplayModifiers.proMode); MapData.Modifiers.Add("strictAngles", gameplayCoreSceneSetupData.gameplayModifiers.strictAngles); MapData.Modifiers.Add("zenMode", gameplayCoreSceneSetupData.gameplayModifiers.zenMode); MapData.Modifiers.Add("slowerSong", gameplayCoreSceneSetupData.gameplayModifiers.songSpeedMul == 0.85f ? true : false); MapData.Modifiers.Add("fasterSong", gameplayCoreSceneSetupData.gameplayModifiers.songSpeedMul == 1.2f ? true : false); MapData.Modifiers.Add("superFastSong", gameplayCoreSceneSetupData.gameplayModifiers.songSpeedMul == 1.5f ? true : false); foreach (KeyValuePair <string, bool> keyValue in MapData.Modifiers) { if (MapData.Modifiers[keyValue.Key] && Enum.IsDefined(typeof(Modifiers), keyValue.Key)) { MapData.ModifiersMultiplier += (int)(Modifiers)Enum.Parse(typeof(Modifiers), keyValue.Key) / 100f; } } MapData.PracticeMode = gameplayCoreSceneSetupData.practiceSettings != null ? true : false; MapData.PracticeModeModifiers.Add("songSpeedMul", MapData.PracticeMode ? gameplayCoreSceneSetupData.practiceSettings.songSpeedMul : 1); MapData.PracticeModeModifiers.Add("startInAdvanceAndClearNotes", MapData.PracticeMode ? gameplayCoreSceneSetupData.practiceSettings.startInAdvanceAndClearNotes ? 1 : 0 : 0); MapData.PracticeModeModifiers.Add("startSongTime", MapData.PracticeMode ? gameplayCoreSceneSetupData.practiceSettings.startSongTime : 0); MapData.InLevel = true; timer.Start(); MapData.Send(); LiveData.Send(); }