public IEnumerator DoOnLevelStart() { yield return(new WaitUntil(() => standardLevelGameplayManager.GetField <StandardLevelGameplayManager.GameState>("_gameState") == StandardLevelGameplayManager.GameState.Playing)); yield return(new WaitUntil(() => Resources.FindObjectsOfTypeAll <GameEnergyCounter>().Any())); gameSongController = standardLevelGameplayManager.GetField <GameSongController>("_gameSongController"); gameEnergyCounter = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().First(); //Prevent the gameEnergyCounter from invoking death by obstacle _oldObstacleEnergyDrainPerSecond = gameEnergyCounter.GetField <float>("_obstacleEnergyDrainPerSecond"); gameEnergyCounter.SetField("_obstacleEnergyDrainPerSecond", 0f); //Unhook the functions in the energy counter that watch note events, so we can peek inside the process beatmapObjectManager = gameEnergyCounter.GetField <BeatmapObjectManager>("_beatmapObjectManager"); beatmapObjectManager.noteWasMissedEvent -= gameEnergyCounter.HandleNoteWasMissedEvent; beatmapObjectManager.noteWasMissedEvent += beatmapObjectManager_noteWasMissedEvent; beatmapObjectManager.noteWasCutEvent -= gameEnergyCounter.HandleNoteWasCutEvent; beatmapObjectManager.noteWasCutEvent += beatmapObjectManager_noteWasCutEvent; //Unhook the level end event so we can reset everything before the level ends gameSongController.songDidFinishEvent -= standardLevelGameplayManager.HandleSongDidFinish; gameSongController.songDidFinishEvent += gameSongController_songDidFinishEvent; }
public virtual void Update() { if (!_wouldHaveFailed) { if (gameEnergyCounter != null && gameEnergyCounter.GetField <PlayerHeadAndObstacleInteraction>("_playerHeadAndObstacleInteraction").intersectingObstacles.Count > 0) { AddEnergy(Time.deltaTime * -_oldObstacleEnergyDrainPerSecond); } if (gameEnergyCounter != null && gameEnergyCounter.GetField <SaberClashChecker>("_saberClashChecker") && gameEnergyCounter.failOnSaberClash) { AddEnergy(-gameEnergyCounter.energy); } } }
public virtual void LateUpdate() { if (!_wouldHaveFailed) { if (gameEnergyCounter != null && gameEnergyCounter.GetField <PlayerHeadAndObstacleInteraction>("_playerHeadAndObstacleInteraction").intersectingObstacles.Count > 0) { AddEnergy(Time.deltaTime * -_oldObstacleEnergyDrainPerSecond); } if (gameEnergyCounter != null && gameEnergyCounter.GetField <SaberClashChecker>("_saberClashChecker").AreSabersClashing(out var _) && gameEnergyCounter.failOnSaberClash) { AddEnergy(-gameEnergyCounter.energy); } if (!Mathf.Approximately(_nextFrameEnergyChange, 0f)) { AddEnergy(_nextFrameEnergyChange); _nextFrameEnergyChange = 0f; } } }