public void FinalizeData(LevelCompletionResults results) { if (songDataType == SongDataType.none && results.levelEndStateType == LevelCompletionResults.LevelEndStateType.Cleared) { songDataType = SongDataType.pass; } else if (songDataType == SongDataType.none && results.levelEndStateType == LevelCompletionResults.LevelEndStateType.Failed) { songDataType = SongDataType.fail; } dataCollector.UnregisterCollector(this); foreach (ITracker t in trackers.Values) { t.EndOfSong(results, this); } foreach (ITracker t in deepTrackers.Values) { t.EndOfSong(results, this); } deepTrackerResult = JsonConvert.SerializeObject(this, Formatting.None); // We store DeepTrackers in a private variable so it does not get serialized. Maybe find a better way to do so ? iDontLikeThat = deepTrackers; deepTrackers = null; trackerResult = JsonConvert.SerializeObject(this, Formatting.None); deepTrackers = iDontLikeThat; iDontLikeThat = null; }
private void IsNotAReplay(int score, int modifiedScore) { if (songDataType == SongDataType.replay) { songDataType = SongDataType.none; } scoreController.scoreDidChangeEvent -= IsNotAReplay; }
public SongData() { try { BOSC = Resources.FindObjectsOfTypeAll <BeatmapObjectSpawnController>().First(); GCSSD = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData; modifierData = Resources.FindObjectsOfTypeAll <GameplayModifiersModelSO>().First(); playerData = Resources.FindObjectsOfTypeAll <PlayerDataModel>().First(); scoreController = Resources.FindObjectsOfTypeAll <ScoreController>().First(); } catch (Exception) { Logger.log.Error("SongData couldn't be created. Did you start the tutorial ?"); return; } if (UserIDFix.UserIDIsReady) { playerID = UserIDFix.UserID; } else { UserIDFix.UserIDReady += SetUserID; } songID = GCSSD.difficultyBeatmap.level.levelID.Replace("custom_level_", "").Split('_')[0]; songDifficulty = GCSSD.difficultyBeatmap.difficulty.ToString().ToLower(); gameMode = GCSSD.difficultyBeatmap.level.beatmapLevelData.difficultyBeatmapSets[0].beatmapCharacteristic.serializedName; songDifficultyRank = GCSSD.difficultyBeatmap.difficultyRank; songName = GCSSD.difficultyBeatmap.level.songName; songArtist = GCSSD.difficultyBeatmap.level.songAuthorName; songMapper = GCSSD.difficultyBeatmap.level.levelAuthorName; WaitForAudioTimeSyncController(); if (GCSSD.practiceSettings != null) { songDataType = SongDataType.practice; songSpeed = GCSSD.practiceSettings.songSpeedMul; songStartTime = GCSSD.practiceSettings.startSongTime; } else { songDataType = SongDataType.replay; // We set it as a replay by default, then set it as a pass if IsNotAReplay() is called scoreController.scoreDidChangeEvent += IsNotAReplay; } dataCollector = new DataCollector(); dataCollector.RegisterCollector(this); }
public IEnumerable<SongDataItem> GetData(SongDataType datatype) { foreach (var data in Items) { if (data.DataType == datatype) yield return data; } }
public void DeleteData(SongDataType datatype) { Items.RemoveAll(it => it.DataType == datatype); }