Ejemplo n.º 1
0
        private void SceneManagerOnActiveSceneChanged(Scene arg0, Scene scene)
        {
            if (scene.buildIndex == 1)
            {
                if (SettingsObject == null)
                {
                    var volumeSettings = Resources.FindObjectsOfTypeAll <VolumeSettingsController>().FirstOrDefault();
                    volumeSettings.gameObject.SetActive(false);
                    SettingsObject = Object.Instantiate(volumeSettings.gameObject);
                    SettingsObject.SetActive(false);
                    volumeSettings.gameObject.SetActive(true);
                    var volume = SettingsObject.GetComponent <VolumeSettingsController>();
                    ReflectionUtil.CopyComponent(volume, typeof(SimpleSettingsController), typeof(SpeedSettingsController), SettingsObject);
                    Object.DestroyImmediate(volume);
                    SettingsObject.GetComponentInChildren <TMP_Text>().text = "SPEED";
                    Object.DontDestroyOnLoad(SettingsObject);
                }
            }
            else
            {
                if (_mainGameSceneSetupData == null)
                {
                    _mainGameSceneSetupData = Resources.FindObjectsOfTypeAll <MainGameSceneSetupData>().FirstOrDefault();
                }

                if (_mainGameSceneSetupData == null || scene.buildIndex != 4)
                {
                    return;
                }

                if (_lastLevelId != _mainGameSceneSetupData.levelId && !string.IsNullOrEmpty(_lastLevelId))
                {
                    TimeScale    = 1;
                    _lastLevelId = _mainGameSceneSetupData.levelId;
                }

                _lastLevelId = _mainGameSceneSetupData.levelId;

                _audioTimeSync = Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().FirstOrDefault();
                _audioTimeSync.forcedAudioSync = true;
                _songAudio = ReflectionUtil.GetPrivateField <AudioSource>(_audioTimeSync, "_audioSource");
                Enabled    = _mainGameSceneSetupData.gameplayOptions.noEnergy;
                var noteCutSoundEffectManager = Resources.FindObjectsOfTypeAll <NoteCutSoundEffectManager>().FirstOrDefault();
                var noteCutSoundEffect        =
                    ReflectionUtil.GetPrivateField <NoteCutSoundEffect>(noteCutSoundEffectManager, "_noteCutSoundEffectPrefab");
                _noteCutAudioSource =
                    ReflectionUtil.GetPrivateField <AudioSource>(noteCutSoundEffect, "_audioSource");

                var canvas = Resources.FindObjectsOfTypeAll <HorizontalLayoutGroup>().FirstOrDefault(x => x.name == "Buttons")
                             .transform.parent;
                canvas.gameObject.AddComponent <SpeedSettingsCreator>();
                TimeScale = TimeScale;

                gameSongController        = Resources.FindObjectsOfTypeAll <GameSongController>().FirstOrDefault();
                songObjectSpawnController = Resources.FindObjectsOfTypeAll <SongObjectSpawnController>().FirstOrDefault();
                scoreController           = Resources.FindObjectsOfTypeAll <ScoreController>().FirstOrDefault <ScoreController>();

                scoresDict = new Dictionary <int, ScoreListItem>();
            }
        }
Ejemplo n.º 2
0
        void EnsureMainGameSceneSetup()
        {
            if (_mainGameSceneSetupData == null)
            {
                _mainGameSceneSetupData = Resources.FindObjectsOfTypeAll <MainGameSceneSetupData>().FirstOrDefault();

                if (_mainGameSceneSetupData == null)
                {
                    return;
                }
                _mainGameSceneSetupData.didFinishEvent += OnMainGameSceneDidFinish;
            }

            if (_justPreventedSubmission)
            {
                var resultsViewController = Resources.FindObjectsOfTypeAll <ResultsViewController>().FirstOrDefault();
                if (resultsViewController == null)
                {
                    return;
                }

                resultsViewController.continueButtonPressedEvent += controller =>
                {
                    PersistentSingleton <GameDataModel> .instance
                    .gameDynamicData.GetCurrentPlayerDynamicData()
                    .gameplayOptions.noEnergy = false;

                    _justPreventedSubmission = false;
                };
            }
        }
