r2mods/ilspy_dump/ror2_csproj/DestroyOnParticleEnd.cs

39 lines
790 B
C#
Raw Normal View History

2024-10-04 07:26:37 +00:00
using RoR2;
using UnityEngine;
public class DestroyOnParticleEnd : MonoBehaviour
{
[SerializeField]
[Tooltip("Set this if you want to specify which particle system is tracked. Otherwise it will automatically grab the first one it finds.")]
private ParticleSystem trackedParticleSystem;
private EffectManagerHelper efh;
public void Start()
{
if (trackedParticleSystem == null)
{
trackedParticleSystem = GetComponentInChildren<ParticleSystem>();
}
if (!efh)
{
efh = GetComponent<EffectManagerHelper>();
}
}
public void Update()
{
if ((bool)trackedParticleSystem && !trackedParticleSystem.IsAlive())
{
if ((bool)efh && efh.OwningPool != null)
{
efh.OwningPool.ReturnObject(efh);
}
else
{
Object.Destroy(base.gameObject);
}
}
}
}