50 lines
1.1 KiB
C#
50 lines
1.1 KiB
C#
|
|
namespace OECS;
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// Describes the kind of tick being processed.
|
||
|
|
/// </summary>
|
||
|
|
public enum TickType
|
||
|
|
{
|
||
|
|
/// <summary>
|
||
|
|
/// A timed tick, carrying a delta time (e.g., frame-based update).
|
||
|
|
/// </summary>
|
||
|
|
Timed,
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// A logical tick, carrying no delta time (e.g., fixed-step simulation).
|
||
|
|
/// </summary>
|
||
|
|
Logical
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// Data passed to systems during a tick.
|
||
|
|
/// </summary>
|
||
|
|
public readonly struct Tick
|
||
|
|
{
|
||
|
|
/// <summary>
|
||
|
|
/// The kind of tick.
|
||
|
|
/// </summary>
|
||
|
|
public TickType Type { get; }
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// The elapsed time since the last tick, in seconds.
|
||
|
|
/// Always 0 for logical ticks.
|
||
|
|
/// </summary>
|
||
|
|
public float DeltaTime { get; }
|
||
|
|
|
||
|
|
private Tick(TickType type, float deltaTime)
|
||
|
|
{
|
||
|
|
Type = type;
|
||
|
|
DeltaTime = deltaTime;
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// Creates a timed tick with the given delta time.
|
||
|
|
/// </summary>
|
||
|
|
public static Tick Timed(float deltaTime) => new(TickType.Timed, deltaTime);
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// Creates a logical tick (no delta time).
|
||
|
|
/// </summary>
|
||
|
|
public static Tick Logical() => new(TickType.Logical, 0f);
|
||
|
|
}
|