public void CreateTrackRings(GameObject go)
        {
            if (rotationSpawners == null)
            {
                rotationSpawners = new List <TrackLaneRingsRotationEffectSpawner>();
            }
            if (stepSpawners == null)
            {
                stepSpawners = new List <TrackLaneRingsPositionStepEffectSpawner>();
            }
            if (trackLaneRingsManagers == null)
            {
                trackLaneRingsManagers = new List <TrackLaneRingsManager>();
            }
            if (trackRingsDescriptors == null)
            {
                trackRingsDescriptors = new List <TrackRings>();
            }

            TrackRings[] ringsDescriptors = go.GetComponentsInChildren <TrackRings>();

            foreach (TrackRings trackRingDesc in ringsDescriptors)
            {
                trackRingsDescriptors.Add(trackRingDesc);

                TrackLaneRingsManager ringsManager =
                    trackRingDesc.gameObject.AddComponent <TrackLaneRingsManager>();
                trackLaneRingsManagers.Add(ringsManager);

                TrackLaneRing ring = trackRingDesc.trackLaneRingPrefab.AddComponent <TrackLaneRing>();

                ReflectionUtil.SetPrivateField(ringsManager, "_trackLaneRingPrefab", ring);
                ReflectionUtil.SetPrivateField(ringsManager, "_ringCount", trackRingDesc.ringCount);
                ReflectionUtil.SetPrivateField(ringsManager, "_ringPositionStep", trackRingDesc.ringPositionStep);

                if (trackRingDesc.useRotationEffect)
                {
                    TrackLaneRingsRotationEffect rotationEffect =
                        trackRingDesc.gameObject.AddComponent <TrackLaneRingsRotationEffect>();

                    ReflectionUtil.SetPrivateField(rotationEffect, "_trackLaneRingsManager", ringsManager);
                    ReflectionUtil.SetPrivateField(rotationEffect, "_startupRotationAngle", trackRingDesc.startupRotationAngle);
                    ReflectionUtil.SetPrivateField(rotationEffect, "_startupRotationStep", trackRingDesc.startupRotationStep);
                    ReflectionUtil.SetPrivateField(rotationEffect, "_startupRotationPropagationSpeed", trackRingDesc.startupRotationPropagationSpeed);
                    ReflectionUtil.SetPrivateField(rotationEffect, "_startupRotationFlexySpeed", trackRingDesc.startupRotationFlexySpeed);

                    TrackLaneRingsRotationEffectSpawner rotationEffectSpawner =
                        trackRingDesc.gameObject.AddComponent <TrackLaneRingsRotationEffectSpawner>();
                    rotationSpawners.Add(rotationEffectSpawner);

                    ReflectionUtil.SetPrivateField(rotationEffectSpawner, "_beatmapEventType", (BeatmapEventType)trackRingDesc.rotationSongEventType);
                    ReflectionUtil.SetPrivateField(rotationEffectSpawner, "_rotationStep", trackRingDesc.rotationStep);
                    ReflectionUtil.SetPrivateField(rotationEffectSpawner, "_rotationPropagationSpeed", trackRingDesc.rotationPropagationSpeed);
                    ReflectionUtil.SetPrivateField(rotationEffectSpawner, "_rotationFlexySpeed", trackRingDesc.rotationFlexySpeed);
                    ReflectionUtil.SetPrivateField(rotationEffectSpawner, "_trackLaneRingsRotationEffect", rotationEffect);
                }
                if (trackRingDesc.useStepEffect)
                {
                    TrackLaneRingsPositionStepEffectSpawner stepEffectSpawner =
                        trackRingDesc.gameObject.AddComponent <TrackLaneRingsPositionStepEffectSpawner>();
                    stepSpawners.Add(stepEffectSpawner);

                    ReflectionUtil.SetPrivateField(stepEffectSpawner, "_trackLaneRingsManager", ringsManager);
                    ReflectionUtil.SetPrivateField(stepEffectSpawner, "_beatmapEventType", (BeatmapEventType)trackRingDesc.stepSongEventType);
                    ReflectionUtil.SetPrivateField(stepEffectSpawner, "_minPositionStep", trackRingDesc.minPositionStep);
                    ReflectionUtil.SetPrivateField(stepEffectSpawner, "_maxPositionStep", trackRingDesc.maxPositionStep);
                    ReflectionUtil.SetPrivateField(stepEffectSpawner, "_moveSpeed", trackRingDesc.moveSpeed);
                }
            }
        }
Ejemplo n.º 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);
                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();
        }
Ejemplo n.º 3
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");
        }