Beispiel #1
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;
     }
 }
Beispiel #2
0
        public async void PlatformEnabled(DiContainer container)
        {
            container.Inject(this);
            bool activeSelf = gameObject.activeSelf;

            if (activeSelf)
            {
                gameObject.SetActive(false);
            }

            if (_instancedMaterialLightWithId is null)
            {
                Mesh mesh = GetComponent <MeshFilter>().mesh;
                if (mesh.vertexCount == 0)
                {
                    float y = (0.5f - center) * length * 2;
                    mesh.vertices = new Vector3[]
                    {
                        new(-width, (y - length) / 2, -width),
                        new(width, (y - length) / 2, -width),
                        new(width, (y + length) / 2, -width),
                        new(-width, (y + length) / 2, -width),
                        new(-width, (y + length) / 2, width),
                        new(width, (y + length) / 2, width),
                        new(width, (y - length) / 2, width),
                        new(-width, (y - length) / 2, width)
                    };

                    mesh.triangles = _triangles;
                }

                (_, _, Material opaqueGlowMaterial) = await _materialSwapper !.MaterialsTask;
                Renderer renderer = GetComponent <Renderer>();
                renderer.sharedMaterial = opaqueGlowMaterial;
                MaterialPropertyBlockController materialPropertyBlockController = gameObject.AddComponent <MaterialPropertyBlockController>();
                materialPropertyBlockController.SetField("_renderers", new[] { renderer });
                MaterialPropertyBlockColorSetter materialPropertyBlockColorSetter = gameObject.AddComponent <MaterialPropertyBlockColorSetter>();
                materialPropertyBlockColorSetter.materialPropertyBlockController = materialPropertyBlockController;
                materialPropertyBlockColorSetter.SetField("_property", "_Color");
                _instancedMaterialLightWithId = gameObject.AddComponent <InstancedMaterialLightWithId>();
                _instancedMaterialLightWithId.SetField("_materialPropertyBlockColorSetter", materialPropertyBlockColorSetter);
                _instancedMaterialLightWithId.SetField("_intensity", 1.25f);
                ((LightWithIdMonoBehaviour)_instancedMaterialLightWithId).SetField("_ID", (int)lightsID);
                _instancedMaterialLightWithId.ColorWasSet(color);
                BloomPrePassBackgroundNonLightRenderer bloomPrePassBackgroundNonLightRenderer = gameObject.AddComponent <BloomPrePassBackgroundNonLightRenderer>();
                bloomPrePassBackgroundNonLightRenderer.SetField("_renderer", renderer);
                ((BloomPrePassBackgroundNonLightRendererCore)bloomPrePassBackgroundNonLightRenderer).SetField("_keepDefaultRendering", true);
                ((BloomPrePassNonLightPass)bloomPrePassBackgroundNonLightRenderer).SetField("_executionTimeType", BloomPrePassNonLightPass.ExecutionTimeType.BeforeBlur);
            }

            ((LightWithIdMonoBehaviour)_instancedMaterialLightWithId).SetField("_lightManager", _lightWithIdManager);
            if (activeSelf)
            {
                gameObject.SetActive(true);
            }
        }
        internal void GameAwake(LightWithIdManager lightManager)
        {
            GetComponent <MeshRenderer>().enabled = false;
            if (GetComponent <MeshFilter>().mesh.vertexCount == 0)
            {
                tubeBloomLight = Instantiate(PlatformManager.LightSource.GetComponent <TubeBloomPrePassLight>());
                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>();
                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
            {
                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;
                materialPropertyBlockColorSetter     = iHeartBeatSaber.GetComponent <MaterialPropertyBlockColorSetter>();
                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);
            }
        }