public void GetControllers() { scoreController = Resources.FindObjectsOfTypeAll <ScoreController>().FirstOrDefault(); energyCounter = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().FirstOrDefault(); rankCounter = Resources.FindObjectsOfTypeAll <RelativeScoreAndImmediateRankCounter>().FirstOrDefault(); endActions = Resources.FindObjectsOfTypeAll <StandardLevelGameplayManager>().FirstOrDefault(); if (endActions == null) { endActions = Resources.FindObjectsOfTypeAll <MissionLevelGameplayManager>().FirstOrDefault(); } if (scoreController != null && energyCounter != null && rankCounter != null && endActions != null) { scoreController.noteWasCutEvent += NoteHit; scoreController.noteWasMissedEvent += NoteMiss; endActions.levelFinishedEvent += LevelFinished; endActions.levelFailedEvent += LevelFinished; Logger.log.Debug("PerformanceMeter reloaded successfully"); } else { Logger.log.Error("Could not reload PerformanceMeter"); scoreController = null; energyCounter = null; rankCounter = null; endActions = null; } }
void ReplaceControllers() { if (!Config.Instance.SpectatorMode || Client.Instance.inRadioMode) { return; } audioTimeSync = Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().FirstOrDefault(); _leftSaber = Resources.FindObjectsOfTypeAll <Saber>().First(x => x.saberType == Saber.SaberType.SaberB); _leftController = _leftSaber.GetPrivateField <VRController>("_vrController").gameObject.AddComponent <OnlineVRController>(); _leftSaber.SetPrivateField("_vrController", _leftController); _rightSaber = Resources.FindObjectsOfTypeAll <Saber>().First(x => x.saberType == Saber.SaberType.SaberA); _rightController = _rightSaber.GetPrivateField <VRController>("_vrController").gameObject.AddComponent <OnlineVRController>(); _rightSaber.SetPrivateField("_vrController", _rightController); Plugin.log.Info("Controllers replaced!"); _scoreController = FindObjectOfType <ScoreController>(); #if DEBUG _scoreController.noteWasMissedEvent += _scoreController_noteWasMissedEvent; _scoreController.noteWasCutEvent += _scoreController_noteWasCutEvent; #endif Plugin.log.Info("Score controller found!"); _energyCounter = FindObjectOfType <GameEnergyCounter>(); Plugin.log.Info("Energy counter found!"); }
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); }
IEnumerator WaitForControllers() { Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine("Waiting for game controllers..."); yield return(new WaitUntil(delegate() { return FindObjectOfType <ScoreController>() != null; })); Console.WriteLine("Controllers found!"); _gameManager = Resources.FindObjectsOfTypeAll <GameplayManager>().First(); if (_gameManager != null) { try { if (ReflectionUtil.GetPrivateField <IPauseTrigger>(_gameManager, "_pauseTrigger") != null) { ReflectionUtil.GetPrivateField <IPauseTrigger>(_gameManager, "_pauseTrigger").SetCallback(delegate() { }); } if (ReflectionUtil.GetPrivateField <VRPlatformHelper>(_gameManager, "_vrPlatformHelper") != null) { ReflectionUtil.GetPrivateField <VRPlatformHelper>(_gameManager, "_vrPlatformHelper").inputFocusWasCapturedEvent -= _gameManager.HandleInputFocusWasCaptured; } } catch (Exception e) { Console.WriteLine(e.ToString()); } } Console.WriteLine("Disabled pause button"); _scoreController = FindObjectOfType <ScoreController>(); if (_scoreController != null) { _scoreController.scoreDidChangeEvent += ScoreChanged; _scoreController.noteWasCutEvent += noteWasCutEvent; _scoreController.comboDidChangeEvent += comboDidChangeEvent; } Console.WriteLine("Found score controller"); _energyController = FindObjectOfType <GameEnergyCounter>(); if (_energyController != null) { _energyController.gameEnergyDidChangeEvent += EnergyDidChangeEvent; } Console.WriteLine("Found energy controller"); _roomAdjust = FindObjectOfType <VRCenterAdjust>(); if (_roomAdjust != null) { roomPositionOffset = _roomAdjust.transform.position; roomRotationOffset = _roomAdjust.transform.rotation; } }
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; }
internal void Initialize(GameEnergyCounter gameEnergyCounter, EventManager eventManager, GameObject rootEnergyBarGO) { _gameEnergyCounter = gameEnergyCounter; _eventManager = eventManager; _rootEnergyBarGO = rootEnergyBarGO; _eventManager.OnInit.Invoke(); _eventManager.DeserializeEvents(); SubscribeToEvents(); if (_gameEnergyCounter.energyType == GameplayModifiers.EnergyType.Bar) { _previousEnergy = _gameEnergyCounter.energy; } else { _previousEnergy = 1.1f; } OnEnergyChangedHandler(_gameEnergyCounter.energy); if (_gameEnergyCounter.energyType == GameplayModifiers.EnergyType.Bar && _eventManager.OnBatteryLivesDecreased.Length > 0) { int eventIndex = Mathf.CeilToInt(_gameEnergyCounter.energy * _eventManager.OnBatteryLivesDecreased.Length); for (int i = eventIndex; i < _eventManager.OnBatteryLivesDecreased.Length; i++) { _eventManager.OnBatteryLivesDecreased[i]?.Invoke(); } } }
private void Start() { _eventManager = gameObject.GetComponent <EventManager>(); if (_eventManager == null) { _eventManager = gameObject.AddComponent <EventManager>(); } _eventManager.OnLevelStart.Invoke(); _scoreController = Resources.FindObjectsOfTypeAll <ScoreController>().FirstOrDefault(); if (_scoreController == null) { return; } _saberCollisionManager = Resources.FindObjectsOfTypeAll <ObstacleSaberSparkleEffectManager>().FirstOrDefault(); _gameEnergyCounter = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().FirstOrDefault(); _beatmapObjectCallbackController = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().FirstOrDefault(); _scoreController.noteWasCutEvent += SliceCallBack; _scoreController.noteWasMissedEvent += NoteMissCallBack; _scoreController.multiplierDidChangeEvent += MultiplierCallBack; _scoreController.comboDidChangeEvent += ComboChangeEvent; _saberCollisionManager.sparkleEffectDidStartEvent += SaberStartCollide; _saberCollisionManager.sparkleEffectDidEndEvent += SaberEndCollide; _gameEnergyCounter.gameEnergyDidReach0Event += FailLevelCallBack; _beatmapObjectCallbackController.beatmapEventDidTriggerEvent += OnBeatmapEventDidTriggerEvent; }
public static bool Prefix(ref GameEnergyCounter __instance, float energyChange) { if (!(GMPUI.EndlessMode && Config.EndlessContinueOnFail)) { return(true); } GameObject endlessObj = GameObject.Find("GMP Endless Behavior"); if (endlessObj == null) { return(true); } if (energyChange > 0) { return(true); } EndlessBehavior endlessBehavior = endlessObj.GetComponent <EndlessBehavior>(); if (endlessBehavior.nextSong != null) { bool willFail = (__instance.energy + energyChange) <= 0; if (willFail && BS_Utils.Plugin.LevelData.IsSet && !BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.gameplayModifiers.noFailOn0Energy) { __instance.ProcessEnergyChange(0.5f); endlessBehavior.SongEnd(); return(false); } } return(true); }
private void Constractor(GameEnergyCounter gameEnergyCounter) { this.gameEnergyCounter = gameEnergyCounter; this.coreGameHUDController = Resources.FindObjectsOfTypeAll <CoreGameHUDController>().FirstOrDefault(); this._energyPanelGO = this.coreGameHUDController.GetField <GameObject, CoreGameHUDController>("_energyPanelGO"); foreach (var item in _energyPanelGO.GetComponentsInChildren <Image>().OrderBy(x => x.name)) { Plugin.Log.Debug($"{item}"); if (item == null) { continue; } if (item.name == "EnergyBar") { this.barImage = item; } else if (item.name == "EnergyIconFull") { this.fullIcon = item; this.DefaltColor = item.color; } else if (item.name == "EnergyIconEmpty") { item.color = Color.red; } } //var difficultyBeatmap = gameplayCoreSceneSetupData.difficultyBeatmap; //if (0 < difficultyBeatmap.beatmapData.spawnRotationEventsCount) { // this.barImage.rectTransform.sizeDelta = new Vector2(0f, 0.7f); //} this.fullIconMaterial = Instantiate(this.fullIcon.material); this.fullIcon.material = this.fullIconMaterial; }
static bool Prefix(GameEnergyCounter __instance, float value) { try { if (Config.Instance.SpectatorMode && SpectatingController.Instance != null && SpectatingController.active && Client.Instance != null && Client.Instance.connected && SpectatingController.Instance.spectatedPlayer != null && SpectatingController.Instance.spectatedPlayer.playerInfo != null) { if (__instance.energy + value <= 1E-05f && SpectatingController.Instance.spectatedPlayer.playerInfo.updateInfo.playerEnergy > 1E-04f) { return(false); } else { return(true); } } else { return(true); } } catch (Exception e) { Plugin.log.Error("Exception in Harmony patch GameEnergyCounter.AddEnergy: " + e); return(true); } }
///////////////////////////////////////////////////// private IEnumerator GetEnergyCounter() { bool loaded = false; while (!loaded) { _energyCounter = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().FirstOrDefault(); if (_energyCounter == null) { yield return(new WaitForSeconds(0.1f)); } else { loaded = true; } } if (_energyCounter != null) { if (_fail) { _energyCounter.gameEnergyDidReach0Event += _energyCounter_gameEnergyDidReach0Event; } } }
private void Start() { _leftEventManager = _leftSaber.GetComponent <EventManager>(); if (_leftEventManager == null) { _leftEventManager = _leftSaber.AddComponent <EventManager>(); } _rightEventManager = _rightSaber.GetComponent <EventManager>(); if (_rightEventManager == null) { _rightEventManager = _rightSaber.AddComponent <EventManager>(); } _leftEventManager.OnLevelStart.Invoke(); _rightEventManager.OnLevelStart.Invoke(); try { _scoreController = Resources.FindObjectsOfTypeAll <ScoreController>().FirstOrDefault(); if (_scoreController == null) { Console.WriteLine("SCORE CONTROLLER NULL"); } _saberCollisionManager = Resources.FindObjectsOfTypeAll <ObstacleSaberSparkleEffectManager>().FirstOrDefault(); if (_saberCollisionManager == null) { Console.WriteLine("COLLISION MANAGER NULL"); } _gameEnergyCounter = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().FirstOrDefault(); if (_gameEnergyCounter == null) { Console.WriteLine("energery counter null"); } _beatmapCallback = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().FirstOrDefault(); if (_beatmapCallback == null) { Console.WriteLine("BEATMAP CALLBACK NULL"); } _scoreController.noteWasCutEvent += SliceCallBack; _scoreController.noteWasMissedEvent += NoteMissCallBack; _scoreController.multiplierDidChangeEvent += MultiplierCallBack; _scoreController.comboDidChangeEvent += ComboChangeEvent; _saberCollisionManager.sparkleEffectDidStartEvent += SaberStartCollide; _saberCollisionManager.sparkleEffectDidEndEvent += SaberEndCollide; _gameEnergyCounter.gameEnergyDidReach0Event += FailLevelCallBack; _beatmapCallback.beatmapEventDidTriggerEvent += LightEventCallBack; } catch (Exception e) { Console.WriteLine(e); Console.WriteLine(e.Message); throw; } }
static bool Prefix(ref GameEnergyCounter __instance, float value) { if (__instance.energy + value <= 1E-05f) { return(false); } return(true); }
public void GetControllers() { DismissGraph(null); levelOk = false; averageHitValue = 0.0f; averageHitValueSize = 0; secondaryAverageHitValue = 0.0f; secondaryAverageHitValueSize = 0; energyList.Clear(); secondaryEnergyList.Clear(); misses.Clear(); if (PluginConfig.Instance.mode == PluginConfig.MeasurementMode.Energy) { energyList.Add(new Pair <float, float>(0.0f, 0.5f)); } if (PluginConfig.Instance.secondaryMode == PluginConfig.MeasurementMode.Energy) { secondaryEnergyList.Add(new Pair <float, float>(0.0f, 0.5f)); } scoreController = Resources.FindObjectsOfTypeAll <ScoreController>().LastOrDefault(); ComboUIController comboUIController = Resources.FindObjectsOfTypeAll <ComboUIController>().LastOrDefault(); energyCounter = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().LastOrDefault(); rankCounter = Resources.FindObjectsOfTypeAll <RelativeScoreAndImmediateRankCounter>().LastOrDefault(); audioController = Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().LastOrDefault(); endActions = Resources.FindObjectsOfTypeAll <StandardLevelGameplayManager>().LastOrDefault(); if (endActions == null) { endActions = Resources.FindObjectsOfTypeAll <MissionLevelGameplayManager>().LastOrDefault(); } if (endActions != null && scoreController != null && energyCounter != null && rankCounter != null && audioController != null && comboUIController != null) { objectManager = (BeatmapObjectManager)_beatmapObjectManager.GetValue(scoreController); comboController = (ComboController)_comboController.GetValue(comboUIController); objectManager.noteWasCutEvent += NoteHit; objectManager.noteWasMissedEvent += NoteMiss; comboController.comboBreakingEventHappenedEvent += ComboBreak; endActions.levelFinishedEvent += LevelFinished; endActions.levelFailedEvent += LevelFinished; Logger.log.Debug("PerformanceMeter reloaded successfully"); } else { Logger.log.Error("Could not reload PerformanceMeter. This may occur when playing online - if so, disregard this message."); scoreController = null; objectManager = null; comboController = null; energyCounter = null; rankCounter = null; audioController = null; endActions = null; } }
public void OnActiveSceneChanged(Scene arg0, Scene scene) { _energyCounter = UnityEngine.Object.FindObjectOfType <GameEnergyCounter>(); _songController = UnityEngine.Object.FindObjectOfType <GameSongController>(); _gameplayManager = UnityEngine.Object.FindObjectOfType <GameplayManager>(); if (_energyCounter != null) { _oldEnergy = _energyCounter.energy; } }
void Awake() { _energyCounter = null; _BMSpawnController = null; bFailed = false; LoadSoundEffects(); StartCoroutine(GetEnergyCounter()); StartCoroutine(GetBeatmapObjectSpawnController()); StartCoroutine(GetMainAudioEffects()); }
private void Init(CountersData data) { //Because CountersController.ReadyToInit relies on finding other objects via Resources.FindObjectsOfTypeAll<>() //before invoking, it is safe to assume that the objects we find do indeed exist. energy = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().First(); fails = data.PlayerData.currentLocalPlayer.playerAllOverallStatsData.allOverallStatsData.failedLevelsCount; if (settings.ShowRestartsInstead) { bool SameLevel = false; if (CurrentLevel != null) { SameLevel = data.GCSSD.difficultyBeatmap.level.songName == CurrentLevel.songName && //I mean, data.GCSSD.difficultyBeatmap.level.songSubName == CurrentLevel.songSubName && //Probably not the best way to compare levels, data.GCSSD.difficultyBeatmap.level.songAuthorName == CurrentLevel.songAuthorName && //But that means I have more lines to spend data.GCSSD.difficultyBeatmap.beatmapData.notesCount == BeatmapDiff.beatmapData.notesCount && //Making snarky comments like these data.GCSSD.difficultyBeatmap.beatmapData.obstaclesCount == BeatmapDiff.beatmapData.obstaclesCount && //For you to find data.GCSSD.difficultyBeatmap.beatmapData.bombsCount == BeatmapDiff.beatmapData.bombsCount; //And to @ me on Discord. } if (SameLevel) { Restarts++; } else { CurrentLevel = data.GCSSD.difficultyBeatmap.level; BeatmapDiff = data.GCSSD.difficultyBeatmap; Restarts = 0; } } Vector3 position = CountersController.DeterminePosition(gameObject, settings.Position, settings.Distance); TextHelper.CreateText(out failText, position - new Vector3(0, 0.4f, 0)); failText.text = settings.ShowRestartsInstead ? Restarts.ToString() : fails.ToString(); failText.fontSize = 4; failText.color = Color.white; failText.alignment = TextAlignmentOptions.Center; GameObject labelGO = new GameObject("Counters+ | Fail Label"); labelGO.transform.parent = transform; TextHelper.CreateText(out TMP_Text label, position); label.text = settings.ShowRestartsInstead ? "Restarts" : "Fails"; label.fontSize = 3; label.color = Color.white; label.alignment = TextAlignmentOptions.Center; if (!settings.ShowRestartsInstead) { energy.gameEnergyDidReach0Event += SlowlyAnnoyThePlayerBecauseTheyFailed; } }
public override bool Activate(ref LightSwitchEventEffect light, ref BeatmapEventData data, ref BeatmapEventType eventType) { GameEnergyCounter counter = GameObject.FindObjectOfType <GameEnergyCounter>(); if (counter != null) { ChromaLogger.Log("Changing health by " + HealthChangeAmount); counter.AddEnergy(HealthChangeAmount); return(true); } return(false); }
IEnumerator InitControllers() { yield return(new WaitUntil(delegate() { return FindObjectOfType <ScoreController>() != null && FindObjectOfType <GameEnergyCounter>() != null; })); StandardLevelGameplayManager _gameManager = Resources.FindObjectsOfTypeAll <StandardLevelGameplayManager>().First(); _gameplayModifiersSO = Resources.FindObjectsOfTypeAll <GameplayModifiersModelSO>().FirstOrDefault(); if (_gameManager != null) { try { if (ReflectionUtil.GetPrivateField <IPauseTrigger>(_gameManager, "_pauseTrigger") != null) { ReflectionUtil.GetPrivateField <IPauseTrigger>(_gameManager, "_pauseTrigger").pauseTriggeredEvent -= _gameManager.HandlePauseTriggered; ReflectionUtil.GetPrivateField <IPauseTrigger>(_gameManager, "_pauseTrigger").pauseTriggeredEvent += ShowPauseMenu; } if (ReflectionUtil.GetPrivateField <VRPlatformHelper>(_gameManager, "_vrPlatformHelper") != null) { ReflectionUtil.GetPrivateField <VRPlatformHelper>(_gameManager, "_vrPlatformHelper").inputFocusWasCapturedEvent -= _gameManager.HandleInputFocusWasCaptured; ReflectionUtil.GetPrivateField <VRPlatformHelper>(_gameManager, "_vrPlatformHelper").inputFocusWasCapturedEvent += ShowPauseMenu; } } catch (Exception e) { Data.Logger.Error(e.ToString()); } } _scoreController = FindObjectOfType <ScoreController>(); _energyController = FindObjectOfType <GameEnergyCounter>(); if (_scoreController != null) { _scoreController.scoreDidChangeEvent += ScoreChanged; _scoreController.noteWasCutEvent += NoteWasCutEvent; _scoreController.comboDidChangeEvent += ComboDidChangeEvent; _scoreController.noteWasMissedEvent += NoteWasMissedEvent; } if (_energyController != null) { _energyController.gameEnergyDidChangeEvent += EnergyDidChangeEvent; } _pauseMenuManager = FindObjectsOfType <PauseMenuManager>().First(); if (_pauseMenuManager != null) { _pauseMenuManager.GetPrivateField <Button>("_restartButton").interactable = false; } }
public override bool Activate(ref MonoBehaviour light, ref BeatmapEventData data, ref BeatmapEventType eventType) { GameEnergyCounter counter = GameObject.FindObjectOfType <GameEnergyCounter>(); if (counter != null) { //ChromaLogger.Log("Changing health by " + HealthChangeAmount); counter.SetField("energy", counter.energy + HealthChangeAmount); return(true); } return(false); }
public System.Collections.IEnumerator DelayedSetup() { yield return(new WaitForSeconds(0.1f)); try { if (_spawnController == null) { _spawnController = Resources.FindObjectsOfTypeAll <BeatmapObjectSpawnController>().LastOrDefault(); } Console.WriteLine("Atemmpting Practice Plugin UI"); var canvas = GameObject.Find("PauseMenu").transform.Find("Wrapper").transform.Find("MenuWrapper").transform.Find("Canvas"); if (canvas == null) { Console.WriteLine("Canvas Null"); } GameObject uiObj = new GameObject("PracticePlugin Seeker UI", typeof(RectTransform)); (uiObj.transform as RectTransform).anchorMin = new Vector2(0, 0); (uiObj.transform as RectTransform).anchorMax = new Vector2(1, 1); (uiObj.transform as RectTransform).sizeDelta = new Vector2(0, 0); _uiElementsCreator = uiObj.AddComponent <UIElementsCreator>(); var practiceUI = new GameObject("PracticePlugin Adjustment UI").AddComponent <PracticeUI>(); UIElementsCreator.practiceUI = practiceUI; BSMLParser.instance.Parse(BeatSaberMarkupLanguage.Utilities.GetResourceContent(Assembly.GetExecutingAssembly(), "PracticePlugin.PracticeUI.bsml"), canvas.gameObject, practiceUI); _uiElementsCreator.Init(); uiObj.transform.SetParent(canvas, false); uiObj.transform.localScale = new Vector3(1, 1, 1); uiObj.transform.localPosition = new Vector3(0f, -3f, 0f); new GameObject("Practice Plugin Behavior").AddComponent <Behavior>(); if (startWithFullEnergy) { GameEnergyCounter energyCounter = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().FirstOrDefault(); if (energyCounter != null) { energyCounter.ProcessEnergyChange(1 - energyCounter.energy); } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
void Clean() { Brink = null; Invulnerable = null; AddHealthNextFrame = 0; _gameEnergyCounter = null; Shield = null; Poison = null; _oldEnergy = null; StartGhostArrowsNextFrame = false; StartGhostNotesNextFrame = false; PluginUI.instance.SetEnergyBarColor(Color.white); }
void DismissGraph(ResultsViewController vc) { if (panel != null) { Destroy(panel); panel = null; resultsController = null; scoreController = null; energyCounter = null; rankCounter = null; endActions = null; } }
private void SceneManagerOnSceneLoaded(Scene newScene, LoadSceneMode mode) { _eventManager = gameObject.GetComponent <EventManager>(); if (_eventManager == null) { _eventManager = gameObject.AddComponent <EventManager>(); } _scoreController = Resources.FindObjectsOfTypeAll <ScoreController>().FirstOrDefault(); if (_scoreController == null) { return; } //_eventManager.OnLevelStart?.Invoke(); // replaced by LevelStartedEvent() _saberCollisionManager = Resources.FindObjectsOfTypeAll <ObstacleSaberSparkleEffectManager>().FirstOrDefault(); _gameEnergyCounter = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().FirstOrDefault(); _beatmapObjectCallbackController = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().FirstOrDefault(); _beatmapDataModel = Resources.FindObjectsOfTypeAll <BeatmapDataSO>().FirstOrDefault(); _scoreController.noteWasCutEvent += SliceCallBack; _scoreController.noteWasMissedEvent += NoteMissCallBack; _scoreController.multiplierDidChangeEvent += MultiplierCallBack; _scoreController.comboDidChangeEvent += ComboChangeEvent; if (_saberCollisionManager) { _saberCollisionManager.sparkleEffectDidStartEvent += SaberStartCollide; _saberCollisionManager.sparkleEffectDidEndEvent += SaberEndCollide; } if (_gameEnergyCounter) { _gameEnergyCounter.gameEnergyDidReach0Event += FailLevelCallBack; } if (_beatmapObjectCallbackController) { _beatmapObjectCallbackController.beatmapEventDidTriggerEvent += OnBeatmapEventDidTriggerEvent; } _lastNoteId = -1; /*if (_beatmapDataModel) * { * _beatmapDataModel.beatmapDataDidChangeEvent += BeatmapDataChangedCallback; * BeatmapDataChangedCallback(); * }*/ }
private void Init() { try { _EventManager.OnLevelStart.Invoke(); _scoreController = Resources.FindObjectsOfTypeAll <ScoreController>().FirstOrDefault(); _saberCollisionManager = Resources.FindObjectsOfTypeAll <ObstacleSaberSparkleEffectManager>().FirstOrDefault(); _gameEnergyCounter = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().FirstOrDefault(); _beatmapObjectCallbackController = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().FirstOrDefault(); UnsubscribeFromEvents(); SubscribeToEvents(); } catch (Exception e) { Console.WriteLine(e); } }
public BSEvents(BeatmapObjectManager beatmapObjectManager, GameEnergyCounter gameEnergyCounter, GameplayCoreSceneSetupData gameplayCoreSceneSetupData, ObstacleSaberSparkleEffectManager obstacleSaberSparkleEffectManager, ScoreController scoreController, PlayerDataModel playerDataModel, PrepareLevelCompletionResults prepareLevelCompletionResults, IBeatmapObjectCallbackController beatmapObjectCallbackController, IDifficultyBeatmap difficultyBeatmap) { _beatmapObjectManager = beatmapObjectManager; _gameEnergyCounter = gameEnergyCounter; _gameplayCoreSceneSetupData = gameplayCoreSceneSetupData; _obstacleSaberSparkleEffectManager = obstacleSaberSparkleEffectManager; _scoreController = scoreController; _playerDataModel = playerDataModel; _prepareLevelCompletionResults = prepareLevelCompletionResults; _beatmapObjectCallbackController = beatmapObjectCallbackController; _difficultyBeatmap = difficultyBeatmap; }
private static void AddEnergyPatch(object self, float value) { //If the Bailout Toggle is off, this will just run the original code and exit this function. if (!BailOutModePlugin.shouldIBail) { addEnergyRedirection.InvokeOriginal(self, value); return; } GameEnergyCounter instance = (GameEnergyCounter)self; if (!(instance.energy + value <= 1E-05f)) { addEnergyRedirection.InvokeOriginal(self, value); return; } //if (BailOutModePlugin.bailoutNotification) showBailoutNotification(); Console.WriteLine("[Bailout] Lethal energy reached, bailing out! [1/4]"); BailOutModePlugin.BailedOut = false; try { typeof(GameEnergyCounter).GetField("<noFail>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(instance, true); //typeof(GameEnergyCounter).GetField("noFail", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(instance, true); //typeof(GameEnergyCounter).GetField("<isInitialized>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(instance, true); Console.WriteLine("[Bailout] Disabling score submission[2/4]"); //BS_Utils.Gameplay.ScoreSubmission.DisableSubmission("Bailed Out"); <-- disables score submission for scoresaber Console.WriteLine("[Bailout] Disabling Ingame Energy Bar [3/4]"); UnityEngine.Object.FindObjectOfType <GameEnergyUIPanel>().gameObject.SetActive(false); Console.WriteLine("[Bailout] Bailed out [4/4]"); } catch (Exception e) { Console.WriteLine(e); throw; } value = 100f; addEnergyRedirection.InvokeOriginal(self, value); }
void DismissGraph(ResultsViewController vc) { if (panel != null) { panel.SetActive(false); Destroy(panel, 1); panel = null; scoreController = null; objectManager = null; comboController = null; energyCounter = null; rankCounter = null; audioController = null; endActions = null; } if (vc != null) { vc.continueButtonPressedEvent -= DismissGraph; vc.restartButtonPressedEvent -= DismissGraph; } }
private void Awake() { _gameEnergyUIPanel = Resources.FindObjectsOfTypeAll <GameEnergyUIPanel>().FirstOrDefault(); if (_gameEnergyUIPanel == null) { return; } _gameEnergyUIPanel.EnableEnergyPanel(true); _gameEnergyCounter = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().FirstOrDefault(); var levelFailedController = Resources.FindObjectsOfTypeAll <LevelFailedController>().FirstOrDefault(); if (levelFailedController == null) { return; } var textEffect = levelFailedController.GetPrivateField <LevelFailedTextEffect>("_levelFailedTextEffect"); _levelFailedAnimator = textEffect.GetPrivateField <Animator>("_animator"); _levelFailedGameObject = GameObject.Find("LevelFailedTextEffect"); }
public static IEnumerator FetchObjects() { yield return(new WaitForSeconds(0.1f)); soundEffectManager = Resources.FindObjectsOfTypeAll <NoteCutSoundEffectManager>().LastOrDefault(); beatmapObjectManager = Resources.FindObjectsOfTypeAll <BeatmapObjectExecutionRatingsRecorder>().LastOrDefault().GetPrivateField <BeatmapObjectManager>("_beatmapObjectManager") as BasicBeatmapObjectManager; spawnController = Resources.FindObjectsOfTypeAll <BeatmapObjectSpawnController>().LastOrDefault(); energyCounter = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().LastOrDefault(); ColorManager = Resources.FindObjectsOfTypeAll <ColorManager>().LastOrDefault(); pauseManager = Resources.FindObjectsOfTypeAll <StandardLevelGameplayManager>().LastOrDefault(); AudioTimeSync = Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().LastOrDefault(); if (AudioTimeSync != null) { songAudio = AudioTimeSync.GetField <AudioSource>("_audioSource"); if (songAudio == null) { Plugin.Log("Audio null"); } } Mixer = soundEffectManager.GetField <AudioManagerSO>("_audioManager"); GameModifiersController.SetupSpawnCallbacks(); }