You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
670 B
C#

using System;
using UnityEngine;
namespace Unity.BossRoom.UnityServices
{
public class RateLimitCooldown
{
public float CooldownTimeLength => m_CooldownTimeLength;
readonly float m_CooldownTimeLength;
private float m_CooldownFinishedTime;
public RateLimitCooldown(float cooldownTimeLength)
{
m_CooldownTimeLength = cooldownTimeLength;
m_CooldownFinishedTime = -1f;
}
public bool CanCall => Time.unscaledTime > m_CooldownFinishedTime;
public void PutOnCooldown()
{
m_CooldownFinishedTime = Time.unscaledTime + m_CooldownTimeLength;
}
}
}