Ejemplo n.º 3
0
        private void Start()
        {
            try
            {
                Console.WriteLine("Darth Maul Loaded");
                this._playerController = FindObjectOfType <PlayerController>();
                this._head             = ReflectionUtil.GetPrivateField <Transform>(_playerController, "_headTransform");
                this.isDarthModeOn     = Plugin.IsDarthModeOn;
                this.isOneHanded       = Plugin.IsOneHanded;
                this.mainController    = Plugin.MainController;
                this.isAutoDetect      = Plugin.IsAutoDetect;
                this.separation        = Plugin.Separation;

                hapticFeedbackHooks = new HapticFeedbackHooks();
                hapticFeedbackHooks.StartHooking();

                var _mainGameSceneSetup = FindObjectOfType <MainGameSceneSetup>();
                _mainGameSceneSetupData = ReflectionUtil.GetPrivateField <MainGameSceneSetupData>(_mainGameSceneSetup, "_mainGameSceneSetupData");

                if (Plugin.IsDarthModeOn && _mainGameSceneSetupData.gameplayMode == GameplayMode.SoloNoArrows)
                {
                    var _beatmapDataModel = ReflectionUtil.GetPrivateField <BeatmapDataModel>(_mainGameSceneSetup, "_beatmapDataModel");
                    var beatmapData       = CreateTransformedBeatmapData(_mainGameSceneSetupData.difficultyLevel.beatmapData, _mainGameSceneSetupData.gameplayOptions, _mainGameSceneSetupData.gameplayMode);
                    if (beatmapData != null)
                    {
                        _beatmapDataModel.beatmapData = beatmapData;
                        ReflectionUtil.SetPrivateField(_mainGameSceneSetup, "_beatmapDataModel", _beatmapDataModel);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
            }
        }
Ejemplo n.º 4
0
    private static void AddEnergyPatch(object self, float value)
    {
        GameEnergyCounter instance = (GameEnergyCounter)self;

        if (!(instance.energy + value <= 1E-05f) || BailOutModePlugin.BailedOut)
        {
            addEnergyRedirection.InvokeOriginal(self, value);
            return;
        }

        Console.WriteLine("[Bailout] Lethal energy reached, bailing out!");
        BailOutModePlugin.BailedOut = true;

        try
        {
            typeof(GameEnergyCounter).GetField("_cannotFail", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(instance, true);

            var sceneSetup = UnityEngine.Object.FindObjectOfType <MainGameSceneSetup>();
            MainGameSceneSetupData setupData = typeof(MainGameSceneSetup).GetField("_mainGameSceneSetupData", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(sceneSetup) as MainGameSceneSetupData;
            setupData.gameplayOptions.noEnergy = true;

            UnityEngine.Object.FindObjectOfType <GameEnergyUIPanel>().EnableEnergyPanel(false);
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
            throw;
        }

        value = 0;
        addEnergyRedirection.InvokeOriginal(self, value);
    }
Ejemplo n.º 5
0
        private void SceneManagerOnActiveSceneChanged(Scene oldScene, Scene newScene)
        {
            string templateText;

            if (!File.Exists(_templatePath))
            {
                templateText = _defaultTemplate;
                File.WriteAllText(_templatePath, templateText);
            }
            else
            {
                templateText = File.ReadAllText(_templatePath);
            }

            templateText = ReadStatusPath(templateText);

            if (newScene.name == MenuSceneName)
            {
                //Menu scene loaded
                File.WriteAllText(_statusPath, string.Empty);
            }
            else if (newScene.name == GameSceneName)
            {
                _mainSetupData = Resources.FindObjectsOfTypeAll <MainGameSceneSetupData>().FirstOrDefault();
                if (_mainSetupData == null)
                {
                    Console.WriteLine("Song Status: Error finding the scriptable objects required to update presence.");
                    return;
                }

                //Main game scene loaded

                var diff = _mainSetupData.difficultyLevel;
                var song = diff.level;

                var gameplayModeText = GetGameplayModeName(_mainSetupData.gameplayMode);
                var keywords         = templateText.Split('{', '}');

                templateText = ReplaceKeyword("songName", song.songName, keywords, templateText);
                templateText = ReplaceKeyword("songSubName", song.songSubName, keywords, templateText);
                templateText = ReplaceKeyword("authorName", song.songAuthorName, keywords, templateText);
                templateText = ReplaceKeyword("gamemode", gameplayModeText, keywords, templateText);
                templateText = ReplaceKeyword("difficulty", diff.difficulty.Name(), keywords, templateText);
                templateText = ReplaceKeyword("isNoFail",
                                              _mainSetupData.gameplayOptions.noEnergy ? "No Fail" : string.Empty, keywords, templateText);
                templateText = ReplaceKeyword("isMirrored",
                                              _mainSetupData.gameplayOptions.mirror ? "Mirrored" : string.Empty, keywords, templateText);
                templateText = ReplaceKeyword("beatsPerMinute",
                                              song.beatsPerMinute.ToString(CultureInfo.InvariantCulture), keywords, templateText);
                templateText = ReplaceKeyword("notesCount",
                                              diff.beatmapData.notesCount.ToString(CultureInfo.InvariantCulture), keywords, templateText);
                templateText = ReplaceKeyword("obstaclesCount",
                                              diff.beatmapData.obstaclesCount.ToString(CultureInfo.InvariantCulture), keywords, templateText);
                templateText = ReplaceKeyword("environmentName", song.environmentSceneInfo.sceneName, keywords,
                                              templateText);

                File.WriteAllText(_statusPath, templateText);
            }
        }
Ejemplo n.º 6
0
        IEnumerator WaitForGameData()
        {
            Console.ForegroundColor = ConsoleColor.Gray;

            yield return(new WaitUntil(delegate() { return Resources.FindObjectsOfTypeAll <MainGameSceneSetupData>().Count() > 0; }));

            _mainGameSceneSetupData = Resources.FindObjectsOfTypeAll <MainGameSceneSetupData>().First();
        }
Ejemplo n.º 7
0
 private void MainGameSceneSetupDataOnDidFinishEvent(MainGameSceneSetupData arg1, LevelCompletionResults results)
 {
     if (!NoFail && HasTimeScaleChanged && results != null &&
         results.levelEndStateType == LevelCompletionResults.LevelEndStateType.Cleared)
     {
         arg1.gameplayOptions.noEnergy = true;
         _resetNoFail = true;
     }
 }
Ejemplo n.º 8
0
        private void StartData()
        {
            getDataJob = delegate
            {
                for (int i = 0; i < 10; i++)
                {
                    Thread.Sleep(150);
                    setupData = Resources.FindObjectsOfTypeAll <MainGameSceneSetupData>().FirstOrDefault();
                    if (setupData != null)
                    {
                        break;
                    }
                }
                if (setupData == null)
                {
                    Console.WriteLine("[SongStatus] Couldn't find SetupData object.");
                    return;
                }

                if (!File.Exists(templateDir))
                {
                    File.WriteAllText(templateDir, defaultTemplate);
                }
                string temp = File.ReadAllText(templateDir);

                var    diff = setupData.difficultyLevel;
                var    song = diff.level;
                string mode = GetGameplayModeName(setupData.gameplayMode);

                var keywords = temp.Split('{', '}');

                temp = ReplaceKeyword("songName", song.songName, keywords, temp);
                temp = ReplaceKeyword("songSubName", song.songSubName, keywords, temp);
                temp = ReplaceKeyword("authorName", song.songAuthorName, keywords, temp);
                temp = ReplaceKeyword("gamemode", mode, keywords, temp);
                temp = ReplaceKeyword("difficulty", diff.difficulty.Name(), keywords, temp);
                temp = ReplaceKeyword("isNoFail",
                                      setupData.gameplayOptions.noEnergy ? "No Fail" : string.Empty, keywords, temp);
                temp = ReplaceKeyword("isMirrored",
                                      setupData.gameplayOptions.mirror ? "Mirrored" : string.Empty, keywords, temp);
                temp = ReplaceKeyword("beatsPerMinute",
                                      song.beatsPerMinute.ToString(CultureInfo.InvariantCulture), keywords, temp);
                temp = ReplaceKeyword("notesCount",
                                      diff.beatmapData.notesCount.ToString(CultureInfo.InvariantCulture), keywords, temp);
                temp = ReplaceKeyword("obstaclesCount",
                                      diff.beatmapData.obstaclesCount.ToString(CultureInfo.InvariantCulture), keywords, temp);
                temp = ReplaceKeyword("environmentName", song.environmentSceneInfo.sceneName, keywords,
                                      temp);

                File.WriteAllText(dir, temp);
            };
            getData = new HMTask(getDataJob);
            getData.Run();
        }
Ejemplo n.º 9
0
        private void SceneManagerOnSceneLoaded(Scene newScene, LoadSceneMode mode)
        {
            if (newScene.name == MenuSceneName)
            {
                //Menu scene loaded
                Presence.details        = "In Menu";
                Presence.state          = string.Empty;
                Presence.startTimestamp = default(long);
                Presence.largeImageKey  = "default";
                Presence.largeImageText = "Beat Saber";
                Presence.smallImageKey  = "solo";
                Presence.smallImageText = "Solo Standard";
                DiscordRpc.UpdatePresence(Presence);
            }
            else if (newScene.name == GameSceneName)
            {
                _mainSetupData = Resources.FindObjectsOfTypeAll <MainGameSceneSetupData>().FirstOrDefault();
                if (_mainSetupData == null)
                {
                    Console.WriteLine("Discord Presence: Error finding the scriptable objects required to update presence.");
                    return;
                }
                //Main game scene loaded;

                var diff  = _mainSetupData.difficultyLevel;
                var level = diff.level;

                Presence.details = $"{level.songName} | {diff.difficulty.Name()}";
                Presence.state   = "";
                if (level.levelID.Contains('∎'))
                {
                    Presence.state = "Custom | ";
                }

                var gameplayModeText = GetGameplayModeName(_mainSetupData.gameplayMode);
                Presence.state += gameplayModeText;
                if (_mainSetupData.gameplayOptions.noEnergy)
                {
                    Presence.state += " [No Fail]";
                }

                if (_mainSetupData.gameplayOptions.mirror)
                {
                    Presence.state += " [Mirrored]";
                }

                Presence.largeImageKey  = "default";
                Presence.largeImageText = "Beat Saber";
                Presence.smallImageKey  = GetGameplayModeImage(_mainSetupData.gameplayMode);
                Presence.smallImageText = gameplayModeText;
                Presence.startTimestamp = (long)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
                DiscordRpc.UpdatePresence(Presence);
            }
        }
Ejemplo n.º 10
0
 private void OnSceneChanged(Scene arg0, Scene arg1)
 {
     if (env.Contains(arg1.name))
     {
         StartData();
     }
     else if (arg1.name == "Menu")
     {
         File.WriteAllText(dir, "");
         getData.Cancel();
         setupData = null;
     }
 }
Ejemplo n.º 11
0
        public static bool IsPartyMode()
        {
            if (_mainGameSceneSetupData == null)
            {
                _mainGameSceneSetupData = Resources.FindObjectsOfTypeAll <MainGameSceneSetupData>().FirstOrDefault();
            }

            if (_mainGameSceneSetupData == null)
            {
                return(false);
            }

            return(_mainGameSceneSetupData.gameplayMode == GameplayMode.PartyStandard);
        }
Ejemplo n.º 12
0
        IEnumerator WaitForGameData()
        {
            Console.ForegroundColor = ConsoleColor.Gray;

            yield return(new WaitUntil(delegate() { return Resources.FindObjectsOfTypeAll <MainGameSceneSetupData>().Count() > 0; }));

            _mainGameSceneSetupData = Resources.FindObjectsOfTypeAll <MainGameSceneSetupData>().First();

            _roomAdjust = FindObjectOfType <VRCenterAdjust>();

            if (_roomAdjust != null)
            {
                roomPositionOffset = _roomAdjust.transform.position;
                roomRotationOffset = _roomAdjust.transform.rotation;
            }
        }
Ejemplo n.º 13
0
        private void SceneManagerOnActiveSceneChanged(Scene arg0, Scene scene)
        {
            StartCoroutine(WaitRemoveScores());
            //We need to enable No Energy mode if playing custom song, so game doesn't ping leaderboards.
            var sceneSetup = FindObjectOfType <MainGameSceneSetup>();

            if (sceneSetup != null)
            {
                //We're in the main game
                _sceneSetupData = ReflectionUtil.GetPrivateField <MainGameSceneSetupData>(sceneSetup, "_mainGameSceneSetupData");
                var currentCustomSong = CustomSongs.FirstOrDefault(x => x.levelId == _sceneSetupData.levelId);
                if (currentCustomSong == null)
                {
                    return;
                }
            }
            else
            {
                //We're probably in menu
            }
        }
Ejemplo n.º 14
0
        void OnMainGameSceneDidFinish(MainGameSceneSetupData setupData, LevelCompletionResults levelCompletionResults)
        {
            if (!setupData.gameplayOptions.validForScoreUse)
            {
                return;                                              // NoFail active
            }
            if (levelCompletionResults?.levelEndStateType != LevelCompletionResults.LevelEndStateType.Cleared)
            {
                return;
            }

            var submissionBlockers = _tweaks.Where(tweak => tweak.IsPreventingScoreSubmission).ToList();

            if (submissionBlockers.Count == 0)
            {
                return;
            }

            submissionBlockers.ForEach(tweak => Log("Score submission prevented by tweak: {0}", tweak.Name));

            setupData.gameplayOptions.noEnergy = true;
            _justPreventedSubmission           = true;
        }
Ejemplo n.º 15
0
        private void SceneManagerOnActiveSceneChanged(Scene oldScene, Scene newScene)
        {
            if (newScene.buildIndex == 1)
            {
                // Loaded menu scene
                System.Net.WebClient client = new System.Net.WebClient();

                var menuSceneSetupData = Resources.FindObjectsOfTypeAll <MenuSceneSetupData>().FirstOrDefault();

                if (menuSceneSetupData.sceneState == MenuSceneSetupData.SceneState.Results)
                {
                    // Send result data
                    var twitchResults = new TwitchSongResults
                    {
                        Action    = "SongResults",
                        Results   = menuSceneSetupData.levelCompletionResults,
                        Timestamp = (long)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds
                    };

                    var p = new NameValueCollection();
                    p.Add("Action", "SongResults");
                    p.Add("Data", JsonConvert.SerializeObject(twitchResults));
                    p.Add("Timestamp", twitchResults.Timestamp.ToString());

                    client.UploadValuesAsync(new System.Uri("http://localhost:3000/gamedata"), "POST", p);
                }
                else
                {
                    var twitchData = new TwitchSceneUpdate
                    {
                        Action    = "Menu",
                        Scene     = menuSceneSetupData.sceneState,
                        Timestamp = (long)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds
                    };

                    var p = new NameValueCollection();
                    p.Add("Action", "SongResults");
                    p.Add("Data", JsonConvert.SerializeObject(twitchData));
                    p.Add("Timestamp", twitchData.Timestamp.ToString());

                    client.UploadValuesAsync(new System.Uri("http://localhost:3000/gamedata"), "POST", p);
                }
            }
            else if (newScene.buildIndex == 4)
            {
                // Loaded game playing scene
                _mainSetupData   = Resources.FindObjectsOfTypeAll <MainGameSceneSetupData>().FirstOrDefault();
                _gameStaticData  = Resources.FindObjectsOfTypeAll <GameStaticData>().FirstOrDefault();
                _scoreController = Resources.FindObjectsOfTypeAll <ScoreController>().FirstOrDefault();

                if (_mainSetupData == null || _gameStaticData == null || _scoreController == null)
                {
                    Console.WriteLine("Twitch Overlay: Cannot load game data.");
                    return;
                }

                // Attach note event handlers
                _scoreController.noteWasCutEvent    += HandleNoteWasCutEvent;
                _scoreController.noteWasMissedEvent += HandleNoteWasMissedEvent;

                var song     = _gameStaticData.GetLevelData(_mainSetupData.levelId);
                var songData = song.GetDifficultyLevel(_mainSetupData.difficulty).songLevelData.songData;

                var twitchSongUpdate = new TwitchSongUpdate
                {
                    Action         = "PlayingSong",
                    SongId         = song.levelId,
                    SongName       = song.songName,
                    SongSubName    = song.songSubName,
                    AuthorName     = song.authorName,
                    Difficulty     = LevelStaticData.GetDifficultyName(_mainSetupData.difficulty),
                    SongLength     = song.GetDifficultyLevel(_mainSetupData.difficulty).audioClip.length,
                    GameMode       = GetGameplayModeName(_mainSetupData.gameplayMode),
                    IsCustomSong   = song.levelId.Contains('∎'),
                    IsNoFail       = _mainSetupData.gameplayOptions.noEnergy,
                    IsMirror       = _mainSetupData.gameplayOptions.mirror,
                    NotesCount     = songData.notesCount,
                    ObstaclesCount = songData.obstaclesCount,
                    BPM            = songData.BeatsPerMinute,
                    SongData       = songData.SongLinesData,
                    Timestamp      = (long)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds
                };

                try
                {
                    var p = new NameValueCollection();
                    p.Add("Action", "PlayingSong");
                    p.Add("Data", JsonConvert.SerializeObject(twitchSongUpdate));
                    p.Add("Timestamp", twitchSongUpdate.Timestamp.ToString());

                    System.Net.WebClient client = new System.Net.WebClient();
                    client.UploadValuesAsync(new System.Uri("http://localhost:3000/gamedata"), "POST", p);
                } catch (Exception e)
                {
                    var p = new NameValueCollection();
                    p.Add("state", "Error");
                    p.Add("Exception", e.ToString());
                    System.Net.WebClient client = new System.Net.WebClient();
                    client.UploadValuesAsync(new System.Uri("http://localhost:3000/gamedata"), "POST", p);
                }
            }
        }
Ejemplo n.º 16
0
        private void SceneManagerOnActiveSceneChanged(Scene arg0, Scene scene)
        {
            if (scene.buildIndex == 1)
            {
                if (_resetNoFail)
                {
                    var resultsViewController =
                        Resources.FindObjectsOfTypeAll <ResultsViewController>().FirstOrDefault();
                    resultsViewController.continueButtonPressedEvent += ResultsViewControllerOnContinueButtonPressedEvent;
                }

                if (SettingsObject == null)
                {
                    var volumeSettings = Resources.FindObjectsOfTypeAll <VolumeSettingsController>().FirstOrDefault();
                    volumeSettings.gameObject.SetActive(false);
                    SettingsObject = Object.Instantiate(volumeSettings.gameObject);
                    SettingsObject.SetActive(false);
                    volumeSettings.gameObject.SetActive(true);
                    var volume = SettingsObject.GetComponent <VolumeSettingsController>();
                    ReflectionUtil.CopyComponent(volume, typeof(IncDecSettingsController),
                                                 typeof(SpeedSettingsController), SettingsObject);
                    Object.DestroyImmediate(volume);
                    SettingsObject.GetComponentInChildren <TMP_Text>().text = "SPEED";
                    Object.DontDestroyOnLoad(SettingsObject);
                }
            }
            else
            {
                if (_mainGameSceneSetupData == null)
                {
                    _mainGameSceneSetupData = Resources.FindObjectsOfTypeAll <MainGameSceneSetupData>().FirstOrDefault();
                    if (_mainGameSceneSetupData == null)
                    {
                        return;
                    }
                    _mainGameSceneSetupData.didFinishEvent += MainGameSceneSetupDataOnDidFinishEvent;
                }

                if (scene.buildIndex != 5)
                {
                    return;
                }

                if (_lastLevelId != _mainGameSceneSetupData.difficultyLevel.level.levelID &&
                    !string.IsNullOrEmpty(_lastLevelId))
                {
                    HasTimeScaleChanged = false;
                    TimeScale           = 1;
                    _lastLevelId        = _mainGameSceneSetupData.difficultyLevel.level.levelID;
                }

                if (IsEqualToOne(TimeScale))
                {
                    HasTimeScaleChanged = false;
                }

                _lastLevelId = _mainGameSceneSetupData.difficultyLevel.level.levelID;

                _audioTimeSync = Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().FirstOrDefault();
                _songAudio     = _audioTimeSync.GetPrivateField <AudioSource>("_audioSource");
                NoFail         = !_mainGameSceneSetupData.gameplayOptions.validForScoreUse;

                if (!NoFail)
                {
                    TimeScale = Mathf.Clamp(TimeScale, 1, MaxSize);
                }

                NoteHitPitchChanger.ReplacePrefab();

                var canvas = Resources.FindObjectsOfTypeAll <HorizontalLayoutGroup>()
                             .FirstOrDefault(x => x.name == "Buttons")
                             .transform.parent;
                _speedSettingsCreator = canvas.gameObject.AddComponent <SpeedSettingsCreator>();
                _speedSettingsCreator.ValueChangedEvent += SpeedSettingsCreatorOnValueChangedEvent;
                TimeScale = TimeScale;
            }
        }
Ejemplo n.º 17
0
        private void OnSceneLoaded(Scene newScene, LoadSceneMode mode)
        {
            var gameStatus = statusManager.gameStatus;

            gameStatus.scene = newScene.name;

            if (newScene.name == "Menu")
            {
                // Menu
                headInObstacle = false;

                // TODO: get the current song, mode and mods while in menu
                gameStatus.ResetMapInfo();

                gameStatus.ResetPerformance();

                statusManager.EmitStatusUpdate(ChangedProperties.AllButNoteCut, "menu");
            }
            else if (newScene.name == "StandardLevel")
            {
                // In game
                mainSetupData = Resources.FindObjectsOfTypeAll <MainGameSceneSetupData>().FirstOrDefault();
                if (mainSetupData == null)
                {
                    Console.WriteLine("[HTTP Status] Couldn't find MainGameSceneSetupData");
                    return;
                }

                gamePauseManager = Resources.FindObjectsOfTypeAll <GamePauseManager>().FirstOrDefault();
                if (gamePauseManager == null)
                {
                    Console.WriteLine("[HTTP Status] Couldn't find GamePauseManager");
                    return;
                }

                scoreController = Resources.FindObjectsOfTypeAll <ScoreController>().FirstOrDefault();
                if (scoreController == null)
                {
                    Console.WriteLine("[HTTP Status] Couldn't find ScoreController");
                    return;
                }

                gameplayManager = Resources.FindObjectsOfTypeAll <GameplayManager>().FirstOrDefault();
                if (gameplayManager == null)
                {
                    Console.WriteLine("[HTTP Status] Couldn't find GameplayManager");
                    return;
                }

                beatmapObjectCallbackController = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().FirstOrDefault();
                if (beatmapObjectCallbackController == null)
                {
                    Console.WriteLine("[HTTP Status] Couldn't find BeatmapObjectCallbackController");
                    return;
                }

                GameSongController gameSongController = (GameSongController)gameSongControllerField.GetValue(gameplayManager);
                audioTimeSyncController          = (AudioTimeSyncController)audioTimeSyncControllerField.GetValue(gameSongController);
                playerHeadAndObstacleInteraction = (PlayerHeadAndObstacleInteraction)playerHeadAndObstacleInteractionField.GetValue(scoreController);

                // Register event listeners
                // private GameEvent GamePauseManager#_gameDidPauseSignal
                AddSubscriber(gamePauseManager, "_gameDidPauseSignal", OnGamePause);
                // private GameEvent GamePauseManager#_gameDidResumeSignal
                AddSubscriber(gamePauseManager, "_gameDidResumeSignal", OnGameResume);
                // public ScoreController#noteWasCutEvent<NoteData, NoteCutInfo, int multiplier> // called after AfterCutScoreBuffer is created
                scoreController.noteWasCutEvent += OnNoteWasCut;
                // public ScoreController#noteWasMissedEvent<NoteData, int multiplier>
                scoreController.noteWasMissedEvent += OnNoteWasMissed;
                // public ScoreController#scoreDidChangeEvent<int> // score
                scoreController.scoreDidChangeEvent += OnScoreDidChange;
                // public ScoreController#comboDidChangeEvent<int> // combo
                scoreController.comboDidChangeEvent += OnComboDidChange;
                // public ScoreController#multiplierDidChangeEvent<int, float> // multiplier, progress [0..1]
                scoreController.multiplierDidChangeEvent += OnMultiplierDidChange;
                // private GameEvent GameplayManager#_levelFinishedSignal
                AddSubscriber(gameplayManager, "_levelFinishedSignal", OnLevelFinished);
                // private GameEvent GameplayManager#_levelFailedSignal
                AddSubscriber(gameplayManager, "_levelFailedSignal", OnLevelFailed);
                // public event Action<BeatmapEventData> BeatmapObjectCallbackController#beatmapEventDidTriggerEvent
                beatmapObjectCallbackController.beatmapEventDidTriggerEvent += OnBeatmapEventDidTrigger;

                var diff  = mainSetupData.difficultyLevel;
                var level = diff.level;

                gameStatus.mode = mainSetupData.gameplayMode.ToString();

                gameStatus.songName       = level.songName;
                gameStatus.songSubName    = level.songSubName;
                gameStatus.songAuthorName = level.songAuthorName;
                gameStatus.songBPM        = level.beatsPerMinute;
                gameStatus.songTimeOffset = (long)(level.songTimeOffset * 1000f);
                gameStatus.length         = (long)(level.audioClip.length * 1000f);
                gameStatus.start          = GetCurrentTime();
                gameStatus.paused         = 0;
                gameStatus.difficulty     = diff.difficulty.Name();
                gameStatus.notesCount     = diff.beatmapData.notesCount;
                gameStatus.obstaclesCount = diff.beatmapData.obstaclesCount;
                gameStatus.maxScore       = ScoreController.MaxScoreForNumberOfNotes(diff.beatmapData.notesCount);

                try {
                    // From https://support.unity3d.com/hc/en-us/articles/206486626-How-can-I-get-pixels-from-unreadable-textures-
                    var texture   = level.coverImage.texture;
                    var active    = RenderTexture.active;
                    var temporary = RenderTexture.GetTemporary(
                        texture.width,
                        texture.height,
                        0,
                        RenderTextureFormat.Default,
                        RenderTextureReadWrite.Linear
                        );

                    Graphics.Blit(texture, temporary);
                    RenderTexture.active = temporary;

                    var cover = new Texture2D(texture.width, texture.height);
                    cover.ReadPixels(new Rect(0, 0, temporary.width, temporary.height), 0, 0);
                    cover.Apply();

                    RenderTexture.active = active;
                    RenderTexture.ReleaseTemporary(temporary);

                    gameStatus.songCover = System.Convert.ToBase64String(
                        ImageConversion.EncodeToPNG(cover)
                        );
                } catch {
                    gameStatus.songCover = null;
                }

                gameStatus.ResetPerformance();

                // TODO: obstaclesOption can be All, FullHeightOnly or None. Reflect that?
                gameStatus.modObstacles = mainSetupData.gameplayOptions.obstaclesOption.ToString();
                gameStatus.modNoEnergy  = mainSetupData.gameplayOptions.noEnergy;
                gameStatus.modMirror    = mainSetupData.gameplayOptions.mirror;

                statusManager.EmitStatusUpdate(ChangedProperties.AllButNoteCut, "songStart");
            }
            else
            {
                statusManager.EmitStatusUpdate(ChangedProperties.AllButNoteCut, "scene");
            }
        }
Ejemplo n.º 18
0
        private void SceneManagerOnActiveSceneChanged(Scene arg0, Scene scene)
        {
            try
            {
                this._playerController = FindObjectOfType <PlayerController>();

                if (scene.buildIndex == 1)
                {
                    IsLeftSaberOn = true;
                    if (_beatmapObjectSpawnController != null)
                    {
                        _beatmapObjectSpawnController.noteWasCutEvent -= this.HandleNoteWasCutEvent;
                    }

                    if (_mainSettingsModel != null && stored)
                    {
                        StartCoroutine(RestoreNoEnergy());
                    }
                }

                if (scene.buildIndex == 5)
                {
                    var _mainGameSceneSetup = FindObjectOfType <MainGameSceneSetup>();
                    this._gameSongController           = FindObjectOfType <GameSongController>();
                    this._noteCutEffectSpawner         = FindObjectOfType <NoteCutEffectSpawner>();
                    this._beatmapObjectSpawnController = FindObjectOfType <BeatmapObjectSpawnController>();
                    _noteCutHapticEffect      = ReflectionUtil.GetPrivateField <NoteCutHapticEffect>(_noteCutEffectSpawner, "_noteCutHapticEffect");
                    _hapticFeedbackController = ReflectionUtil.GetPrivateField <HapticFeedbackController>(_noteCutHapticEffect, "_hapticFeedbackController");
                    _mainSettingsModel        = ReflectionUtil.GetPrivateField <MainSettingsModel>(_hapticFeedbackController, "_mainSettingsModel");
                    _mainSettingsModel.controllersRumbleEnabled = true;

                    this._mainGameSceneSetupData = ReflectionUtil.GetPrivateField <MainGameSceneSetupData>(_mainGameSceneSetup, "_mainGameSceneSetupData");

                    if (!stored)
                    {
                        storedNoEnergy = _mainGameSceneSetupData.gameplayOptions.noEnergy;
                    }
                    stored = true;

                    if (_mainGameSceneSetupData.gameplayMode == GameplayMode.SoloNoArrows)
                    {
                        BeatmapDataModel _beatmapDataModel = ReflectionUtil.GetPrivateField <BeatmapDataModel>(_mainGameSceneSetup, "_beatmapDataModel");
                        BeatmapData      beatmapData       = CreateTransformedBeatmapData(_mainGameSceneSetupData.difficultyLevel.beatmapData, _mainGameSceneSetupData.gameplayOptions, _mainGameSceneSetupData.gameplayMode);
                        if (beatmapData != null)
                        {
                            _beatmapDataModel.beatmapData = beatmapData;
                            ReflectionUtil.SetPrivateField(_mainGameSceneSetup, "_beatmapDataModel", _beatmapDataModel);
                        }

                        if (Plugin.IsOneColorModeOn)
                        {
                            _mainGameSceneSetupData.gameplayOptions.noEnergy = true;
                            _sabers = FindObjectsOfType <Saber>();

                            Saber targetSaber = (Plugin.IsColorRed) ? _playerController.leftSaber : _playerController.rightSaber;
                            Saber otherSaber  = (Plugin.IsColorRed) ? _playerController.rightSaber : _playerController.leftSaber;

                            if (targetSaber == null || otherSaber == null)
                            {
                                return;
                            }

                            var   targetCopy = Instantiate(targetSaber.gameObject);
                            Saber newSaber   = targetCopy.GetComponent <Saber>();
                            targetCopy.transform.parent         = targetSaber.transform.parent;
                            targetCopy.transform.localPosition  = Vector3.zero;
                            targetCopy.transform.localRotation  = Quaternion.identity;
                            targetSaber.transform.parent        = otherSaber.transform.parent;
                            targetSaber.transform.localPosition = Vector3.zero;
                            targetSaber.transform.localRotation = Quaternion.identity;
                            otherSaber.gameObject.SetActive(false);

                            if (Plugin.IsColorRed)
                            {
                                ReflectionUtil.SetPrivateField(_playerController, "_rightSaber", targetSaber);
                                ReflectionUtil.SetPrivateField(_playerController, "_leftSaber", newSaber);
                            }
                            else
                            {
                                ReflectionUtil.SetPrivateField(_playerController, "_leftSaber", targetSaber);
                                ReflectionUtil.SetPrivateField(_playerController, "_rightSaber", newSaber);
                            }

                            _playerController.leftSaber.gameObject.SetActive(IsLeftSaberOn);

                            if (_beatmapObjectSpawnController != null)
                            {
                                _beatmapObjectSpawnController.noteWasCutEvent += this.HandleNoteWasCutEvent;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
            }
        }
Ejemplo n.º 19
0
 private void _mainGameSceneSetupData_didFinishEvent(MainGameSceneSetupData sender, LevelCompletionResults completitionResult)
 {
     _mainGameSceneSetupData.didFinishEvent -= _mainGameSceneSetupData_didFinishEvent;
     Resources.FindObjectsOfTypeAll <MenuSceneSetupData>().First().TransitionToScene((completitionResult == null) ? 0.35f : 1.3f);
 }
Ejemplo n.º 20
0
        private void SceneManagerOnSceneLoaded(Scene scene, LoadSceneMode mode)
        {
            if (scene.name == MenuSceneName)
            {
                if (_resetNoFail)
                {
                    var resultsViewController =
                        Resources.FindObjectsOfTypeAll <ResultsViewController>().FirstOrDefault();
                    if (resultsViewController != null)
                    {
                        resultsViewController.continueButtonPressedEvent +=
                            ResultsViewControllerOnContinueButtonPressedEvent;
                    }
                }

                if (SettingsObject != null)
                {
                    return;
                }

                var volumeSettings = Resources.FindObjectsOfTypeAll <VolumeSettingsController>().FirstOrDefault();

                if (volumeSettings == null)
                {
                    return;
                }

                volumeSettings.gameObject.SetActive(false);
                SettingsObject = Object.Instantiate(volumeSettings.gameObject);
                SettingsObject.SetActive(false);
                volumeSettings.gameObject.SetActive(true);

                if (SettingsObject == null)
                {
                    return;
                }

                var volume = SettingsObject.GetComponent <VolumeSettingsController>();
                ReflectionUtil.CopyComponent(volume, typeof(IncDecSettingsController),
                                             typeof(SpeedSettingsController), SettingsObject);
                Object.DestroyImmediate(volume);

                SettingsObject.GetComponentInChildren <TMP_Text>().text = "SPEED";
                Object.DontDestroyOnLoad(SettingsObject);
            }
            else if (scene.name == GameSceneName)
            {
                CustomEffectPoolsInstaller customEffectPoolsInstaller = null;
                var effectPoolsInstaller = Resources.FindObjectsOfTypeAll <EffectPoolsInstaller>().FirstOrDefault();
                if (effectPoolsInstaller != null)
                {
                    customEffectPoolsInstaller = (CustomEffectPoolsInstaller)ReflectionUtil.CopyComponent(effectPoolsInstaller,
                                                                                                          typeof(EffectPoolsInstaller), typeof(CustomEffectPoolsInstaller), effectPoolsInstaller.gameObject);
                }

                SceneContext          sceneContext          = null;
                SceneDecoratorContext sceneDecoratorContext = null;

                foreach (var gameObject in scene.GetRootGameObjects())
                {
                    if (sceneContext == null)
                    {
                        sceneContext = gameObject.GetComponentInChildren <SceneContext>(true);
                    }
                }

                foreach (var gameObject in SceneManager.GetSceneByName(ContextSceneName).GetRootGameObjects())
                {
                    if (sceneDecoratorContext == null)
                    {
                        sceneDecoratorContext = gameObject.GetComponentInChildren <SceneDecoratorContext>(true);
                    }
                }


                if (sceneContext != null && sceneDecoratorContext != null)
                {
                    var prop           = typeof(Context).GetField("_installers", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
                    var installersList = (List <MonoInstaller>)prop.GetValue(sceneDecoratorContext);
                    installersList.Remove(effectPoolsInstaller);
                    Object.DestroyImmediate(effectPoolsInstaller);
                    installersList.Add(customEffectPoolsInstaller);
                }

                if (_mainGameSceneSetupData == null)
                {
                    _mainGameSceneSetupData = Resources.FindObjectsOfTypeAll <MainGameSceneSetupData>().FirstOrDefault();
                    if (_mainGameSceneSetupData == null)
                    {
                        return;
                    }
                    _mainGameSceneSetupData.didFinishEvent += MainGameSceneSetupDataOnDidFinishEvent;
                }

                if (_lastLevelId != _mainGameSceneSetupData.difficultyLevel.level.levelID &&
                    !string.IsNullOrEmpty(_lastLevelId))
                {
                    PlayingNewSong      = true;
                    HasTimeScaleChanged = false;
                    TimeScale           = 1;
                    _lastLevelId        = _mainGameSceneSetupData.difficultyLevel.level.levelID;
                }
                else
                {
                    PlayingNewSong = false;
                }

                if (IsEqualToOne(TimeScale))
                {
                    HasTimeScaleChanged = false;
                }

                _lastLevelId = _mainGameSceneSetupData.difficultyLevel.level.levelID;

                AudioTimeSync = Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().FirstOrDefault();
                _songAudio    = AudioTimeSync.GetPrivateField <AudioSource>("_audioSource");
                NoFail        = !_mainGameSceneSetupData.gameplayOptions.validForScoreUse;

                if (!NoFail)
                {
                    TimeScale = Mathf.Clamp(TimeScale, 1, MaxSize);
                }

                var canvas = Resources.FindObjectsOfTypeAll <HorizontalLayoutGroup>()
                             .FirstOrDefault(x => x.name == "Buttons")
                             ?.transform.parent;

                if (canvas == null)
                {
                    return;
                }

                _uiElementsCreator = canvas.gameObject.AddComponent <UIElementsCreator>();
                _uiElementsCreator.ValueChangedEvent += UIElementsCreatorOnValueChangedEvent;
                _uiElementsCreator.Init();
                TimeScale = TimeScale;
            }
        }
        public void Present(VRUIViewController parentViewController, bool fromDebug)
        {
            _ui     = TwitchIntegrationUi.Instance;
            _logger = LogManager.GetCurrentClassLogger();

            try
            {
                _menuSceneSetupData     = Resources.FindObjectsOfTypeAll <MenuSceneSetupData>().First();
                _mainGameSceneSetupData = Resources.FindObjectsOfTypeAll <MainGameSceneSetupData>().First();
                _resultsFlowCoordinator = Resources.FindObjectsOfTypeAll <ResultsFlowCoordinator>().First();

                if (_levelRequestNavigationController == null)
                {
                    _levelRequestNavigationController =
                        _ui.CreateViewController <LevelRequestNavigationController>("LevelRequestNavController");
                }

                if (_requestInfoViewController == null)
                {
                    _requestInfoViewController = _ui.CreateViewController <RequestInfoViewController>("RequestInfo");
                    _requestInfoViewController.rectTransform.anchorMin = new Vector2(0.3f, 0f);
                    _requestInfoViewController.rectTransform.anchorMax = new Vector2(0.7f, 1f);
                }

                _levelDifficultyViewController =
                    Resources.FindObjectsOfTypeAll <StandardLevelDifficultyViewController>().First();
                _levelDetailViewController =
                    Resources.FindObjectsOfTypeAll <StandardLevelDetailViewController>().First();
            }
            catch (Exception e)
            {
                _logger.Error("Unable to load UI components: " + e);
                return;
            }

            if (!_initialized)
            {
                DidFinishEvent += Finish;
                _levelRequestNavigationController.DidFinishEvent        += HandleLevelRequestNavigationControllerDidfinish;
                _levelDifficultyViewController.didSelectDifficultyEvent +=
                    HandleDifficultyViewControllerDidSelectDifficulty;
                _levelDetailViewController.didPressPlayButtonEvent += HandleDetailViewControllerDidPressPlayButton;



                _requestInfoViewController.DownloadButtonpressed += HandleDidPressDownloadButton;
                _requestInfoViewController.SkipButtonPressed     += HandleDidPressSkipButton;

                _initialized = true;
            }

            //_levelRequestNavigationController.Init();
            parentViewController.PresentModalViewController(_levelRequestNavigationController, null,
                                                            StaticData.DidStartFromQueue);
            _requestInfoViewController.Init("Default Song Name", "Default User");

            _levelRequestNavigationController.PushViewController(_requestInfoViewController, true);

            if (!fromDebug)
            {
                return;             //Loading song preview arrests control from the results controller, causing it to display improperly.
            }
            CheckQueueAndUpdate();
        }
 private void HandleMainGameSceneDidFinish(MainGameSceneSetupData mainGameSceneSetupData, LevelCompletionResults levelCompletionResults)
 {
     StaticData.LastLevelCompletionResults  = levelCompletionResults;
     mainGameSceneSetupData.didFinishEvent -= HandleMainGameSceneDidFinish;
     _menuSceneSetupData.TransitionToScene(0.7f);
 }
Ejemplo n.º 23
0
        public IEnumerator Start()
        {
            // The goal now is to find the clip this scene will be playing.
            // For this, we find the single root gameObject (which is the gameObject
            // to which we are attached),
            // then we get its GameSongController to find the audio clip,
            // and its FlyingTextSpawner to display the lyrics.


            textSpawner    = FindObjectOfType <FlyingTextSpawner>();
            songController = FindObjectOfType <GameSongController>();

            if (textSpawner == null || songController == null)
            {
                yield break;
            }

            MainGameSceneSetup sceneSetup = FindObjectOfType <MainGameSceneSetup>();

            if (sceneSetup == null)
            {
                yield break;
            }

            MainGameSceneSetupData sceneSetupData = SetupDataField.GetValue(sceneSetup) as MainGameSceneSetupData;

            if (sceneSetupData == null)
            {
                yield break;
            }

            List <Subtitle> subtitles = new List <Subtitle>();

            if (LyricsFetcher.GetLocalLyrics(sceneSetupData.difficultyLevel.level.levelID, subtitles))
            {
                // Lyrics found locally, continue with them.
                SpawnText("Lyrics found locally", 3f);
            }
            else
            {
                // Clip found, now select the first song that has the same clip (using reference comparison).
                IStandardLevel level = sceneSetupData.difficultyLevel.level;

                // We found the matching song, we can get started.
                Debug.Log($"Corresponding song data found: {level.songName} by {level.songAuthorName}.");

                // When this coroutine ends, it will call the given callback with a list
                // of all the subtitles we found, and allow us to react.
                // If no subs are found, the callback is not called.
                yield return(StartCoroutine(LyricsFetcher.GetOnlineLyrics(level.songName, level.songAuthorName, subtitles)));

                if (subtitles.Count == 0)
                {
                    yield break;
                }

                SpawnText("Lyrics found online", 3f);
            }

            StartCoroutine(DisplayLyrics(subtitles));
        }
Ejemplo n.º 24
0
        private void SceneManagerOnActiveSceneChanged(Scene arg0, Scene arg1)
        {
            if (overlayEnabled)
            {
                if (arg1.name == "Menu" && InSong)
                {
                    Console.WriteLine("[StreamInfo] Exited song scene.");

                    InSong = false;
                    StartTask.Cancel();
                    ats = null;

                    Console.WriteLine("[StreamInfo] Ready for next song.");
                }
                else if (env.Contains(arg1.name))
                {
                    StartJob = delegate
                    {
                        Console.WriteLine("[StreamInfo] Entered song scene. Initializing...");
                        InSong         = true;
                        EnergyReached0 = false;
                        int runID = 1 + songCount++;

                        Console.WriteLine("[StreamInfo] Finding controllers and data...");

                        GameEnergyCounter      energy    = null;
                        ScoreController        score     = null;
                        MainGameSceneSetupData setupData = null;

                        while (ats == null || energy == null || score == null || setupData == null)
                        {
                            Thread.Sleep(150);
                            ats       = UnityEngine.Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().FirstOrDefault();
                            energy    = UnityEngine.Resources.FindObjectsOfTypeAll <GameEnergyCounter>().FirstOrDefault();
                            score     = UnityEngine.Resources.FindObjectsOfTypeAll <ScoreController>().FirstOrDefault();
                            setupData = UnityEngine.Resources.FindObjectsOfTypeAll <MainGameSceneSetupData>().FirstOrDefault();
                        }
                        Console.WriteLine("[StreamInfo] Found controllers and data.");

                        bool noFail = false;

                        if (setupData != null)
                        {
                            Console.WriteLine("[StreamInfo] Getting song name data...");
                            var level = setupData.difficultyLevel.level;

                            _songName   = level.songName;
                            _songSub    = level.songSubName;
                            _songAuthor = level.songAuthorName;

                            string songname = "\"" + _songName + "\" by " + _songSub + " - " + _songAuthor;
                            File.WriteAllText(Path.Combine(dir, "SongName.txt"), songname + "               ");

                            noFail = setupData.gameplayOptions.noEnergy;
                        }
                        Console.WriteLine("[StreamInfo] Hooking Events...");
                        if (score != null)
                        {
                            score.comboDidChangeEvent      += OnComboChange;
                            score.multiplierDidChangeEvent += OnMultiplierChange;
                            score.noteWasMissedEvent       += OnNoteMiss;
                            score.noteWasCutEvent          += OnNoteCut;
                            score.scoreDidChangeEvent      += OnScoreChange;
                        }
                        if (energy != null)
                        {
                            energy.gameEnergyDidChangeEvent += OnEnergyChange;
                            if (!BailOutInstalled)
                            {
                                energy.gameEnergyDidReach0Event += OnEnergyFail;
                            }
                        }
                        info.SetDefault();
                        if (noFail)
                        {
                            EnergyReached0 = true;
                            info.energy    = -3;
                        }
                        Console.WriteLine("[StreamInfo] Starting update loop...");
                        while (InSong && overlayEnabled && runID == songCount)
                        {
                            if (ats != null)
                            {
                                string time      = Math.Floor(ats.songTime / 60).ToString("N0") + ":" + Math.Floor(ats.songTime % 60).ToString("00");
                                string totaltime = Math.Floor(ats.songLength / 60).ToString("N0") + ":" + Math.Floor(ats.songLength % 60).ToString("00");
                                string percent   = ((ats.songTime / ats.songLength) * 100).ToString("N0");

                                overlay.UpdateText(info.GetVal("multiplier"),
                                                   info.GetVal("score"),
                                                   ScoreController.MaxScoreForNumberOfNotes(info.notes_total),
                                                   time + " / " + totaltime + " (" + percent + "%)",
                                                   info.GetVal("combo"),
                                                   info.GetVal("notes_hit") + "/" + info.GetVal("notes_total"),
                                                   info.GetVal("energy"));
                            }
                            Thread.Sleep(overlayRefreshRate);
                        }
                        Console.WriteLine("[SongInfo] Thread completed: " + runID);
                    };
                    StartTask = new HMTask(StartJob);
                    StartTask.Run();
                }
            }
        }