コード例 #1
0
        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());
            }
        }
コード例 #2
0
        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();
            }
        }
コード例 #3
0
        private void SceneManagerOnActiveSceneChanged(Scene arg0, Scene scene)
        {
            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");
                twitchPowers = chatPowers.AddComponent <TwitchPowers>();
                GameObject.DontDestroyOnLoad(chatPowers);
            }

            //        }
            //        catch(Exception ex)
            //        {
            //           Log(ex.ToString());
            //        }

            GMPDisplay display = chatPowers.GetComponent <GMPDisplay>();

            if (display != null)
            {
                display.Destroy();
                GameObject.Destroy(display);
            }



            ReadPrefs();
            if (GMPUI.chatIntegration)
            {
                if (twitchPowers != null)
                {
                    cooldowns.ResetCooldowns();
                    TwitchPowers.ResetPowers(false);
                    twitchPowers.StopAllCoroutines();
                }
                if (Config.resetChargesperLevel)
                {
                    charges = 0;
                }
            }

            //    twitchCommands.StopAllCoroutines();
            haveSongNJS = false;

            invalidForScoring = false;
            if (soundIsPlaying == true)
            {
                gnomeSound.Stop();
            }
            soundIsPlaying = false;
            isValidScene   = false;
            playerInfo     = false;
            if (arg0.name == "EmpyTransition" && chatPowers != null)
            {
                GameObject.Destroy(chatPowers);
            }

            if (scene.name == ("Menu"))
            {
                Log("Switched to Menu");
                SharedCoroutineStarter.instance.StartCoroutine(GrabPP());


                if (_hasRegistered == false)
                {
                    TwitchConnection.Instance.StartConnection();
                    TwitchConnection.Instance.RegisterOnMessageReceived(TwitchConnection_OnMessageReceived);
                    _hasRegistered = true;
                }

                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")
            {
                environmentColorsSetter = Resources.FindObjectsOfTypeAll <EnvironmentColorsSetter>().FirstOrDefault();
                soundEffectManager      = Resources.FindObjectsOfTypeAll <NoteCutSoundEffectManager>().First();
                levelData       = Resources.FindObjectsOfTypeAll <StandardLevelSceneSetupDataSO>().First();
                spawnController = Resources.FindObjectsOfTypeAll <BeatmapObjectSpawnController>().First();
                energyCounter   = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().First();
                energyPanel     = Resources.FindObjectsOfTypeAll <GameEnergyUIPanel>().First();

                spawnController.noteDidStartJumpEvent += SpawnController_ModifiedJump;
                spawnController.noteWasCutEvent       += SpawnController_ScaleRemoveCut;
                spawnController.noteWasMissedEvent    += SpawnController_ScaleRemoveMiss;

                currentSongSpeed = levelData.gameplayCoreSetupData.gameplayModifiers.songSpeedMul;


                levelData.didFinishEvent += LevelData_didFinishEvent;



                if (GMPUI.njsRandom)
                {
                    twitchPowers.StartCoroutine(TwitchPowers.RandomNJS());
                }
                Log(GMPUI.swapSabers.ToString());
                if (GMPUI.noArrows)
                {
                    twitchPowers.StartCoroutine(TwitchPowers.NoArrows());
                }
                if (GMPUI.chatIntegration && Config.maxCharges > 0)
                {
                    chatPowers.AddComponent <GMPDisplay>();
                }
                if (Config.timeForCharges > 0)
                {
                    twitchPowers.StartCoroutine(TwitchPowers.ChargeOverTime());
                }

                pauseManager = Resources.FindObjectsOfTypeAll <StandardLevelGameplayManager>().First();
                var colors = Resources.FindObjectsOfTypeAll <SimpleColorSO>();
                foreach (SimpleColorSO color in colors)
                {
                    Log(color.name);
                    if (color.name == "Color0")
                    {
                        colorA = color;
                    }
                    if (color.name == "Color1")
                    {
                        colorB = color;
                    }
                }
                oldColorA.SetColor(colorA);
                oldColorB.SetColor(colorB);


                Log(colorA.color.ToString());
                if (GMPUI.chatIntegration && charges <= Config.maxCharges)
                {
                    charges += Config.chargesPerLevel;
                    if (charges > Config.maxCharges)
                    {
                        charges = Config.maxCharges;
                    }
                    //          TwitchConnection.Instance.SendChatMessage("Current Charges: " + charges);
                }



                //   ReflectionUtil.SetProperty(typeof(PracticePlugin.Plugin), "TimeScale", 1f);
                isValidScene  = true;
                AudioTimeSync = Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().FirstOrDefault();
                if (AudioTimeSync != null)
                {
                    songAudio = AudioTimeSync.GetField <AudioSource>("_audioSource");
                    if (songAudio != null)
                    {
                        Log("Audio not null");
                    }
                    Log("Object Found");
                }
                //Get Sabers
                player = Resources.FindObjectsOfTypeAll <PlayerController>().FirstOrDefault();
                if (player != null)
                {
                    leftSaber  = player.leftSaber;
                    rightSaber = player.rightSaber;

                    playerInfo = true;
                }
                else
                {
                    playerInfo = false;
                    Log("Player is null");
                }
                Log(leftSaber.handlePos.ToString());
                Log(leftSaber.saberBladeTopPos.ToString());

                if (GMPUI.swapSabers)
                {
                    Log("Testing Ground Active");
                    try
                    {
                        SharedCoroutineStarter.instance.StartCoroutine(TwitchPowers.TestingGround(5f));
                    }
                    catch (Exception ex)
                    {
                        Log(ex.ToString());
                    }
                }
                //  SharedCoroutineStarter.instance.StartCoroutine(SwapSabers(leftSaber, rightSaber));

                if (GMPUI.gnomeOnMiss == true)
                {
                    invalidForScoring = true;

                    if (spawnController != null)
                    {
                        spawnController.noteWasMissedEvent += delegate(BeatmapObjectSpawnController beatmapObjectSpawnController2, NoteController noteController)
                        {
                            if (noteController.noteData.noteType != NoteType.Bomb)
                            {
                                try
                                {
                                    twitchPowers.StartCoroutine(TwitchPowers.SpecialEvent());
                                    Log("Gnoming");
                                }
                                catch (Exception ex)
                                {
                                    Log(ex.ToString());
                                }
                            }
                        };

                        spawnController.noteWasCutEvent += delegate(BeatmapObjectSpawnController beatmapObjectSpawnController2, NoteController noteController, NoteCutInfo noteCutInfo)
                        {
                            if (!noteCutInfo.allIsOK)
                            {
                                twitchPowers.StartCoroutine(TwitchPowers.SpecialEvent());
                                Log("Gnoming");
                            }
                        };
                    }
                }
                if (GMPUI.bulletTime || GMPUI.chatIntegration || GMPUI.fixedNoteScale != 1f)
                {
                    invalidForScoring = true;
                }

                /*
                 * if(GMPUI.superHot == true)
                 * {
                 *  startGMPUI.superHot = false;
                 *  SharedCoroutineStarter.instance.StartCoroutine(Wait(1f));
                 *
                 * }
                 *
                 */
            }
        }