Example #1
0
        public void PlatformEnabled(DiContainer container)
        {
            container.Inject(this);
            bool activeSelf = gameObject.activeSelf;

            gameObject.SetActive(false);

            if (_instancedMaterialLightWithId is null && _tubeBloomPrePassLightWithId is null)
            {
                Mesh mesh = GetComponent <MeshFilter>().mesh;
                if (mesh.vertexCount == 0)
                {
                    _tubeBloomPrePassLightWithId = gameObject.AddComponent <TubeBloomPrePassLightWithId>();
                    TubeBloomPrePassLight tubeBloomPrePassLight = gameObject.AddComponent <TubeBloomPrePassLight>();
                    GameObject            boxLight = new("BoxLight");
                    boxLight.SetActive(false);
                    Transform boxLightTransform = boxLight.transform;
                    boxLightTransform.transform.SetParent(transform);
                    boxLightTransform.transform.localRotation = Quaternion.Euler(Vector3.zero);
                    MeshFilter meshFilter = boxLight.AddComponent <MeshFilter>();
                    meshFilter.mesh = Mesh;
                    MeshRenderer renderer = boxLight.AddComponent <MeshRenderer>();
                    renderer.sharedMaterial = _materialSwapper !.TransparentGlowMaterial;
                    ParametricBoxController parametricBoxController = boxLight.AddComponent <ParametricBoxController>();
                    _meshRendererAccessor(ref parametricBoxController)               = renderer;
                    _centerAccessor(ref tubeBloomPrePassLight)                       = center;
                    _parametricBoxControllerAccessor(ref tubeBloomPrePassLight)      = parametricBoxController;
                    _mainEffectPostProcessEnabledAccessor(ref tubeBloomPrePassLight) = _postProcessEnabled;
                    tubeBloomPrePassLight.width  = width * 2;
                    tubeBloomPrePassLight.length = length;
                    tubeBloomPrePassLight.bloomFogIntensityMultiplier = bloomFogIntensityMultiplier;
                    _tubeBloomPrePassLightAccessor(ref _tubeBloomPrePassLightWithId) = tubeBloomPrePassLight;
                    BloomPrePassLight bloomPrePassLight = tubeBloomPrePassLight;
                    _lightTypeAccessor(ref bloomPrePassLight) = BloomPrePassLight.bloomLightsDict.Keys.First(static x => x.name == "AddBloomPrePassLightType");
Example #2
0
        private void UpdateSaberColor(SaberModelController saberModel, Color color)
        {
            SetSaberGlowColor[]     glowColors     = Helper.GetValue <SetSaberGlowColor[]>(saberModel, "_setSaberGlowColors");
            SetSaberFakeGlowColor[] fakeGlowColors = Helper.GetValue <SetSaberFakeGlowColor[]>(saberModel, "_setSaberFakeGlowColors");

            Color      trailTintColor = Helper.GetValue <SaberModelController.InitData>(saberModel, "_initData").trailTintColor;
            SaberTrail trail          = Helper.GetValue <SaberTrail>(saberModel, "_saberTrail");

            Helper.SetValue <Color>(trail, "_color", (color * trailTintColor).linear);

            TubeBloomPrePassLight light = Helper.GetValue <TubeBloomPrePassLight>(saberModel, "_saberLight");

            if (light != null)
            {
                light.color = color;
            }

            foreach (SetSaberGlowColor glowColor in glowColors)
            {
                glowColor.SetColors();
            }

            foreach (SetSaberFakeGlowColor fakeGlowColor in fakeGlowColors)
            {
                fakeGlowColor.SetColors();
            }
        }
Example #3
0
        IEnumerator <WaitForEndOfFrame> KerFuffel(TubeBloomPrePassLight tubeBloomLight)
        {
            yield return(new WaitForEndOfFrame());

            tubeBloomLight.color = Color.black.ColorWithAlpha(0);
            tubeBloomLight.Refresh();
        }
Example #4
0
        internal void GameAwake(LightWithIdManager lightManager)
        {
            GetComponent <MeshRenderer>().enabled = false;
            if (GetComponent <MeshFilter>().mesh.vertexCount == 0)
            {
                tubeBloomLight = Instantiate(Prefab);
                tubeBloomLight.transform.parent = transform;
                PlatformManager.SpawnedObjects.Add(tubeBloomLight.gameObject);

                tubeBloomLight.transform.localRotation = Quaternion.identity;
                tubeBloomLight.transform.localPosition = Vector3.zero;
                tubeBloomLight.transform.localScale    = new Vector3(1 / transform.lossyScale.x, 1 / transform.lossyScale.y, 1 / transform.lossyScale.z);

                tubeBloomLight.gameObject.SetActive(false);

                TubeBloomPrePassLightWithId lightWithId = tubeBloomLight.GetComponent <TubeBloomPrePassLightWithId>();
                if (lightWithId)
                {
                    lightWithId.SetField("_tubeBloomPrePassLight", tubeBloomLight);
                    ((LightWithIdMonoBehaviour)lightWithId).SetField("_ID", (int)lightsID);
                    ((LightWithIdMonoBehaviour)lightWithId).SetField("_lightManager", lightManager);
                }

                tubeBloomLight.SetField("_width", width * 2);
                tubeBloomLight.SetField("_length", length);
                tubeBloomLight.SetField("_center", center);
                tubeBloomLight.SetField("_transform", tubeBloomLight.transform);
                tubeBloomLight.SetField("_maxAlpha", 0.1f);
                tubeBloomLight.SetField("_bloomFogIntensityMultiplier", fogIntensityMultiplier);

                ParametricBoxController parabox = tubeBloomLight.GetComponentInChildren <ParametricBoxController>();
                tubeBloomLight.SetField("_parametricBoxController", parabox);

                Parametric3SliceSpriteController parasprite = tubeBloomLight.GetComponentInChildren <Parametric3SliceSpriteController>();
                tubeBloomLight.SetField("_dynamic3SliceSprite", parasprite);
                parasprite.Init();
                parasprite.GetComponent <MeshRenderer>().enabled = false;

                SetColorToDefault();
                tubeBloomLight.gameObject.SetActive(true);
            }
            else
            {
                // swap for <3
                PlatformManager.InactiveHeart.SetActive(false);
                iHeartBeatSaber = Instantiate(PlatformManager.InactiveHeart);
                PlatformManager.SpawnedObjects.Add(iHeartBeatSaber);
                iHeartBeatSaber.transform.parent     = transform;
                iHeartBeatSaber.transform.position   = transform.position;
                iHeartBeatSaber.transform.localScale = Vector3.one;
                iHeartBeatSaber.transform.rotation   = transform.rotation;
                InstancedMaterialLightWithId lightWithId = iHeartBeatSaber.GetComponent <InstancedMaterialLightWithId>();
                ((LightWithIdMonoBehaviour)lightWithId).SetField("_ID", (int)lightsID);
                ((LightWithIdMonoBehaviour)lightWithId).SetField("_lightManager", lightManager);
                lightWithId.SetField("_minAlpha", 0f);
                iHeartBeatSaber.GetComponent <MeshFilter>().mesh = GetComponent <MeshFilter>().mesh;
                iHeartBeatSaber.SetActive(true);
            }
        }
Example #5
0
        private void Awake()
        {
            var prefab = Resources.FindObjectsOfTypeAll <TubeBloomPrePassLight>().First(x => x.name == "Neon");

            TubeLight[] localDescriptors = GetComponentsInChildren <TubeLight>(true);

            if (localDescriptors == null)
            {
                return;
            }

            TubeLight tl = this;

            tubeBloomLight = Instantiate(prefab);
            tubeBloomLight.transform.SetParent(tl.transform);
            tubeBloomLight.transform.localRotation = Quaternion.identity;
            tubeBloomLight.transform.localPosition = Vector3.zero;
            tubeBloomLight.transform.localScale    = new Vector3(1 / tl.transform.lossyScale.x, 1 / tl.transform.lossyScale.y, 1 / tl.transform.lossyScale.z);

            if (tl.GetComponent <MeshFilter>().mesh.vertexCount == 0)
            {
                tl.GetComponent <MeshRenderer>().enabled = false;
            }
            else
            {
                // swap for MeshBloomPrePassLight
                tubeBloomLight.gameObject.SetActive(false);
                MeshBloomPrePassLight meshbloom = ReflectionUtil.CopyComponent(tubeBloomLight, typeof(TubeBloomPrePassLight), typeof(MeshBloomPrePassLight), tubeBloomLight.gameObject) as MeshBloomPrePassLight;
                meshbloom.Init(tl.GetComponent <Renderer>());
                tubeBloomLight.gameObject.SetActive(true);
                Destroy(tubeBloomLight);
                tubeBloomLight = meshbloom;
            }

            tubeBloomLight.SetPrivateField("_width", tl.width * 2);
            tubeBloomLight.SetPrivateField("_length", tl.length);
            tubeBloomLight.SetPrivateField("_center", tl.center);
            tubeBloomLight.SetPrivateField("_transform", tubeBloomLight.transform);
            var parabox = tubeBloomLight.GetComponentInChildren <ParametricBoxController>();

            tubeBloomLight.SetPrivateField("_parametricBoxController", parabox);
            var parasprite = tubeBloomLight.GetComponentInChildren <Parametric3SliceSpriteController>();

            tubeBloomLight.SetPrivateField("_dynamic3SliceSprite", parasprite);
            parasprite.Init();
            parasprite.GetComponent <MeshRenderer>().enabled = false;

            tubeBloomLight.color = tl.color * 0.9f;

            var prop = typeof(BSLight).GetField("_ID", BindingFlags.NonPublic | BindingFlags.Instance);

            prop.SetValue(tubeBloomLight, (int)tl.lightsID);

            //tubeBloomLight.InvokePrivateMethod("OnDisable", new object[0]);
            tubeBloomLight.Refresh();
            TubeLightManager.UpdateEventTubeLightList();
        }
 public static AmbientLightColourHolder GetTubeLightColourHolder(TubeBloomPrePassLight light)
 {
     if (tubeLightOriginals.TryGetValue(light, out AmbientLightColourHolder holder))
     {
         return(holder);
     }
     else
     {
         return(new AmbientLightColourHolder(light));
     }
 }
Example #7
0
            private BSMColorManager(SaberModelController bsm, SaberType saberType)
            {
                _bsm       = bsm;
                _saberType = saberType;

                _saberWeaponTrail       = _saberWeaponTrailAccessor(ref _bsm);
                _trailTintColor         = _initDataAccessor(ref _bsm).trailTintColor;
                _setSaberGlowColors     = _setSaberGlowColorsAccessor(ref _bsm);
                _setSaberFakeGlowColors = _SetSaberFakeGlowAccessor(ref _bsm);
                _saberLight             = _saberLightAccessor(ref _bsm);
            }
Example #8
0
 public static void HandleLightEvent(TubeBloomPrePassLight light, LightArrangement arr)
 {
     if (playerLaserErr)
     {
         return;
     }
     try
     {
         light.gameObject.SetActive(arr.enabled);
         light.enabled = arr.enabled;
         light.color   = arr.color;
     }
     catch (Exception e)
     {
         Plugin.Log.Critical("Laser error: " + e.Message);
     }
 }
Example #9
0
        private void SetColorToDefault()
        {
            tubeLightDescriptors = GameObject.FindObjectsOfType <TubeLight>().ToList();

            foreach (TubeLight tl in tubeLightDescriptors)
            {
                TubeBloomPrePassLight tube = tl.gameObject.GetComponent <TubeBloomPrePassLight>();
                if (tube != null)
                {
                    tube.color = tl.color;
                }

                MeshBloomPrePassLight mesh = tl.gameObject.GetComponent <MeshBloomPrePassLight>();
                if (mesh != null)
                {
                    mesh.color = tl.color;
                }
            }
        }
Example #10
0
 public static void HandleCPLightEvent(TubeBloomPrePassLight light, LightArrangement arr)
 {
     try
     {
         light.enabled = arr.enabled;
         if (arr.enabled)
         {
             light.gameObject.SetActive(arr.enabled);
             light.color = arr.color;
         }
         else
         {
             light.color = cpOffColour;
         }
     }
     catch (Exception e)
     {
         Plugin.Log.Critical("CP Laser error: " + e.Message);
     }
 }
Example #11
0
        internal static IEnumerator ChangeColorCoroutine(Saber saber, Color color, float time = 0.05f)
        {
            if (time != 0)
            {
                yield return(new WaitForSeconds(time));
            }
            SaberModelController modelController = saber.gameObject.GetComponentInChildren <SaberModelController>(true);

            if (modelController is IColorable colorable)
            {
                colorable.SetColor(color);
            }
            if (modelController is SaberModelController smc)
            {
                Color tintColor = Accessors.ModelInitData(ref smc).trailTintColor;
                SetSaberGlowColor[]     setSaberGlowColors     = Accessors.SaberGlowColor(ref smc);
                SetSaberFakeGlowColor[] setSaberFakeGlowColors = Accessors.FakeSaberGlowColor(ref smc);
                TubeBloomPrePassLight   light = Accessors.SaberLight(ref smc);
                saber.ChangeColor(color, smc, tintColor, setSaberGlowColors, setSaberFakeGlowColors, light);
            }
        }
            public AmbientLightColourHolder(TubeBloomPrePassLight light)
            {
                this.light = light;

                fieldColour = light.GetField <Color>("_color");
                color       = light.color;

                Renderer[] rends = light.GetComponentsInChildren <Renderer>();
                foreach (Renderer rend in rends)
                {
                    if (rend.materials.Length > 0)
                    {
                        if (rend.material.shader.name == "Custom/ParametricBox" || rend.material.shader.name == "Custom/ParametricBoxOpaque")
                        {
                            rendColors.Add(rend, rend.material.GetColor("_Color"));
                        }
                    }
                }

                tubeLightOriginals.Add(light, this);
            }
Example #13
0
        private void CreateLights()
        {
            List <ILightWithId>[] lightsWithId = _lightManager.GetPrivateField <List <ILightWithId>[]>("_lights");
            int maxLightId = _lightManager.GetPrivateField <int>("kMaxLightId");

            _lights = new List <DynamicTubeBloomPrePassLight> [maxLightId + 1];

            for (int id = 0; id < lightsWithId.Length; id++)
            {
                if (lightsWithId[id] == null)
                {
                    continue;
                }

                foreach (ILightWithId lightWithId in lightsWithId[id])
                {
                    if (lightWithId is TubeBloomPrePassLightWithId tubeLightWithId)
                    {
                        TubeBloomPrePassLight tubeLight = tubeLightWithId.GetPrivateField <TubeBloomPrePassLight>("_tubeBloomPrePassLight");

                        DynamicTubeBloomPrePassLight light = _container.InstantiateComponent <DynamicTubeBloomPrePassLight>(new GameObject($"DynamicTubeBloomPrePassLight({tubeLight.name})"), new[] { tubeLight });

                        if (_lights[id] == null)
                        {
                            _lights[id] = new List <DynamicTubeBloomPrePassLight>(10);
                        }

                        _lights[id].Add(light);

                        light.transform.parent   = transform;
                        light.transform.position = Vector3.zero;
                        light.transform.rotation = Quaternion.identity;
                    }
                }
            }

            _logger.Trace($"Created {_lights.Sum(l => l?.Count)} DynamicTubeBloomPrePassLights");
        }
        public static void ApplyColour(this TubeBloomPrePassLight light, Color color)
        {
            AmbientLightColourHolder holder = AmbientLightColourHolder.GetTubeLightColourHolder(light);

            holder.ApplyColour(color);
        }
        public static void Reset(this TubeBloomPrePassLight light)
        {
            AmbientLightColourHolder holder = AmbientLightColourHolder.GetTubeLightColourHolder(light);

            holder.ResetColour();
        }
Example #16
0
        /// <summary>
        /// Change the color of a saber.
        /// </summary>
        /// <param name="_">The saber.</param>
        /// <param name="color">The color to change the saber to.</param>
        /// <param name="smc">The model controller of the saber.</param>
        /// <param name="tintColor">The tint color of the new color.</param>
        /// <param name="setSaberGlowColors">The glow color groups of the saber.</param>
        /// <param name="setSaberFakeGlowColors">The fake glow color groups of the saber.</param>
        /// <param name="light">The light of the saber.</param>
        public static void ChangeColor(this Saber _, Color color, SaberModelController smc, Color tintColor, SetSaberGlowColor[] setSaberGlowColors, SetSaberFakeGlowColor[] setSaberFakeGlowColors, TubeBloomPrePassLight light)
        {
            Accessors.TrailColor(ref Accessors.SaberTrail(ref smc)) = (color * tintColor).linear;

            for (int i = 0; i < setSaberGlowColors.Length; i++)
            {
                setSaberGlowColors[i].OverrideColor(color);
            }
            for (int i = 0; i < setSaberFakeGlowColors.Length; i++)
            {
                setSaberFakeGlowColors[i].OverrideColor(color);
            }
            if (light != null)
            {
                light.color = color;
            }
        }
Example #17
0
        internal void GameAwake()
        {
            GetComponent <MeshRenderer>().enabled = false;
            if (GetComponent <MeshFilter>().mesh.vertexCount == 0)
            {
                tubeBloomLight = Instantiate(prefab);
                tubeBloomLight.transform.parent = transform;
                PlatformManager.SpawnedObjects.Add(tubeBloomLight.gameObject);

                tubeBloomLight.transform.localRotation = Quaternion.identity;
                tubeBloomLight.transform.localPosition = Vector3.zero;
                tubeBloomLight.transform.localScale    = new Vector3(1 / transform.lossyScale.x, 1 / transform.lossyScale.y, 1 / transform.lossyScale.z);

                tubeBloomLight.gameObject.SetActive(false);

                var lightWithId = tubeBloomLight.GetComponent <LightWithId>();
                if (lightWithId)
                {
                    lightWithId.SetPrivateField("_tubeBloomPrePassLight", tubeBloomLight);
                    lightWithId.SetPrivateField("_ID", (int)lightsID);
                    lightWithId.SetPrivateField("_lightManager", PlatformManager.LightManager);
                }
                // i broke it -.-
                //try to fix it, if you can't: roll back
                tubeBloomLight.SetPrivateField("_width", width * 2);
                tubeBloomLight.SetPrivateField("_length", length);
                tubeBloomLight.SetPrivateField("_center", center);
                tubeBloomLight.SetPrivateField("_transform", tubeBloomLight.transform);
                tubeBloomLight.SetPrivateField("_maxAlpha", 0.1f);

                var parabox = tubeBloomLight.GetComponentInChildren <ParametricBoxController>();
                tubeBloomLight.SetPrivateField("_parametricBoxController", parabox);

                var parasprite = tubeBloomLight.GetComponentInChildren <Parametric3SliceSpriteController>();
                tubeBloomLight.SetPrivateField("_dynamic3SliceSprite", parasprite);
                parasprite.Init();
                parasprite.GetComponent <MeshRenderer>().enabled = false;

                SetColorToDefault();
                tubeBloomLight.gameObject.SetActive(true);
            }
            else
            {
                // swap for <3
                iHeartBeatSaber = Instantiate(PlatformManager.Heart);
                PlatformManager.SpawnedObjects.Add(iHeartBeatSaber);
                iHeartBeatSaber.transform.parent     = transform;
                iHeartBeatSaber.transform.position   = transform.position;
                iHeartBeatSaber.transform.localScale = Vector3.one;
                iHeartBeatSaber.transform.rotation   = transform.rotation;
                var lightWithId = iHeartBeatSaber.GetComponent <LightWithId>();
                if (lightWithId)
                {
                    lightWithId.SetPrivateField("_ID", (int)lightsID);
                    lightWithId.SetPrivateField("_lightManager", PlatformManager.LightManager);
                    lightWithId.SetPrivateField("_minAlpha", 0);
                }
                iHeartBeatSaber.GetComponent <MeshFilter>().mesh = GetComponent <MeshFilter>().mesh;
                iHeartBeatSaber.SetActive(true);
            }
        }
Example #18
0
        public static void LoadLights()
        {
            bool laserNull = false;
            bool ringNull  = false;

            Plugin.Log.Info("Loading lights...");

            try
            {
                lasers     = GameObject.Find("MultiplayerLocalActivePlayerController(Clone)/IsActiveObjects/Lasers");
                ringLights = GameObject.Find("MultiplayerLocalActivePlayerController(Clone)/IsActiveObjects/DirectionalLights");

                // Load the lasers
                if (lasers != null)
                {
                    laserLeft        = lasers.transform.Find("LaserL").gameObject.GetComponent <TubeBloomPrePassLight>();
                    laserRight       = lasers.transform.Find("LaserR").gameObject.GetComponent <TubeBloomPrePassLight>();
                    backLaserLeft    = lasers.transform.Find("LaserFrontL").gameObject.GetComponent <TubeBloomPrePassLight>();
                    backLaserRight   = lasers.transform.Find("LaserFrontR").gameObject.GetComponent <TubeBloomPrePassLight>();
                    behindLaserLeft  = lasers.transform.Find("LaserBackL").gameObject.GetComponent <TubeBloomPrePassLight>();
                    behindLaserRight = lasers.transform.Find("LaserBackR").gameObject.GetComponent <TubeBloomPrePassLight>();
                    farLaserLeft     = lasers.transform.Find("LaserFarL").gameObject.GetComponent <TubeBloomPrePassLight>();
                    farLaserRight    = lasers.transform.Find("LaserFarR").gameObject.GetComponent <TubeBloomPrePassLight>();
                    allLasers        = new List <TubeBloomPrePassLight>()
                    {
                        laserLeft, laserRight, backLaserLeft, backLaserRight, behindLaserLeft, behindLaserRight, farLaserLeft, farLaserRight
                    };

                    foreach (TubeBloomPrePassLight l in allLasers)
                    {
                        LightingController.HandleLightEvent(l, new LightArrangement()
                        {
                            enabled = false, color = null
                        });
                    }
                    playerLaserErr = false;
                }
                else
                {
                    Plugin.Log.Error("Lasers are disabled.");
                    playerLaserErr = true;
                }

                // Loaded the other player's lasers
                connectedPlayerLighting = new List <ConnectedPlayerLighting>();
                var players = Resources.FindObjectsOfTypeAll <GameObject>().Where(obj => obj.name == "MultiplayerConnectedPlayerController(Clone)");
                if (players != null)
                {
                    foreach (GameObject o in players)
                    {
                        ConnectedPlayerLighting l = new ConnectedPlayerLighting();
                        GameObject _lasers        = o.transform.Find("Lasers").gameObject;
                        l.laserLeft          = _lasers.transform.Find("SideLaserL").gameObject.GetComponent <TubeBloomPrePassLight>();
                        l.laserRight         = _lasers.transform.Find("SideLaserR").gameObject.GetComponent <TubeBloomPrePassLight>();
                        l.laserFront         = _lasers.transform.Find("FrontLaserC2").gameObject.GetComponent <TubeBloomPrePassLight>();
                        l.downLaserLeft      = _lasers.transform.Find("FrontLaserL").gameObject.GetComponent <TubeBloomPrePassLight>();
                        l.downLaserRight     = _lasers.transform.Find("FrontLaserR").gameObject.GetComponent <TubeBloomPrePassLight>();
                        l.downLaserConnector = _lasers.transform.Find("FrontLaserC").gameObject.GetComponent <TubeBloomPrePassLight>();
                        l.extendedLaserLeft  = _lasers.transform.Find("ThinLaserL").gameObject.GetComponent <TubeBloomPrePassLight>();
                        l.extendedLaserRight = _lasers.transform.Find("ThinLaserR").gameObject.GetComponent <TubeBloomPrePassLight>();
                        l.AddAllToList();

                        allLasers.AddRange(l.allLasers);
                        connectedPlayerLighting.Add(l);
                        Plugin.Log.Info("Loaded a Connected Player's lights");
                    }
                }

                cpOffColour = GetCSO(new Color(0, 0, 0));
                LightingController.HandleGlobalCPLightEvent(new LightArrangement()
                {
                    enabled = false, color = cpOffColour
                });

                // Load the ring lights
                if (ringLights != null)
                {
                    ringLightBehind = ringLights.transform.Find("DirectionalLight1").gameObject.GetComponent <DirectionalLight>();
                    ringLightFront  = ringLights.transform.Find("DirectionalLight2").gameObject.GetComponent <DirectionalLight>();
                    ringLightLeft   = ringLights.transform.Find("DirectionalLight4").gameObject.GetComponent <DirectionalLight>();
                    ringLightRight  = ringLights.transform.Find("DirectionalLight3").gameObject.GetComponent <DirectionalLight>();
                    allRings        = new List <DirectionalLight>()
                    {
                        ringLightBehind, ringLightFront, ringLightLeft, ringLightRight
                    };

                    foreach (DirectionalLight l in allRings)
                    {
                        LightingController.HandleLightEvent(l, new LightArrangement()
                        {
                            enabled = false, color = null
                        });
                    }
                    ringErr = false;
                }
                else
                {
                    Plugin.Log.Error("Ring Lights are disabled.");
                    ringErr = true;
                }

                Plugin.Log.Info("Lasers: " + (laserNull == true || lasers == null ? "error" : "working"));
                Plugin.Log.Info("Ring Lights: " + (ringNull == true || ringLights == null ? "error" : "working"));
                Plugin.Log.Info("CP Lights: " + (connectedPlayerLighting.Count == 0 ? "none found" : "working (" + connectedPlayerLighting.Count + ")"));

                if (ringErr && playerLaserErr)
                {
                    loadError = true;
                    Plugin.Log.Critical("Both rings and lasers failed to load. Lighting has been disabled.");
                }
                else
                {
                    loadedLights = true;
                }
            } catch (Exception e)
            {
                Plugin.Log.Critical("Error loading lights: " + e.Message);
                loadError = true;
            }
        }
Example #19
0
        public void Initialize()
        {
            var parent     = _flickeringNeonSign.transform.parent.gameObject;
            var renderers  = parent.GetComponentsInChildren <SpriteRenderer>();
            var tubeLights = parent.GetComponentsInChildren <TubeBloomPrePassLight>();

            _eNeon = _flickeringNeonSign.GetField <TubeBloomPrePassLight, FlickeringNeonSign>("_light");
            _eLogo = _flickeringNeonSign.GetField <SpriteRenderer, FlickeringNeonSign>("_flickeringSprite");
            var rootRenderers      = new List <SpriteRenderer>();
            var defaultEnvironment = _menuEnvironmentManager.transform.GetChild(0);

            for (int i = defaultEnvironment.childCount - 1; i >= 0; i--)
            {
                var child    = defaultEnvironment.GetChild(i);
                var renderer = child.GetComponent <SpriteRenderer>();
                if (renderer != null)
                {
                    rootRenderers.Add(renderer);
                }
                if (rootRenderers.Count >= 2)
                {
                    break;
                }
            }
            if (rootRenderers.Count >= 2)
            {
                _beatLine  = rootRenderers[1];
                _saberLine = rootRenderers[0];
            }

            foreach (var renderer in renderers)
            {
                switch (renderer.gameObject.name)
                {
                case "BatLogo":
                    _batLogo = renderer;
                    break;

                case "SaberLogo":
                    _saberLogo = renderer;
                    break;
                }
            }
            foreach (var light in tubeLights)
            {
                switch (light.gameObject.name)
                {
                case "BNeon":
                    _bNeon = light;
                    break;

                case "ANeon":
                    _aNeon = light;
                    break;

                case "TNeon":
                    _tNeon = light;
                    break;

                case "SaberNeon":
                    _saberNeon = light;
                    break;
                }
            }
            if (_config.ColorPairs.TryGetValue("Beat", out Config.ColorPair beatPair) && beatPair.Enabled)
            {
                _batLogo.color = beatPair.Color;
                _eLogo.color   = beatPair.Color;
                _eNeon.color   = beatPair.Color;
                _bNeon.color   = beatPair.Color;
                _aNeon.color   = beatPair.Color;
                _tNeon.color   = beatPair.Color;
                _flickeringNeonSign.SetField("_lightOnColor", beatPair.Color);
                _flickeringNeonSign.SetField("_spriteOnColor", beatPair.Color);
                _beatLine.color = new Color(beatPair.Color.r, beatPair.Color.g, beatPair.Color.b, _beatLine.color.a);
                var pss = _flickeringNeonSign.gameObject.GetComponentsInChildren <ParticleSystem>();
                foreach (var ps in pss)
                {
                    var main = ps.main;
                    main.startColor = beatPair.Color;
                }
            }
            if (_config.ColorPairs.TryGetValue("Saber", out Config.ColorPair saberPair) && saberPair.Enabled)
            {
                _saberLogo.color = saberPair.Color;
                _saberNeon.color = saberPair.Color;
                _saberLine.color = new Color(saberPair.Color.r, saberPair.Color.g, saberPair.Color.b, _saberLine.color.a);
            }
        }
Example #20
0
        private void Awake()
        {
            var prefab = Resources.FindObjectsOfTypeAll <TubeBloomPrePassLight>().First(x => x.name == "Neon");

            TubeLight[] localDescriptors = GetComponentsInChildren <TubeLight>(true);

            if (localDescriptors == null)
            {
                return;
            }

            TubeLight tl = this;

            tubeBloomLight = Instantiate(prefab);
            tubeBloomLight.transform.SetParent(tl.transform);
            tubeBloomLight.transform.localRotation = Quaternion.identity;
            tubeBloomLight.transform.localPosition = Vector3.zero;
            tubeBloomLight.transform.localScale    = new Vector3(1 / tl.transform.lossyScale.x, 1 / tl.transform.lossyScale.y, 1 / tl.transform.lossyScale.z);

            if (tl.GetComponent <MeshFilter>().mesh.vertexCount == 0)
            {
                tl.GetComponent <MeshRenderer>().enabled = false;
            }
            else
            {
                // swap for MeshBloomPrePassLight
                tubeBloomLight.gameObject.SetActive(false);
                MeshBloomPrePassLight meshbloom = ReflectionUtil.CopyComponent(tubeBloomLight, typeof(TubeBloomPrePassLight), typeof(MeshBloomPrePassLight), tubeBloomLight.gameObject) as MeshBloomPrePassLight;
                meshbloom.Init(tl.GetComponent <Renderer>());
                tubeBloomLight.gameObject.SetActive(true);
                DestroyImmediate(tubeBloomLight);
                tubeBloomLight = meshbloom;
            }
            tubeBloomLight.gameObject.SetActive(false);

            var lightWithId = tubeBloomLight.GetComponent <LightWithId>();

            if (lightWithId)
            {
                lightWithId.SetPrivateField("_tubeBloomPrePassLight", tubeBloomLight);
                var runtimeFields = typeof(LightWithId).GetTypeInfo().GetRuntimeFields();
                runtimeFields.First(f => f.Name == "_ID").SetValue(lightWithId, (int)tl.lightsID);
                //var lightManagers = Resources.FindObjectsOfTypeAll<LightWithIdManager>();
                //lightManager = lightManagers.FirstOrDefault();

                runtimeFields.First(f => f.Name == "_lighManager").SetValue(lightWithId, lightManager);
            }

            tubeBloomLight.SetPrivateField("_width", tl.width * 2);
            tubeBloomLight.SetPrivateField("_length", tl.length);
            tubeBloomLight.SetPrivateField("_center", tl.center);
            tubeBloomLight.SetPrivateField("_transform", tubeBloomLight.transform);
            tubeBloomLight.SetPrivateField("_maxAlpha", 0.1f);
            var parabox = tubeBloomLight.GetComponentInChildren <ParametricBoxController>();

            tubeBloomLight.SetPrivateField("_parametricBoxController", parabox);
            var parasprite = tubeBloomLight.GetComponentInChildren <Parametric3SliceSpriteController>();

            tubeBloomLight.SetPrivateField("_dynamic3SliceSprite", parasprite);
            parasprite.Init();
            parasprite.GetComponent <MeshRenderer>().enabled = false;
            tubeBloomLight.color = color * 0.9f;

            tubeBloomLight.gameObject.SetActive(true);
            tubeBloomLight.Refresh();
            //TubeLightManager.UpdateEventTubeLightList();
        }