示例#1
0
        public void ApplyColors()
        {
            if (_colorInit && _overrideCustomSabers && safeSaberOverride)
            {
                EnsureCustomSabersOverridden();
            }
            if (SceneManager.GetActiveScene().name == "MenuCore" && CustomSabersPresent && _overrideCustomSabers)
            {
                EnsureCustomSabersOverridden();
            }

            if (disablePlugin == false || queuedDisable)
            {
                //                [CustomColorsEdit] Mesh renderer material name is ObstacleCore(Instance)
                //[CustomColorsEdit] Mesh renderer material name is ObstacleCoreInside(Instance)
                //[CustomColorsEdit] Mesh renderer material name is ObstacleFrame(Instance)

                if (_colorInit)
                {
                    return;
                }

                var colorManager = Resources.FindObjectsOfTypeAll <ColorManager>().FirstOrDefault();
                if (colorManager == null)
                {
                    return;
                }

                var leftColor  = ReflectionUtil.GetPrivateField <SimpleColorSO>(colorManager, "_colorA");
                var rightColor = ReflectionUtil.GetPrivateField <SimpleColorSO>(colorManager, "_colorB");

                leftColor.SetColor(ColorLeft);
                rightColor.SetColor(ColorRight);

                Log("ColorManager colors set!");

                foreach (var scriptableColor in _scriptableColors)
                {
                    if (scriptableColor != null)
                    {
                        //             Log(scriptableColor.name);
                        //     Log(scriptableColor.color.ToString());

                        /*
                         * if (scriptableColor.name == "Color Red" || scriptableColor.name == "BaseColor1")
                         * {
                         *  scriptableColor.SetColor(ColorLeft);
                         * }
                         * else if (scriptableColor.name == "Color Blue" || scriptableColor.name == "BaseColor0")
                         * {
                         *  scriptableColor.SetColor(ColorRight);
                         * }
                         */
                        if (scriptableColor.name == "BaseNoteColor0")
                        {
                            scriptableColor.SetColor(ColorRight);
                        }
                        else if (scriptableColor.name == "BaseColor0")
                        {
                            scriptableColor.SetColor(ColorRightLight);
                        }
                        else if (scriptableColor.name == "BaseNoteColor1")
                        {
                            scriptableColor.SetColor(ColorLeft);
                        }
                        else if (scriptableColor.name == "BaseColor1")
                        {
                            scriptableColor.SetColor(ColorLeftLight);
                        }
                        else if (scriptableColor.name == "MenuEnvLight3")
                        {
                            scriptableColor.SetColor(ColorRightLight);
                        }
                        else if (scriptableColor.name == "MenuEnvLight1")
                        {
                            scriptableColor.SetColor(ColorRightLight);
                        }
                        //   else if (scriptableColor.name == "MenuEnvLight1")
                        //      scriptableColor.SetColor(ColorRightLight);

                        //      Log(scriptableColor.name);
                        //      Log(scriptableColor.color.ToString());
                    }
                    //         Log($"Set scriptable color: {scriptableColor.name}");
                }
                Log("ScriptableColors modified!");
                colorManager.RefreshColors();

                if (SceneManager.GetActiveScene().name == "MenuCore")
                {
                    SharedCoroutineStarter.instance.StartCoroutine(SetLogoColors());


                    Log("Menu colors set!");
                }

                /*
                 * foreach (var prePassLight in _prePassLights)
                 * {
                 *
                 *  if (prePassLight != null)
                 *  {
                 *      if (prePassLight.name.Contains("SaberNeon"))
                 *      {
                 *          prePassLight.color = ColorLeftLight;
                 *
                 *      }
                 *
                 *
                 *      if (prePassLight.name.Contains("BATNeon") || prePassLight.name.Contains("ENeon"))
                 *          prePassLight.color = ColorRightLight;
                 *
                 *      //    Log($"PrepassLight: {prePassLight.name}");
                 *  }
                 * }
                 *
                 * Log("PrePassLight colors set!");
                 *
                 * SpriteRenderer[] sprites = Resources.FindObjectsOfTypeAll<SpriteRenderer>();
                 * foreach (var sprite in sprites)
                 * {
                 *  Log(sprite.name);
                 *  if (sprite != null)
                 *  if (sprite != null)
                 *  {
                 *      if (sprite.name == "SaberLogo")
                 *          sprite.sharedMaterial.color = ColorLeftLight;
                 *      if (sprite.name == "BatLogo" || sprite.name == "LogoE")
                 *          sprite.sharedMaterial.color = ColorRightLight;
                 *  }
                 *
                 * }
                 */



                if (Plugin.wallColorPreset != 0)
                {
                    SharedCoroutineStarter.instance.StartCoroutine(WallPrep());
                }
                if (gameScene && rainbowWall)
                {
                    SharedCoroutineStarter.instance.StartCoroutine(RainbowWalls());
                }

                //Logo Disable if needed

                /*
                 * GameObject logo = GameObject.Find("Logo");
                 * if(logo != null)
                 * GameObject.Destroy(logo.gameObject);
                 */

                if (SceneManager.GetActiveScene().name == "MenuCore")
                {
                    /*
                     * var flickeringLetter = UnityEngine.Object.FindObjectOfType<FlickeringNeonSign>();
                     * if (flickeringLetter != null)
                     *  ReflectionUtil.SetPrivateField(flickeringLetter, "_onColor", ColorRightLight);
                     */
                    Log("Menu colors set!");
                }


                _colorInit    = true;
                queuedDisable = false;
                colorsSetter  = Resources.FindObjectsOfTypeAll <EnvironmentColorsSetter>().FirstOrDefault();
                if (allowEnvironmentColors)
                {
                    if (colorsSetter != null)
                    {
                        try
                        {
                            colorsSetter.Awake();
                        }
                        catch
                        {
                            Log("Failed to Initialize Color Setter");
                        }

                        overrideSaberOverride = true;
                    }
                }
                else
                {
                    colorManager.RefreshColors();
                }
                safeSaberOverride = true;
                ColorsAppliedEvent?.Invoke();
            }
            if (disablePlugin && allowEnvironmentColors && _overrideCustomSabers)
            {
                colorsSetter = Resources.FindObjectsOfTypeAll <EnvironmentColorsSetter>().FirstOrDefault();
                if (colorsSetter != null)
                {
                    overrideSaberOverride = true;
                    _colorInit            = true;
                }
                safeSaberOverride = true;
            }
        }