Class ManualTickClock
- Namespace
- Unity.Multiplayer.Core
An ITickClock driven by hand: Step(int) ticks once, Advance(double) turns elapsed seconds into whole ticks and carries the remainder. For tests and engine-free simulations; in a running game the adapter's NetworkTickClock is used instead.
public sealed class ManualTickClock : ITickClock
- Inheritance
-
ManualTickClock
- Implements
- Inherited Members
Constructors
ManualTickClock(int)
Creates a clock at tick 0.
public ManualTickClock(int tickRate = 30)
Parameters
tickRateint
Exceptions
- ArgumentOutOfRangeException
tickRateis below 1.
Properties
CurrentTick
Ticks elapsed since the clock started; 0 before the first tick.
public long CurrentTick { get; }
Property Value
Pending
Seconds accumulated towards the next tick, in [0, TickInterval).
public double Pending { get; }
Property Value
TickInterval
Seconds per tick: 1 / TickRate.
public double TickInterval { get; }
Property Value
TickRate
Ticks per second.
public int TickRate { get; }
Property Value
Time
Simulation time in seconds: CurrentTick × TickInterval.
public double Time { get; }
Property Value
Methods
Advance(double)
Adds seconds of elapsed time and ticks once per whole interval it completes.
Returns the number of ticks run.
public int Advance(double seconds)
Parameters
secondsdouble
Returns
Exceptions
- ArgumentOutOfRangeException
secondsis negative, NaN or infinite.
Step(int)
Ticks ticks times, raising Ticked for each.
public void Step(int ticks = 1)
Parameters
ticksint
Exceptions
- ArgumentOutOfRangeException
ticksis negative.
Events
Ticked
Raised once per tick with the new CurrentTick.
public event Action<long> Ticked