Core/Common: Add a TimeSpan interface to TimeTrackerSmall

Port From (https://github.com/TrinityCore/TrinityCore/commit/35e0002df3073cf4c3e1dae9fbff73d75ddb5e98)
This commit is contained in:
hondacrx
2022-03-02 13:48:14 -05:00
parent 0576cc0a07
commit 7631b1c387
+18 -2
View File
@@ -346,11 +346,21 @@ public class TimeTrackerSmall
i_expiryTime = expiry;
}
public TimeTrackerSmall(TimeSpan expiry = default)
{
i_expiryTime = (int)expiry.TotalMilliseconds;
}
public void Update(int diff)
{
i_expiryTime -= diff;
}
public void Update(TimeSpan diff)
{
Update((int)diff.TotalMilliseconds);
}
public bool Passed()
{
return i_expiryTime <= 0;
@@ -361,10 +371,16 @@ public class TimeTrackerSmall
i_expiryTime = interval;
}
public int GetExpiry()
public void Reset(TimeSpan expiry)
{
return i_expiryTime;
Reset((int)expiry.TotalMilliseconds);
}
public TimeSpan GetExpiry()
{
return TimeSpan.FromMilliseconds(i_expiryTime);
}
int i_expiryTime;
}