41 lines
826 B
C#
41 lines
826 B
C#
namespace BITKit
|
|
{
|
|
[System.Serializable]
|
|
public class LimitTimes
|
|
{
|
|
public LimitTimes()
|
|
{
|
|
m_current = max;
|
|
}
|
|
public LimitTimes(int max)
|
|
{
|
|
this.max = max;
|
|
m_current = max;
|
|
}
|
|
public int max = 8;
|
|
int current
|
|
{
|
|
get => m_current;
|
|
set => m_current = value;
|
|
}
|
|
int m_current;
|
|
public void Release()
|
|
{
|
|
current++;
|
|
}
|
|
public bool CanUpdate()
|
|
{
|
|
if (current > 0)
|
|
{
|
|
current--;
|
|
return true;
|
|
}
|
|
else return false;
|
|
}
|
|
public static implicit operator bool(LimitTimes self)
|
|
{
|
|
return self.CanUpdate();
|
|
}
|
|
}
|
|
}
|