Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
0
 public static void Prefix(InstancedMaterialLightWithId __instance, MaterialPropertyBlockColorSetter ____materialPropertyBlockColorSetter, ref Color color)
 {
     if (__instance.gameObject.name == "<3(Clone)")
     {
         color.r *= color.a;
         color.g *= color.a;
         color.b *= color.a;
     }
 }
 public static void Prefix(InstancedMaterialLightWithId __instance, ref UnityEngine.Color newColor)
 {
     if (__instance.gameObject.name == "<3")
     {
         newColor.r = magenta_red;
         newColor.g = magenta_green;
         newColor.b = magenta_blue;
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Steals the heart from the GreenDayScene<br/>
        /// Then De-Serializes the data from the embedded resource heart.mesh onto the GreenDayHeart to make it more visually pleasing<br/>
        /// Also adjusts it position and color.
        /// Now Loads a Light Prefab since the one in the Menu is f****d.
        /// </summary>
        private static void LoadHeartAndLightSource()
        {
            Scene greenDay = SceneManager.LoadScene("GreenDayGrenadeEnvironment", new LoadSceneParameters(LoadSceneMode.Additive));

            SharedCoroutineStarter.instance.StartCoroutine(fuckUnity());
            IEnumerator <WaitUntil> fuckUnity() //did you know loaded scenes are loaded asynchronously, regarless if you use async or not?
            {
                yield return(new WaitUntil(() => { return greenDay.isLoaded; }));

                GameObject root = greenDay.GetRootGameObjects()[0];

                Heart = root.transform.Find("GreenDayCity/armHeartLighting").gameObject;
                Heart.SetActive(false);
                Heart.transform.SetParent(null);
                Heart.name = "<3";
                SceneManager.MoveGameObjectToScene(Heart, SCENE);

                LightSource = root.transform.Find("GlowLineL (2)").gameObject;
                LightSource.SetActive(false);
                LightSource.transform.SetParent(null);
                LightSource.name = "LightSource";
                SceneManager.MoveGameObjectToScene(LightSource, SCENE);
                SceneManager.UnloadSceneAsync("GreenDayGrenadeEnvironment");

                Settings.ShowHeartChanged += Heart.SetActive;

                using Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("CustomFloorPlugin.heart.mesh");
                using StreamReader streamReader     = new StreamReader(manifestResourceStream);

                string meshfile = streamReader.ReadToEnd();

                string[]   dimension1      = meshfile.Split('|');
                string[][] dimension2      = new string[][] { dimension1[0].Split('/'), dimension1[1].Split('/') };
                string[][] string_vector3s = new string[dimension2[0].Length][];

                int i = 0;

                foreach (string string_vector3 in dimension2[0])
                {
                    string_vector3s[i++] = string_vector3.Split(',');
                }

                List <Vector3> vertices  = new List <Vector3>();
                List <int>     triangles = new List <int>();

                foreach (string[] string_vector3 in string_vector3s)
                {
                    vertices.Add(new Vector3(float.Parse(string_vector3[0], NUM_INV), float.Parse(string_vector3[1], NUM_INV), float.Parse(string_vector3[2], NUM_INV)));
                }
                foreach (string s_int in dimension2[1])
                {
                    triangles.Add(int.Parse(s_int, NUM_INV));
                }

                Mesh mesh = new Mesh {
                    vertices  = vertices.ToArray(),
                    triangles = triangles.ToArray()
                };
                Vector3    position = new Vector3(-8f, 25f, 26f);
                Quaternion rotation = Quaternion.Euler(-100f, 90f, 90f);
                Vector3    scale    = new Vector3(25f, 25f, 25f);

                Heart.GetComponent <MeshFilter>().mesh = mesh;
                Heart.transform.position   = position;
                Heart.transform.rotation   = rotation;
                Heart.transform.localScale = scale;

                LightWithIdManager           manager     = FindLightWithIdManager(GetCurrentEnvironment());
                InstancedMaterialLightWithId lightWithId = Heart.GetComponent <InstancedMaterialLightWithId>();

                typeof(LightWithIdMonoBehaviour).GetField("_lightManager", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(lightWithId, manager);

                Heart.SetActive(Settings.ShowHeart);
                Heart.GetComponent <InstancedMaterialLightWithId>().ColorWasSet(Color.magenta);
            }
        }