Improved naming and documentation
This commit is contained in:
parent
c60b15dc51
commit
927d835d2e
@ -12,32 +12,38 @@ namespace NEG.Utils.Timing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds time int this TimeMachine
|
||||
/// Adds time into the TimeMachine
|
||||
/// </summary>
|
||||
/// <param name="time">Amount of time to be added</param>
|
||||
public void Forward(double time)
|
||||
public void Accumulate(double time)
|
||||
{
|
||||
this.time += time;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decreeses the amount of time in this TimeMashine by up to given amount
|
||||
/// Retrieves given amount of time from the TimeMachine
|
||||
/// </summary>
|
||||
/// <param name="maxTime"></param>
|
||||
/// <returns>Amount of time decressed</returns>
|
||||
public double Warp(double maxTime)
|
||||
/// <returns>Amount of time retrievend</returns>
|
||||
public double Retrieve(double maxTime)
|
||||
{
|
||||
if(!Double.IsFinite(maxTime))
|
||||
{
|
||||
double timeRetrieved = time;
|
||||
time = 0;
|
||||
return timeRetrieved;
|
||||
}
|
||||
double timeLeft = time - maxTime;
|
||||
time = Math.Max(timeLeft, 0);
|
||||
return Math.Min(maxTime + timeLeft, maxTime);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to decrese the amount of time in this TimeMachine <br/>
|
||||
/// If there is at least <paramref name="time"/> time accumulated in this machine subtructs that amount and returns true, otherwise returns false
|
||||
/// Attempts to retrieves given amount of time from the TimeMachine <br/>
|
||||
/// If there is enough <paramref name="time"/> accumulated in this machine subtructs that amount and returns true, otherwise returns false
|
||||
/// </summary>
|
||||
/// <param name="time"></param>
|
||||
public bool TryWarp(double time)
|
||||
public bool TryRetrieve(double time)
|
||||
{
|
||||
if (this.time >= time)
|
||||
{
|
||||
@ -48,12 +54,12 @@ namespace NEG.Utils.Timing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Result is equivalent to calling <see cref="TryWarp(double)"/> as many times as possible, but is faster fo larger <paramref name="limit"/> values
|
||||
/// Result is equivalent to calling <see cref="TryRetrieve(double)"/> as many times as possible, but is faster for larger <paramref name="limit"/> values
|
||||
/// </summary>
|
||||
/// <param name="interval">Single unit of warp time, must be non negative/param>
|
||||
/// <param name="limit">Maximum amount of warps, must be non negative</param>
|
||||
/// <param name="interval">Single unit of warp time, must be positive/param>
|
||||
/// <param name="limit">Maximum amount of warps, must be positive</param>
|
||||
/// <returns>Amount of warps</returns>
|
||||
public int MultiWarp(double interval, int limit = int.MaxValue)
|
||||
public int RetrieveAll(double interval, int limit = int.MaxValue)
|
||||
{
|
||||
int result = (int)Math.Floor(time / interval);
|
||||
result = Math.Clamp(result, 0, limit);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user