01.10.2020
+ Time controls (Stopwatch, Timers, Intervals) + Added smmeries to everything in SM.Base ~ Renamed Vectors to CVectors.
This commit is contained in:
parent
7acdba92f8
commit
97e638d9d9
44 changed files with 1092 additions and 289 deletions
48
SMCode/SM.Base/Time/Interval.cs
Normal file
48
SMCode/SM.Base/Time/Interval.cs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
using System;
|
||||
using SM.Base.Contexts;
|
||||
|
||||
namespace SM.Base.Time
|
||||
{
|
||||
/// <summary>
|
||||
/// Performs intervals.
|
||||
/// </summary>
|
||||
public class Interval : Timer
|
||||
{
|
||||
private bool _stop;
|
||||
|
||||
/// <inheritdoc />
|
||||
public Interval(float seconds) : base(seconds)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Interval(TimeSpan timeSpan) : base(timeSpan)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Stopping(UpdateContext context)
|
||||
{
|
||||
TriggerEndAction(context);
|
||||
if (_stop){base.Stop();}
|
||||
else Reset();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This will tell the interval to stop after the next iteration.
|
||||
/// <para>To stop immediately use <see cref="Cancel"/></para>
|
||||
/// </summary>
|
||||
public override void Stop()
|
||||
{
|
||||
_stop = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This will stop the interval immediately.
|
||||
/// </summary>
|
||||
public void Cancel()
|
||||
{
|
||||
base.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue