コード例 #1
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();
        }
コード例 #2
0
        public static void CreateAdditionalLightSwitchControllers()
        {
            var templateSwitchEffect = Resources.FindObjectsOfTypeAll <LightSwitchEventEffect>().FirstOrDefault();

            for (int i = 6; i < 16; i++)
            {
                var newSwitchEffect = ReflectionUtil.CopyComponent(templateSwitchEffect, typeof(LightSwitchEventEffect), typeof(LightSwitchEventEffect), templateSwitchEffect.gameObject) as LightSwitchEventEffect;
                newSwitchEffect.SetPrivateField("_lightsID", i);
                newSwitchEffect.SetPrivateField("_event", (BeatmapEventType)(i - 1));
            }
        }
コード例 #3
0
        /// <summary>
        /// Creates Additional <see cref="LightSwitchEventEffect"/>s<br/>
        /// [May create redundant/duplicate <see cref="LightSwitchEventEffect"/>s!]<br/>
        /// [May cover <see cref="BeatmapEventType"/>s that aren't supposed to be supported anymore!]<br/>
        /// [Possible Semantic Error!]
        /// </summary>
        internal static void CreateAdditionalLightSwitchControllers(LightWithIdManager lightManager)
        {
            LightSwitchEventEffect templateSwitchEffect = Resources.FindObjectsOfTypeAll <LightSwitchEventEffect>().FirstOrDefault();

            for (int i = 6; i < 16; i++)
            {
                //This Component is spawned onto a base game object and not cleaned up by Custom Platforms (in good faith that the game does so for us by unloading the environment scene)
                LightSwitchEventEffect newSwitchEffect = ReflectionUtil.CopyComponent(templateSwitchEffect, typeof(LightSwitchEventEffect), typeof(LightSwitchEventEffect), templateSwitchEffect.gameObject) as LightSwitchEventEffect;
                newSwitchEffect.SetPrivateField("_lightManager", lightManager);
                newSwitchEffect.SetPrivateField("_lightsID", i);
                newSwitchEffect.SetPrivateField("_event", (BeatmapEventType)(i - 1));
            }
        }
コード例 #4
0
        public T AddToggleSetting <T>(string name) where T : SwitchSettingsController
        {
            var        volumeSettings    = Resources.FindObjectsOfTypeAll <WindowModeSettingsController>().FirstOrDefault();
            GameObject newSettingsObject = MonoBehaviour.Instantiate(volumeSettings.gameObject, transform);

            newSettingsObject.name = name;

            WindowModeSettingsController volume = newSettingsObject.GetComponent <WindowModeSettingsController>();
            T newToggleSettingsController       = (T)ReflectionUtil.CopyComponent(volume, typeof(SwitchSettingsController), typeof(T), newSettingsObject);

            MonoBehaviour.DestroyImmediate(volume);

            newSettingsObject.GetComponentInChildren <TMP_Text>().text = name;

            return(newToggleSettingsController);
        }
コード例 #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();
        }
コード例 #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");
        }