Files
Ultimate-Fishing-Simulator-…/Assets/Scripts/Assembly-CSharp/TriggerSplash.cs
2026-03-04 09:37:33 +08:00

36 lines
1.2 KiB
C#

using UnityEngine;
using UnityEngine.VFX;
public class TriggerSplash : MonoBehaviour
{
public GameObject prefab;
private float previousNormalizedHeight = -1f;
private Rigidbody rigibodyComponent;
private void OnEnable()
{
rigibodyComponent = GetComponent<Rigidbody>();
}
private void Update()
{
float normalizedHeightOfSphereBelowSurface = GetComponent<Buoyancy>().GetNormalizedHeightOfSphereBelowSurface();
if (normalizedHeightOfSphereBelowSurface > 0f && previousNormalizedHeight <= 0f && PoolManager.Instances[PoolManager.InstanceType.Splash] != null)
{
GameObject nextAvailable = PoolManager.Instances[PoolManager.InstanceType.Splash].getNextAvailable();
if (nextAvailable != null)
{
nextAvailable.transform.position = GetComponent<Buoyancy>().GetCurrentWaterPosition();
VisualEffect component = nextAvailable.GetComponent<VisualEffect>();
component.SetFloat("Splash Radius", GetComponent<Buoyancy>().sphereRadiusApproximation);
component.SetVector3("Velocity", rigibodyComponent.linearVelocity);
nextAvailable.SetActive(value: true);
component.Play();
}
}
previousNormalizedHeight = normalizedHeightOfSphereBelowSurface;
}
}