Photon Fusion 2.0.4

Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Properties | List of all members
TickRate Struct Reference

A tick rate is a collection of tick rates. More...

Classes

struct  Resolved
 Represents a resolved tick rate. More...
 
struct  Selection
 Represents a selection of tick rates for client and server. More...
 

Public Types

enum class  ValidateResult
 Enumerates the possible results of validating a tick rate selection. More...
 

Public Member Functions

Selection ClampSelection (Selection selection)
 Clamps the indices in the specified Selection to valid ranges. More...
 
int GetDivisor (int index)
 Gets the divisor for the tick rate at the specified index. More...
 
int GetTickRate (int index)
 Gets the tick rate at the specified index. More...
 
 TickRate (params int[] rates)
 
int[] ToArray ()
 Converts the tick rates to an array. More...
 
bool Validate ()
 Validates the tick rates in the TickRate. More...
 
ValidateResult ValidateSelection (Selection selected)
 Validates the tick rates in the specified Selection. More...
 

Static Public Member Functions

static TickRate Get (int rate)
 Retrieves the TickRate associated with the specified tick rate. More...
 
static void Init ()
 Initializes the TickRate class by setting up the valid tick rates and their lookup dictionary. More...
 
static void InitChecked ()
 
static bool IsValid (int rate)
 Checks if the provided tick rate is valid. More...
 
static bool IsValid (TickRate rate)
 Checks if the provided TickRate is valid. More...
 
static Resolved Resolve (Selection selection)
 Resolves the specified Selection into a Resolved structure. More...
 

Public Attributes

int _count
 
fixed int _rates [4]
 

Static Public Attributes

static Dictionary< int, TickRate_lookup
 
static TickRate[] _valid
 
static ReadOnlyCollection< TickRate_validReadOnly
 

Properties

static IReadOnlyList< TickRateAvailable [get]
 Gets a read-only list of all available TickRates. More...
 
int Client [get]
 Gets the tick rate for the client. More...
 
int Count [get]
 Gets the count of tick rates in the TickRate. More...
 
int this[int index] [get]
 Gets the tick rate at the specified index. More...
 

Detailed Description

A tick rate is a collection of tick rates.

Member Enumeration Documentation

◆ ValidateResult

enum ValidateResult
strong

Enumerates the possible results of validating a tick rate selection.

Enumerator
Ok 

The tick rate selection is valid.

Error 

An error occurred during validation.

NotFound 

The tick rate selection was not found.

InvalidTickRate 

The tick rate selection is invalid.

ServerIndexOutOfRange 

The server index in the tick rate selection is out of range.

ClientSendIndexOutOfRange 

The client send index in the tick rate selection is out of range.

ServerSendIndexOutOfRange 

The server send index in the tick rate selection is out of range.

ServerSendRateLargerThanTickRate 

The server send rate in the tick rate selection is larger than the tick rate.

Member Function Documentation

◆ ClampSelection()

Selection ClampSelection ( Selection  selection)

Clamps the indices in the specified Selection to valid ranges.

Parameters
selectionThe Selection to clamp.
Returns
A new Selection with clamped indices. If the TickRate is invalid, returns a default Selection.

◆ Get()

static TickRate Get ( int  rate)
static

Retrieves the TickRate associated with the specified tick rate.

Parameters
rateThe tick rate to retrieve the TickRate for.
Returns
The TickRate associated with the specified tick rate.
Exceptions
InvalidOperationExceptionThrown when the tick rate is invalid.

◆ GetDivisor()

int GetDivisor ( int  index)

Gets the divisor for the tick rate at the specified index.

Parameters
indexThe index of the tick rate to get the divisor for.
Returns
The divisor for the tick rate at the specified index.
Exceptions
ArgumentOutOfRangeExceptionThrown when the index is out of range.
InvalidOperationExceptionThrown when the client tick rate is not divisible by the tick rate at the specified index.

◆ GetTickRate()

int GetTickRate ( int  index)

Gets the tick rate at the specified index.

Parameters
indexThe index of the tick rate to get.
Returns
The tick rate at the specified index.
Exceptions
ArgumentOutOfRangeExceptionThrown when the index is out of range.

◆ Init()

static void Init ( )
static

Initializes the TickRate class by setting up the valid tick rates and their lookup dictionary.

◆ IsValid() [1/2]

static bool IsValid ( int  rate)
static

Checks if the provided tick rate is valid.

Parameters
rateThe tick rate to validate.
Returns
true if the tick rate is valid; otherwise, false.

◆ IsValid() [2/2]

static bool IsValid ( TickRate  rate)
static

Checks if the provided TickRate is valid.

Parameters
rateThe TickRate to validate.
Returns
true if the TickRate is valid; otherwise, false.

◆ Resolve()

static Resolved Resolve ( Selection  selection)
static

Resolves the specified Selection into a Resolved structure.

Parameters
selectionThe Selection to resolve.
Returns
A Resolved structure that represents the resolved tick rates.

◆ ToArray()

int [] ToArray ( )

Converts the tick rates to an array.

Returns
An array containing the tick rates.

◆ Validate()

bool Validate ( )

Validates the tick rates in the TickRate.

Returns
true if the tick rates are valid; otherwise, false.

The tick rates are valid if:

  • There is at least one tick rate.
  • There are no more than four tick rates.
  • The first tick rate is greater than 0.
  • Each tick rate is a divisor of the first tick rate.

◆ ValidateSelection()

ValidateResult ValidateSelection ( Selection  selected)

Validates the tick rates in the specified Selection.

Parameters
selectedThe Selection to validate.
Returns
A ValidateResult that indicates the result of the validation.

The Selection is valid if:

  • The TickRate is valid.
  • The client tick rate in the Selection matches the client tick rate in the TickRate.
  • The server index in the Selection is within the range of available tick rates.
  • The server send index in the Selection is within the range of available tick rates.
  • The client send index in the Selection is within the range of available tick rates.
  • The server send rate in the Selection is not larger than the server tick rate.

Property Documentation

◆ Available

IReadOnlyList<TickRate> Available
staticget

Gets a read-only list of all available TickRates.

This property ensures that the TickRate class is initialized before returning the list.

◆ Client

int Client
get

Gets the tick rate for the client.

◆ Count

int Count
get

Gets the count of tick rates in the TickRate.

◆ this[int index]

int this[int index]
get

Gets the tick rate at the specified index.

Parameters
indexThe index of the tick rate to get.
Returns
The tick rate at the specified index.