RiftMayhem/Assets/Scripts/Networking/NetworkedAreaOfEffectWithImpactEvent.cs
2025-02-21 18:35:51 +00:00

48 lines
1.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class NetworkedAreaOfEffectWithImpactEvent : NetworkedAreaOfEffect
{
public float impactDelay;
public UnityEvent<Taggable, List<Taggable>> onImpactHappened = new UnityEvent<Taggable, List<Taggable>>();
protected override void Awake()
{
base.Awake();
}
public override void Init()
{
StartCoroutine(ApplyTelegraphDelay(impactDelay));
}
protected override IEnumerator ApplyTelegraphDelay(float delay)
{
effectVisual.SetActive(true);
yield return new WaitForSeconds(impactDelay);
CheckSurroundings();
}
protected override void ApplyArea()
{
}
protected override void CheckSurroundings()
{
base.CheckSurroundings(); //TODO: spread the total value over ticks, for now just apply the instant effect every tick, manage tick values on effect applied
onImpactHappened.Invoke(ownerTag, targets);
StartCoroutine(SelfDestruct());
}
}