private void SceneManagerOnActiveSceneChanged(Scene oldScene, Scene newScene) { UI.BasicUI.ReadPrefs(); CurrentScore = 0; maxPossibleScore = 0; currentMaxPossibleScore = 0; gameScene = false; if (newScene.name == "MenuCore") { if (standardLevelDetailView == null) { standardLevelDetailView = Resources.FindObjectsOfTypeAll <StandardLevelDetailViewController>().FirstOrDefault(); } if (standardLevelDetailView != null) { standardLevelDetailView.didPressPlayButtonEvent += StandardLevelDetailView_didPressPlayButtonEvent; } if (DifficultyViewController == null) { DifficultyViewController = Resources.FindObjectsOfTypeAll <BeatmapDifficultyViewController>().FirstOrDefault(); } if (DifficultyViewController != null) { DifficultyViewController.didSelectDifficultyEvent += DifficultyViewController_didSelectDifficultyEvent; } if (PlayerName == "") { PlayerName = BS_Utils.Gameplay.GetUserInfo.GetUserName(); } } if (newScene.name == "GameCore") { gameScene = true; if (UI.BasicUI.enabled && !BS_Utils.Gameplay.Gamemode.IsIsolatedLevel) { levelSceneSetupDataSO = BS_Utils.Plugin.LevelData; if (levelSceneSetupDataSO != null) { maxPossibleScore = ScoreController.MaxRawScoreForNumberOfNotes(levelSceneSetupDataSO.GameplayCoreSceneSetupData.difficultyBeatmap.beatmapData.notesCount); } scoreController = Resources.FindObjectsOfTypeAll <ScoreController>().FirstOrDefault(); if (scoreController != null) { scoreController.scoreDidChangeEvent += ScoreController_scoreDidChangeEvent; } CreateBoard(); SharedCoroutineStarter.instance.StartCoroutine(UpdateBoardFixed()); } } }
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"); levelSetup = BS_Utils.Plugin.LevelData; GameplayCoreSceneSetup gameplayCoreSceneSetup = Resources.FindObjectsOfTypeAll <GameplayCoreSceneSetup>().First(); if (Plugin.IsDarthModeOn) { BS_Utils.Gameplay.ScoreSubmission.DisableSubmission("Darth Maul"); //var _beatmapDataModel = ReflectionUtil.GetPrivateField<BeatmapDataModel>(gameplayCoreSceneSetup, "_beatmapDataModel"); //var beatmapData = CreateTransformedBeatmapData(levelSetup.GameplayCoreSceneSetupData.difficultyBeatmap.beatmapData.GetCopy(), levelSetup); //if (beatmapData != null) //{ // _beatmapDataModel.beatmapData = beatmapData; //} } } catch (Exception ex) { Console.WriteLine(ex.Message + "\n" + ex.StackTrace); } }
public void OnActiveSceneChanged(Scene arg0, Scene scene) { if (scene.name == "MenuViewControllers") { activateDuringIsolated = false; Log("Switched to Menu"); SharedCoroutineStarter.instance.StartCoroutine(GrabPP()); var controllers = Resources.FindObjectsOfTypeAll <VRController>(); if (controllers != null) { foreach (VRController controller in controllers) { if (controller != null) { if (controller.ToString() == "ControllerLeft (VRController)") { leftController = controller; } if (controller.ToString() == "ControllerRight (VRController)") { rightController = controller; } } // Log(controller.ToString()); } // Log("Left:" + leftController.ToString()); // Log("Right: " + rightController.ToString()); } } if (scene.name == "GameCore") { RemovePatches(); } if (_mainSettingsModel == null) { var menu = Resources.FindObjectsOfTypeAll <MainFlowCoordinator>().FirstOrDefault(); if (menu != null) { _mainSettingsModel = menu.GetField <MainSettingsModelSO>("_mainSettingsModel"); _mainSettingsModel.Load(true); Log("RUMBLE: " + _mainSettingsModel.controllersRumbleEnabled.ToString()); if (!setDefaultRumble) { defaultRumble = _mainSettingsModel.controllersRumbleEnabled; ModPrefs.SetInt("GameplayModifiersPlus", "GameRumbleSetting", _mainSettingsModel.controllersRumbleEnabled ? 1 : 0); setDefaultRumble = true; Log("Set Default Rumble Value"); } } } if (_mainSettingsModel != null) { defaultRumble = ModPrefs.GetInt("GameplayModifiersPlus", "GameRumbleSetting", -1, false) != 1 ? false : true; _mainSettingsModel.controllersRumbleEnabled.value = defaultRumble; _mainSettingsModel.Save(); } paused = false; if (!customColorsInstalled) { if (colorA != null) { colorA.SetColor(defColorA); } if (colorB != null) { colorB.SetColor(defColorB); } } // try // { if (scene.name == "EmptyTransition") { Log("Resetting Chat Powers Object"); if (chatPowers != null) { GameObject.Destroy(chatPowers); } } if (chatPowers == null) { Log("Null Creation of Chat Powers Object"); chatPowers = new GameObject("Chat Powers"); GameObject.DontDestroyOnLoad(chatPowers); twitchPowers = chatPowers.AddComponent <TwitchPowers>(); } // } // catch(Exception ex) // { // Log(ex.ToString()); // } GMPDisplay display = chatPowers.GetComponent <GMPDisplay>(); if (display != null) { display.Destroy(); GameObject.Destroy(display); } ReadPrefs(); if (GMPUI.chatIntegration && twitchPluginInstalled) { if (twitchPowers != null) { cooldowns.ResetCooldowns(); TwitchPowers.ResetPowers(false); twitchPowers.StopAllCoroutines(); } if (ChatConfig.resetChargesEachLevel) { charges = 0; } } // twitchCommands.StopAllCoroutines(); haveSongNJS = false; if (soundIsPlaying == true) { gnomeSound.Stop(); } soundIsPlaying = false; isValidScene = false; playerInfo = false; modifiersInit = false; if (arg0.name == "EmpyTransition" && chatPowers != null) { GameObject.Destroy(chatPowers); } if (scene.name == "GameCore") { Log("Isolated: " + BS_Utils.Gameplay.Gamemode.IsIsolatedLevel); isValidScene = true; if (BS_Utils.Gameplay.Gamemode.IsIsolatedLevel && !activateDuringIsolated) { Log("Isolated Level, not activating"); return; } // Log("Pre GrabGrab"); GameObject.Destroy(GameObject.Find("Color Setter")); soundEffectManager = Resources.FindObjectsOfTypeAll <NoteCutSoundEffectManager>().FirstOrDefault(); spawnController = Resources.FindObjectsOfTypeAll <BeatmapObjectSpawnController>().FirstOrDefault(); energyCounter = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().First(); energyPanel = Resources.FindObjectsOfTypeAll <GameEnergyUIPanel>().First(); ColorManager = Resources.FindObjectsOfTypeAll <ColorManager>().First(); levelData = BS_Utils.Plugin.LevelData; // Log("Post GrabGrab"); if (spawnController != null) { spawnController.noteDidStartJumpEvent += SpawnController_ModifiedJump; spawnController.noteWasCutEvent += SpawnController_ScaleRemoveCut; spawnController.noteWasMissedEvent += SpawnController_ScaleRemoveMiss; } else { Log("Spawn Controller Null"); } // Log("Post GrabGrab 2"); currentSongSpeed = levelData.GameplayCoreSceneSetupData.gameplayModifiers.songSpeedMul; BS_Utils.Plugin.LevelDidFinishEvent += LevelData_didFinishEvent; // Log("Post GrabGrab 3"); if (!Multiplayer.MultiMain.multiActive.Value) { if (GMPUI.chatIntegration && ChatConfig.maxCharges > 0 && twitchPluginInstalled) { chatPowers.AddComponent <GMPDisplay>(); } if (GMPUI.chatIntegration && ChatConfig.timeForCharges > 0 && twitchPluginInstalled) { twitchPowers.StartCoroutine(TwitchPowers.ChargeOverTime()); } } // Log("Post GrabGrab 4"); pauseManager = Resources.FindObjectsOfTypeAll <StandardLevelGameplayManager>().First(); var colors = Resources.FindObjectsOfTypeAll <SimpleColorSO>(); // Log("Pre Color"); foreach (SimpleColorSO color in colors) { // Log(color.name); if (color.name == "BaseNoteColor1") { colorA = color; } if (color.name == "BaseNoteColor0") { colorB = color; } } oldColorA.SetColor(colorA); oldColorB.SetColor(colorB); // Log("Pre ChatInt"); // Log(colorA.color.ToString()); if (GMPUI.chatIntegration && charges <= ChatConfig.maxCharges && twitchPluginInstalled) { charges += ChatConfig.chargesPerLevel; if (charges > ChatConfig.maxCharges) { charges = ChatConfig.maxCharges; } // TryAsyncMessage("Current Charges: " + charges); } // Log("Pre Audio/Player"); // ReflectionUtil.SetProperty(typeof(PracticePlugin.Plugin), "TimeScale", 1f); AudioTimeSync = Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().FirstOrDefault(); if (AudioTimeSync != null) { songAudio = AudioTimeSync.GetField <AudioSource>("_audioSource"); if (songAudio == null) { Log("Audio null"); } // Log("Object Found"); } //Get Sabers player = Resources.FindObjectsOfTypeAll <PlayerController>().FirstOrDefault(); if (player != null) { playerInfo = true; } else { playerInfo = false; Log("Player is null"); } CheckGMPModifiers(); } }
public void OnActiveSceneChanged(Scene arg0, Scene scene) { if (scene.name == "MenuViewControllers") { activateDuringIsolated = false; } if (scene.name == "EmptyTransition") { Log("Resetting Chat Powers Object"); if (chatPowers != null) { GameObject.Destroy(chatPowers); } } if (chatPowers == null) { // Log("Null Creation of Chat Powers Object"); chatPowers = new GameObject("Chat Powers"); GameObject.DontDestroyOnLoad(chatPowers); twitchPowers = chatPowers.AddComponent <TwitchPowers>(); } GMPDisplay display = chatPowers.GetComponent <GMPDisplay>(); if (display != null) { display.Destroy(); GameObject.Destroy(display); } ReadPrefs(); if (GMPUI.chatIntegration && twitchPluginInstalled) { if (twitchPowers != null) { cooldowns.ResetCooldowns(); TwitchPowers.ResetPowers(false); twitchPowers.StopAllCoroutines(); } if (Config.resetChargesEachLevel) { GameModifiersController.charges = 0; } } isValidScene = false; if (arg0.name == "EmpyTransition" && chatPowers != null) { GameObject.Destroy(chatPowers); } if (scene.name == "GameCore") { Log("Isolated: " + BS_Utils.Gameplay.Gamemode.IsIsolatedLevel); isValidScene = true; if (BS_Utils.Gameplay.Gamemode.IsIsolatedLevel && !activateDuringIsolated) { Log("Isolated Level, not activating"); return; } if (!BS_Utils.Plugin.LevelData.IsSet || BS_Utils.Plugin.LevelData.Mode != BS_Utils.Gameplay.Mode.Standard) { return; } ColorController.oldColorScheme = null; levelData = BS_Utils.Plugin.LevelData; GameObjects.Load(); GameModifiersController.currentSongSpeed = levelData.GameplayCoreSceneSetupData.gameplayModifiers.songSpeedMul; chatPowers.AddComponent <GMPDisplay>(); if (GMPUI.chatIntegration && Config.timeForCharges > 0 && twitchPluginInstalled) { twitchPowers.StartCoroutine(TwitchPowers.ChargeOverTime()); } if (GMPUI.chatIntegration && GameModifiersController.charges <= Config.maxCharges && twitchPluginInstalled) { GameModifiersController.charges += Config.chargesPerLevel; if (GameModifiersController.charges > Config.maxCharges) { GameModifiersController.charges = Config.maxCharges; } } SharedCoroutineStarter.instance.StartCoroutine(GameModifiersController.CheckGMPModifiers()); } }
public static BeatmapData CreateTransformedBeatmapData(BeatmapData beatmapData, BS_Utils.Gameplay.LevelData levelSetup) { BeatmapData beatmapData2 = beatmapData; if (BS_Utils.Gameplay.Gamemode.GameMode == "No Arrows") { beatmapData2 = BeatmapDataNoArrowsTransform.CreateTransformedData(beatmapData2); } //This covers all of the modifiers and player settings that were here previously beatmapData2 = BeatDataTransformHelper.CreateTransformedBeatmapData(beatmapData2, levelSetup.GameplayCoreSceneSetupData.gameplayModifiers, levelSetup.GameplayCoreSceneSetupData.practiceSettings, levelSetup.GameplayCoreSceneSetupData.playerSpecificSettings); if (beatmapData2 == beatmapData) { beatmapData2 = beatmapData.GetCopy(); } return(beatmapData2); }
private void GetObjects() { if (_spawnController == null) { _spawnController = Resources.FindObjectsOfTypeAll <BeatmapObjectSpawnController>().FirstOrDefault(); } if (_spawnController == null) { return; } _spawnController.noteWasCutEvent -= _spawnController_noteWasCutEvent; _spawnController.noteWasMissedEvent -= _spawnController_noteWasMissedEvent; if (LevelData == null) { LevelData = BS_Utils.Plugin.LevelData; } if (LevelData == null) { return; } if (_levelFailedController == null) { _levelFailedController = Resources.FindObjectsOfTypeAll <StandardLevelFailedController>().FirstOrDefault(); } if (_levelRestartController == null) { _levelRestartController = Resources.FindObjectsOfTypeAll <StandardLevelRestartController>().FirstOrDefault(); } if (_energyCounter == null) { _energyCounter = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().FirstOrDefault(); } if (_scoreController == null) { _scoreController = Resources.FindObjectsOfTypeAll <ScoreController>().FirstOrDefault(); } if (!CheckRestrictions()) { return; } _spawnController.noteWasCutEvent += _spawnController_noteWasCutEvent; _spawnController.noteWasMissedEvent += _spawnController_noteWasMissedEvent; _energyCounter.gameEnergyDidReach0Event += _energyCounter_gameEnergyDidReach0Event; if (Config.failOnSaberClash) { LevelData.GameplayCoreSceneSetupData.gameplayModifiers.failOnSaberClash = true; } if (Config.stricterAngles) { Log("Disabling Score Submission for Stricter Angles"); BS_Utils.Gameplay.ScoreSubmission.DisableSubmission("Gameplay Restrictions Plus"); LevelData.GameplayCoreSceneSetupData.gameplayModifiers.strictAngles = true; } }
private void AddEvents() { _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 { _beatmapObjectSpawnController = Resources.FindObjectsOfTypeAll <BeatmapObjectSpawnController>().FirstOrDefault(); if (_beatmapObjectSpawnController == null) { Console.WriteLine("SPAWN CONTROLLER NULL"); //_beatmapObjectSpawnController = _saberRoot.AddComponent<BeatmapObjectSpawnController>(); } _scoreController = Resources.FindObjectsOfTypeAll <ScoreController>().FirstOrDefault(); if (_scoreController == null) { Console.WriteLine("SCORE CONTROLLER NULL"); //_scoreController = _saberRoot.AddComponent<ScoreController>(); } _saberCollisionManager = Resources.FindObjectsOfTypeAll <ObstacleSaberSparkleEffectManager>().FirstOrDefault(); if (_saberCollisionManager == null) { Console.WriteLine("COLLISION MANAGER NULL"); //_saberCollisionManager = _saberRoot.AddComponent<ObstacleSaberSparkleEffectManager>(); } _gameEnergyCounter = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().FirstOrDefault(); if (_gameEnergyCounter == null) { Console.WriteLine("energery counter null"); //_gameEnergyCounter = _saberRoot.AddComponent<GameEnergyCounter>(); } _beatmapCallback = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().FirstOrDefault(); if (_beatmapCallback == null) { Console.WriteLine("BEATMAP CALLBACK NULL"); //_beatmapCallback = _saberRoot.AddComponent<BeatmapObjectCallbackController>(); } _gamePauseManager = Resources.FindObjectsOfTypeAll <GamePauseManager>().FirstOrDefault(); if (_gamePauseManager == null) { Console.WriteLine("GamePauseManager Null"); //_gamePauseManager = _saberRoot.AddComponent<GamePauseManager>(); } _playerHeadAndObstacleInteraction = Resources.FindObjectsOfTypeAll <PlayerHeadAndObstacleInteraction>().FirstOrDefault(); if (_playerHeadAndObstacleInteraction == null) { Console.WriteLine("PlayerHeadAndObstacleInteraction Null"); //_playerHeadAndObstacleInteraction = _saberRoot.AddComponent<PlayerHeadAndObstacleInteraction>(); } _beatmapObjectSpawnController.noteWasCutEvent += SliceCallBack; _beatmapObjectSpawnController.noteWasMissedEvent += NoteMissCallBack; _scoreController.multiplierDidChangeEvent += MultiplierCallBack; _scoreController.comboDidChangeEvent += ComboChangeEvent; _saberCollisionManager.sparkleEffectDidStartEvent += SaberStartCollide; _saberCollisionManager.sparkleEffectDidEndEvent += SaberEndCollide; _gameEnergyCounter.gameEnergyDidReach0Event += FailLevelCallBack; _beatmapCallback.beatmapEventDidTriggerEvent += LightEventCallBack; // ReflectionUtil.SetPrivateField(_gamePauseManager, "_gameDidResumeSignal", (Action)OnPauseMenuClosed); //For some reason _gameDidResumeSignal isn't public. } catch (Exception e) { Console.WriteLine(e); Console.WriteLine(e.Message); throw; } try { BS_Utils.Gameplay.LevelData mgs = GetGameSceneSetup(); BeatmapData beatmapData = mgs.GameplayCoreSceneSetupData.difficultyBeatmap.beatmapData; BeatmapLineData[] beatmapLinesData = beatmapData.beatmapLinesData; float LastTime = 0.0f; for (int i = 0; i < beatmapLinesData.Length; i++) { BeatmapObjectData[] beatmapObjectsData = beatmapLinesData[i].beatmapObjectsData; for (int j = beatmapObjectsData.Length - 1; j > 0; j--) { if (beatmapObjectsData[j].beatmapObjectType == BeatmapObjectType.Note) { if (((NoteData)beatmapObjectsData[j]).noteType != NoteType.Bomb) { if (beatmapObjectsData[j].time > LastTime) { LastNoteId = beatmapObjectsData[j].id; LastTime = beatmapObjectsData[j].time; } break; } } } } } catch (Exception e) { Console.WriteLine(e); Console.WriteLine(e.Message); throw; } }
private void GCSSFound(Scene scene, GameplayCoreSceneSetup gcss) { ChromaLogger.Log("Found GCSS!", ChromaLogger.Level.DEBUG); //Plugin.PlayReloadSound(); _playerController = FindObjectOfType <PlayerController>(); if (_playerController == null) { ChromaLogger.Log("Player Controller not found!", ChromaLogger.Level.WARNING); } /*if (!SceneUtils.IsTargetGameScene(scene.buildIndex)) { * ChromaLogger.Log("Somehow we got to the point where we override a map, while not playing a map. How did this happen?", ChromaLogger.Level.WARNING); * return; * }*/ if (gcss == null) { ChromaLogger.Log("Failed to obtain MainGameSceneSetup", ChromaLogger.Level.WARNING); return; } //GameplayCoreSetupData mgData = ReflectionUtil.GetPrivateField<MainGameSceneSetupData>(mgs, "_mainGameSceneSetupData"); BS_Utils.Gameplay.LevelData levelData = BS_Utils.Plugin.LevelData; if (!levelData.IsSet) { ChromaLogger.Log("BS_Utils LevelData is not set", ChromaLogger.Level.WARNING); return; } PlayerSpecificSettings playerSettings = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.playerSpecificSettings; //Map BeatmapDataModel _beatmapDataModel = ReflectionUtil.GetField <BeatmapDataModel>(gcss, "_beatmapDataModel"); if (_beatmapDataModel == null) { ChromaLogger.Log("{XXX} : NULL BEATMAP DATA MODEL", ChromaLogger.Level.ERROR); } if (_beatmapDataModel.beatmapData == null) { ChromaLogger.Log("{XXX} : NULL BEATMAP DATA MODEL BEATMAP DATA", ChromaLogger.Level.ERROR); } //BeatmapData beatmapData = CreateTransformedBeatmapData(mgData.difficultyLevel.beatmapData, mgData.gameplayOptions, mgData.gameplayMode); BeatmapData beatmapData = CreateTransformedBeatmapData(_beatmapDataModel.beatmapData, playerSettings, BaseGameMode.CurrentBaseGameMode); if (beatmapData != null) { _beatmapDataModel.beatmapData = beatmapData; ReflectionUtil.SetField(gcss, "_beatmapDataModel", _beatmapDataModel); } foreach (IChromaBehaviourExtension extension in extensions) { extension.PostInitialization(songBPM, beatmapData, playerSettings, scoreController); } //modes = GetModes(mgData.gameplayMode, chromaSong); if (ChromaConfig.DebugMode) { Console.WriteLine(); Console.WriteLine(); ChromaLogger.Log("Gamemode: " + BaseGameMode.CurrentBaseGameMode.ToString() + " -- Party: " + BaseGameMode.PartyMode, ChromaLogger.Level.DEBUG); } //ChromaLogger.Log("Modify Sabers was called", ChromaLogger.Level.DEBUG); ColourManager.RefreshLights(); if (ChromaConfig.LightshowModifier) { foreach (Saber saber in GameObject.FindObjectsOfType <Saber>()) { saber.gameObject.SetActive(false); } } }