public IEnumerator SetLogoColors()
        {
            yield return(new WaitForSeconds(0.2f));

            if (GameObject.Find("Logo") != null)
            {
                foreach (Transform t in GameObject.Find("Logo").transform)
                {
                    Log($"Transform: {t.name}");
                    if (t.name == "BATNeon")
                    {
                        t.GetComponent <TubeBloomPrePassLight>().color = ColorLeftLight;
                    }
                    else if (t.name == "BatLogo")
                    {
                        t.GetComponent <SpriteRenderer>().color = ColorLeftLight * 1.4f;
                    }
                    else if (t.name == "SaberLogo")
                    {
                        t.GetComponent <SpriteRenderer>().color = ColorRightLight * 1.4f;
                    }
                    else if (t.name == "SaberNeon")
                    {
                        t.GetComponent <TubeBloomPrePassLight>().color = ColorRightLight;
                    }
                }
            }
            var flickeringLetter = UnityEngine.Object.FindObjectOfType <FlickeringNeonSign>();

            if (flickeringLetter != null)
            {
                ReflectionUtil.SetPrivateField(flickeringLetter, "_lightOnColor", ColorLeftLight);
                ReflectionUtil.SetPrivateField(flickeringLetter, "_spriteOnColor", ColorLeftLight * 1.6f);
            }
        }
Exemplo n.º 2
0
        private void setupColors()
        {
            _colorInit = false;

            if (colManager != null)
            {
                ReflectionUtil.SetPrivateField(colManager, "_colorA", _colorLeft);
                ReflectionUtil.SetPrivateField(colManager, "_colorB", _colorRight);
            }

            foreach (SimpleColorSO colorSO in colorSOs)
            {
                var oldCol = ReflectionUtil.GetPrivateField <Color>(colorSO, "_color");
                if (oldCol.r == 1.0f)
                {
                    ReflectionUtil.SetPrivateField(colorSO, "_color", _colorLeft);
                }
                else
                {
                    ReflectionUtil.SetPrivateField(colorSO, "_color", _colorRight);
                }
            }

            var _blueSaberMat = source.FirstOrDefault((Material x) => x.name == "BlueSaber");

            _blueSaberMat.SetColor("_Color", _colorRight);
            _blueSaberMat.SetColor("_EmissionColor", _colorRight);
            var _redSaberMat = source.FirstOrDefault((Material x) => x.name == "RedSaber");

            _redSaberMat.SetColor("_Color", _colorLeft);
            _redSaberMat.SetColor("_EmissionColor", _colorLeft);

            foreach (Saber saber in sabers)
            {
                MeshRenderer lineRenderer = saber.gameObject.transform.Find("Handle/Ornament").GetComponent <MeshRenderer>();

                if (saber.saberType == Saber.SaberType.SaberA)
                {
                    lineRenderer.sharedMaterial = _redSaberMat;
                    lineRenderer.material       = _redSaberMat;
                }
                else
                {
                    lineRenderer.sharedMaterial = _blueSaberMat;
                    lineRenderer.material       = _blueSaberMat;
                }
            }
        }
Exemplo n.º 3
0
        public void OnUpdate()
        {
            if (_colorInit && _overrideCustomSabers)
            {
                EnsureCustomSabersOverridden();
            }

            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);

            _protectedScriptableColors.Add(leftColor);
            _protectedScriptableColors.Add(rightColor);
            Log("ColorManager colors set!");


            foreach (var scriptableColor in _scriptableColors.Except(_protectedScriptableColors))
            {
                if (scriptableColor.name.Contains("-CustomColorApplied"))
                {
                    continue;
                }

                scriptableColor.SetColor(scriptableColor.color.r > 0.5 ? _colorLeft : _colorRight);
                scriptableColor.name += "-CustomColorApplied";
                Log($"Scriptable color: {scriptableColor.name}");
            }
            Log("ScriptableColors modified!");


            foreach (var prePassLight in _prePassLights)
            {
                var oldCol = ReflectionUtil.GetPrivateField <Color>(prePassLight, "_color");

                ReflectionUtil.SetPrivateField(prePassLight, "_color", oldCol.r > 0.5 ? _colorLeft : _colorRight);
            }
            Log("PrePassLight colors set!");


            foreach (var light in _environmentLights)
            {
                light.SetColor("_Color", new Color(_colorRight.r * 0.5f, _colorRight.g * 0.5f, _colorRight.b * 0.5f, 1.0f));
            }
            Log("Environment light colors set!");


            if (SceneManager.GetActiveScene().name == "Menu")
            {
                var texts = UnityEngine.Object.FindObjectsOfType <TextMeshPro>();
                foreach (var text in texts)
                {
                    if (text.name.Contains("-CustomColorApplied"))
                    {
                        continue;
                    }

                    var oldCol = ReflectionUtil.GetPrivateField <Color>(text, "m_fontColor");

                    ReflectionUtil.SetPrivateField(text, "m_fontColor", oldCol.r > 0.5 ? _colorLeft : _colorRight);
                    text.name += "-CustomColorApplied";

                    Log($"text: {text.name}");
                }

                var flickeringLetter = UnityEngine.Object.FindObjectOfType <FlickeringNeonSign>();
                if (flickeringLetter != null)
                {
                    ReflectionUtil.SetPrivateField(flickeringLetter, "_onColor", _colorRight);
                }

                Log("Menu colors set!");
            }


            _colorInit = true;
        }
