r2mods/ilspy_dump/ror2_csproj/RoR2.EntityLogic/UpdateEvent.cs

33 lines
683 B
C#
Raw Normal View History

2024-10-04 07:26:37 +00:00
using UnityEngine;
using UnityEngine.Events;
namespace RoR2.EntityLogic;
public class UpdateEvent : MonoBehaviour
{
[Tooltip("Don't call the action until at least this many updates have fired")]
[SerializeField]
private int updateSkipCount;
[Tooltip("Don't call the action after this many updates have fired. If negative, ignore.")]
[SerializeField]
private int maxInvokeCount = -1;
[SerializeField]
private UnityEvent action;
private int invokeCount;
private int updateCount;
private void Update()
{
if (updateSkipCount < updateCount && (maxInvokeCount < 0 || invokeCount < maxInvokeCount))
{
action?.Invoke();
invokeCount++;
}
updateCount++;
}
}