smrendererv3/SMCode/SM.Base/Time/Stopwatch.cs
Michel Fedde 03b3942732 Holidays 12.10. -> 25.10.2020
~ Moved code around in files.

SM.Base:
+ PostProcessing-system
+ OnInitialization() for Scenes.
+ Shader-Extensions
+ Added option to not react while unfocused to the window.
+ Added Screenshots to the window.
+ Connected the log system to the SM.OGL-action system.

~ Replaced IShader with abstract MaterialShader.
~ When a log compression folder doesn't exist, it will create one.

SM.OGL:
+ Added support for UniformArrays
+ Added ShaderPreProcessing
+ Added Shader Extensions.
+ Added Debug actions.
+ SM.OGL settings

~ Framebuffer Size is automaticly changed, when the window and scale is set.

SM2D:
+ Added easy shader drawing.
2020-10-24 15:10:36 +02:00

60 lines
No EOL
1.4 KiB
C#

#region usings
using System.Collections.Generic;
using SM.Base.Contexts;
#endregion
namespace SM.Base.Time
{
/// <summary>
/// Represents a stopwatch.
/// </summary>
public class Stopwatch
{
private static List<Stopwatch> _activeStopwatches = new List<Stopwatch>();
/// <summary>
/// Contains how much time already has passed. (in seconds)
/// </summary>
public float Elapsed { get; private set; }
/// <summary>
/// Starts the stopwatch.
/// </summary>
public virtual void Start()
{
_activeStopwatches.Add(this);
}
/// <summary>
/// Performs a tick.
/// </summary>
/// <param name="context"></param>
private protected virtual void Tick(UpdateContext context)
{
Elapsed += context.Deltatime;
}
/// <summary>
/// Stops the stopwatch.
/// </summary>
public virtual void Stop()
{
_activeStopwatches.Remove(this);
}
/// <summary>
/// Resets the stopwatch.
/// </summary>
public void Reset()
{
Elapsed = 0;
}
internal static void PerformTicks(UpdateContext context)
{
for (var i = 0; i < _activeStopwatches.Count; i++) _activeStopwatches[i].Tick(context);
}
}
}