Exemplo n.º 4
0
        public void OnUpdate()
        {
            if (_colorInit == false)
            {
                foreach (XWeaponTrail trail in weapontrails)
                {
                    var oldCol = ReflectionUtil.GetPrivateField <Color>(trail, "MyColor");
                    if (oldCol.r == 1.0f)
                    {
                        ReflectionUtil.SetPrivateField(trail, "MyColor", new Color(_colorLeft.r, _colorLeft.g, _colorLeft.b, oldCol.a));
                    }
                    else
                    {
                        ReflectionUtil.SetPrivateField(trail, "MyColor", new Color(_colorRight.r, _colorRight.g, _colorRight.b, oldCol.a));
                    }
                }

                if (prePassLights.Length > 0)
                {
                    foreach (TubeBloomPrePassLight prePassLight in prePassLights)
                    {
                        var oldCol = ReflectionUtil.GetPrivateField <Color>(prePassLight, "_color");
                        if (oldCol.r == 1.0f)
                        {
                            ReflectionUtil.SetPrivateField(prePassLight, "_color", _colorLeft);
                        }
                        else
                        {
                            ReflectionUtil.SetPrivateField(prePassLight, "_color", _colorRight);
                        }
                    }
                }

                foreach (Material mat in envLights)
                {
                    mat.SetColor("_Color", new Color(_colorRight.r * 0.5f, _colorRight.g * 0.5f, _colorRight.b * 0.5f, 1.0f));
                }

                if (SceneManager.GetActiveScene().name == "Menu")
                {
                    TextMeshPro[] texts = UnityEngine.Object.FindObjectsOfType <TextMeshPro>();
                    if (texts.Length > 0)
                    {
                        foreach (TextMeshPro text in texts)
                        {
                            var oldCol = ReflectionUtil.GetPrivateField <Color>(text, "m_fontColor");
                            if (oldCol.r == 1.0f)
                            {
                                ReflectionUtil.SetPrivateField(text, "m_fontColor", _colorLeft);
                            }
                            else
                            {
                                ReflectionUtil.SetPrivateField(text, "m_fontColor", _colorRight);
                            }
                        }
                    }

                    FlickeringNeonSign E = UnityEngine.Object.FindObjectOfType <FlickeringNeonSign>();
                    if (E != null)
                    {
                        ReflectionUtil.SetPrivateField(E, "_onColor", _colorRight);
                    }
                }

                _colorInit = true;
            }
        }
        public void ApplyColors()
        {
            if (_colorInit && _overrideCustomSabers && safeSaberOverride)
            {
                EnsureCustomSabersOverridden();
            }
            if (SceneManager.GetActiveScene().name == "Menu" && 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 == "Color0")
                        {
                            scriptableColor.SetColor(ColorLeft);
                        }
                        else if (scriptableColor.name == "BaseColor0")
                        {
                            scriptableColor.SetColor(ColorRightLight);
                        }
                        else if (scriptableColor.name == "Color1")
                        {
                            scriptableColor.SetColor(ColorRight);
                        }
                        else if (scriptableColor.name == "BaseColor1")
                        {
                            scriptableColor.SetColor(ColorLeftLight);
                        }
                        else if (scriptableColor.name == "MenuEnvLight0")
                        {
                            scriptableColor.SetColor(ColorRightLight);
                        }

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

                foreach (var prePassLight in _prePassLights)
                {
                    if (prePassLight != null)
                    {
                        if (prePassLight.name.Contains("NeonLight (6)"))
                        {
                            prePassLight.color = ColorLeftLight;
                        }
                        if (prePassLight.name.Contains("NeonLight (8)"))
                        {
                            if (prePassLight.gameObject.transform.position.ToString() == "(0.0, 17.2, 24.8)")
                            {
                                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)
                {
                    if (sprite != null)
                    {
                        if (sprite.name == "LogoSABER")
                        {
                            sprite.color = ColorLeftLight;
                        }
                        if (sprite.name == "LogoBAT" || sprite.name == "LogoE")
                        {
                            sprite.color = ColorRightLight;
                        }
                    }
                }

                if (Plugin.wallColorPreset != 0)
                {
                    coreObstacleMaterials  = Resources.FindObjectsOfTypeAll <Material>().Where(m => m.name == "ObstacleCore" || m.name == "ObstacleCoreInside");
                    frameObstacleMaterials = Resources.FindObjectsOfTypeAll <Material>().Where(m => m.name == "ObstacleFrame");
                    if (gameScene && rainbowWall)
                    {
                        SharedCoroutineStarter.instance.StartCoroutine(RainbowWalls());
                    }
                    else
                    {
                        SetWallColors();
                    }
                }

                //Logo Disable if needed

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

                if (SceneManager.GetActiveScene().name == "Menu")
                {
                    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)
                    {
                        colorsSetter.Awake();
                        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;
            }
        }