Photon Fusion 2.0.0

Public Member Functions | Static Public Member Functions | Public Attributes | Properties | List of all members
TickAccumulator Struct Reference

A tick accumulator. More...

Public Member Functions

void AddTicks (int ticks)
 Adds a specified number of ticks to the TickAccumulator.
 
void AddTime (double dt, double step, int? maxTicks=null)
 Adds a specified amount of time to the TickAccumulator, incrementing the tick count as necessary.
 
float Alpha (double step)
 Calculates the alpha value based on the given step.
 
bool ConsumeTick (out bool last)
 Consumes a tick from the TickAccumulator.
 
void Start ()
 Starts the TickAccumulator, allowing it to accumulate ticks.
 
void Stop ()
 Stops the TickAccumulator from accumulating ticks.
 

Static Public Member Functions

static TickAccumulator StartNew ()
 Starts a new TickAccumulator.
 

Public Attributes

bool _running
 
double _scale
 
int _ticks
 
double _time
 

Properties

int Pending [get]
 Gets the number of pending ticks in the TickAccumulator.
 
double Remainder [get]
 Gets the remaining time in the TickAccumulator.
 
bool Running [get]
 Gets a value indicating whether the TickAccumulator is running.
 
double TimeScale [get, set]
 Gets or sets the time scale of the TickAccumulator.
 

Detailed Description

A tick accumulator.

Member Function Documentation

◆ AddTicks()

void AddTicks ( int  ticks)

Adds a specified number of ticks to the TickAccumulator.

Parameters
ticksThe number of ticks to add.

◆ AddTime()

void AddTime ( double  dt,
double  step,
int?  maxTicks = null 
)

Adds a specified amount of time to the TickAccumulator, incrementing the tick count as necessary.

Parameters
dtThe amount of time to add.
stepThe time step value.
maxTicksThe maximum number of ticks to add. If this value is reached, the remaining time is set to 0.

◆ Alpha()

float Alpha ( double  step)

Calculates the alpha value based on the given step.

Parameters
stepThe step value used to calculate the alpha.
Returns
The calculated alpha value.

◆ ConsumeTick()

bool ConsumeTick ( out bool  last)

Consumes a tick from the TickAccumulator.

Parameters
lastWhen this method returns, contains a boolean indicating whether the consumed tick was the last one.
Returns
true if a tick was successfully consumed; otherwise, false.

◆ StartNew()

static TickAccumulator StartNew ( )
static

Starts a new TickAccumulator.

Returns
A new TickAccumulator.

Property Documentation

◆ TimeScale

double TimeScale
getset

Gets or sets the time scale of the TickAccumulator.

Exceptions
InvalidOperationExceptionThrown when the value is less than or equal to 0.