Files
UltimateFishing/Assets/Scripts/Assembly-CSharp/twinkle.cs
2026-02-21 16:45:37 +08:00

54 lines
1.2 KiB
C#

using UnityEngine;
public class twinkle : MonoBehaviour
{
private float baseIntensity;
private Light torchLight;
private Renderer fire;
private Material fireSource;
private void Start()
{
Renderer[] componentsInChildren = base.gameObject.GetComponentsInChildren<Renderer>();
Renderer[] array = componentsInChildren;
foreach (Renderer renderer in array)
{
if (renderer.gameObject.name == "fx_fire")
{
fire = renderer;
break;
}
Material[] materials = renderer.materials;
foreach (Material material in materials)
{
if (material.name.StartsWith("mat_torch_01"))
{
fireSource = material;
}
}
}
torchLight = base.gameObject.GetComponentInChildren<Light>();
if ((bool)torchLight && (bool)fire)
{
baseIntensity = torchLight.intensity;
}
}
private void Update()
{
if ((bool)torchLight && (bool)fire)
{
torchLight.transform.position = torchLight.transform.position * 0.7f + fire.bounds.center * 0.3f;
torchLight.intensity = baseIntensity + fire.bounds.size.magnitude;
}
if ((bool)fireSource)
{
float num = 2.3f + fire.bounds.size.magnitude / 3f;
fireSource.SetVector("_EmissionColor", new Vector4(num, num, num, num));
}
}
}