public static bool Prefix(MeshBloomPrePassLight __instance, Color _color)
 {
     __instance.color = _color;
     if (__instance.renderer.material != null)
     {
         __instance.renderer.material.color = _color;
     }
     return(false);
 }
Example #2
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();
        }
Example #3
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;
                }
            }
        }
    public override void ColorWasSet(Color color)
    {
        MeshBloomPrePassLight _tubeBloomPrePassLight = (MeshBloomPrePassLight)ReflectionUtil.GetPrivateField <TubeBloomPrePassLight>(this, "_tubeBloomPrePassLight");

        _tubeBloomPrePassLight.UpdateColor(color);
    }
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);
                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();
        }
Example #6
0
        public static void SetupTubeLight(TubeLight tl, DiContainer _container)
        {
            var prefab = Resources.FindObjectsOfTypeAll <TubeBloomPrePassLight>().First(x => x.name == "Neon");

            // Don't init twice
            if (tl.tubeBloomLight != null)
            {
                return;
            }

            var tubeBloomLight = _container.InstantiatePrefabForComponent <TubeBloomPrePassLight>(prefab);

            tubeBloomLight.name = "Tube Light " + z++;

            tl.tubeBloomLight = tubeBloomLight;
            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);

            var withId = tubeBloomLight.GetComponent <TubeBloomPrePassLightWithId>();

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

                MeshBloomPrePassLightWithId meshbloomid = ReflectionUtil.CopyComponent(withId, typeof(TubeBloomPrePassLightWithId), typeof(MeshBloomPrePassLightWithId), withId.gameObject) as MeshBloomPrePassLightWithId;
                Destroy(withId);
                withId = meshbloomid;

                tubeBloomLight.gameObject.SetActive(true);
                Destroy(tubeBloomLight);

                tubeBloomLight = meshbloom;
            }

            var setColorToDefault = Bind(SetColorToDefault, tl, withId);

            tl.onEnable += () => {
                BSEvents.menuSceneLoaded      += setColorToDefault;
                BSEvents.menuSceneLoadedFresh += setColorToDefault;
                setColorToDefault();
            };

            tl.onDisable += () => {
                BSEvents.menuSceneLoaded      -= setColorToDefault;
                BSEvents.menuSceneLoadedFresh -= setColorToDefault;
            };

            var lightType = tubeBloomLight.GetPrivateField <BloomPrePassLightTypeSO>("_lightType", typeof(BloomPrePassLight));

            //tubeBloomLight.SetPrivateField("_lightType", lightType, typeof(BloomPrePassLight));
            tubeBloomLight.SetPrivateField("_registeredWithLightType", lightType, typeof(BloomPrePassLight));

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

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

            tubeBloomLight.SetPrivateField("_dynamic3SliceSprite", parasprite);

            parasprite.InvokeMethod("Init");
            parasprite.GetComponent <MeshRenderer>().enabled = false;

            ReflectionUtil.SetPrivateField(withId, "_tubeBloomPrePassLight", tubeBloomLight);
            ReflectionUtil.SetPrivateField(withId, "_ID", (int)tl.lightsID, typeof(LightWithId));
            withId.SetPrivateField("_lightManager", defaultLightWithIdManager, typeof(LightWithId));

            tubeBloomLight.InvokeMethod("Refresh");
        }