DRHPS/code-csharp/en_US/TRIG_PLAYCHATBOX.cs
2025-04-08 11:31:35 +08:00

34 lines
738 B
C#

using System.Collections;
using UnityEngine;
public class TRIG_PLAYCHATBOX : MonoBehaviour
{
[Header("WARNING! This can only run once!")]
public INT_Chat Chat;
public float TriggerDelay;
public bool ChatHasRan;
public bool DestroyOnCollide;
private void OnTriggerEnter2D(Collider2D other)
{
if ((bool)other.GetComponent<PlayerManager>() && !ChatHasRan)
{
ChatHasRan = true;
StartCoroutine(Delay());
}
}
private IEnumerator Delay()
{
yield return new WaitForSeconds(TriggerDelay);
Chat.RUN();
if (DestroyOnCollide)
{
Object.Destroy(base.gameObject);
}
}
}