From 927d835d2e367007ab3590af547892758ac6a193 Mon Sep 17 00:00:00 2001 From: LubieKakao1212 Date: Mon, 19 Dec 2022 15:23:50 +0100 Subject: [PATCH] Improved naming and documentation --- Timing/TimeMachine.cs | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/Timing/TimeMachine.cs b/Timing/TimeMachine.cs index e253bdc..9cef9b7 100644 --- a/Timing/TimeMachine.cs +++ b/Timing/TimeMachine.cs @@ -12,32 +12,38 @@ namespace NEG.Utils.Timing } /// - /// Adds time int this TimeMachine + /// Adds time into the TimeMachine /// /// Amount of time to be added - public void Forward(double time) + public void Accumulate(double time) { this.time += time; } /// - /// Decreeses the amount of time in this TimeMashine by up to given amount + /// Retrieves given amount of time from the TimeMachine /// /// - /// Amount of time decressed - public double Warp(double maxTime) + /// Amount of time retrievend + 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); } /// - /// Attempts to decrese the amount of time in this TimeMachine
- /// If there is at least time accumulated in this machine subtructs that amount and returns true, otherwise returns false + /// Attempts to retrieves given amount of time from the TimeMachine
+ /// If there is enough accumulated in this machine subtructs that amount and returns true, otherwise returns false ///
/// - public bool TryWarp(double time) + public bool TryRetrieve(double time) { if (this.time >= time) { @@ -48,12 +54,12 @@ namespace NEG.Utils.Timing } /// - /// Result is equivalent to calling as many times as possible, but is faster fo larger values + /// Result is equivalent to calling as many times as possible, but is faster for larger values /// - /// Single unit of warp time, must be non negative/param> - /// Maximum amount of warps, must be non negative + /// Single unit of warp time, must be positive/param> + /// Maximum amount of warps, must be positive /// Amount of warps - 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);