Struct NetworkTick
A simple struct used to represent a network tick. This is using a uint internally, but it has special logic to deal with invalid ticks, and it handles wrap around correctly.
Implements
Inherited Members
Namespace: Unity.NetCode
Assembly: solution.dll
Syntax
[Serializable]
public struct NetworkTick : IEquatable<NetworkTick>
Constructors
Name | Description |
---|---|
NetworkTick(uint) | Constructor, the start tick can be 0. Use this instead of the default constructor since that will generate an invalid tick. |
Properties
Name | Description |
---|---|
Invalid | A value representing an invalid tick, this is the same as 'default' but provide more context in the code. |
IsValid | Check if the tick is valid. Not all operations will work on invalid ticks. |
SerializedData | The serialized data for a tick. Includes both validity and tick index. |
TickIndexForValidTick | Get the tick index assuming the tick is valid. Should be used with care since ticks will wrap around. |
TickValue | Helper property to enable exception-free visibility in the Entity Inspector |
Methods
Name | Description |
---|---|
Add(uint) | Add a delta to the tick, assumes the tick is valid. |
Decrement() | Decrement the tick, assumes the tick is valid. |
Equals(object) | Compare two ticks, also works for invalid ticks. |
Equals(NetworkTick) | Compare two ticks, also works for invalid ticks. |
GetHashCode() | Get a hash for the tick. |
Increment() | Increment the tick, assumes the tick is valid. |
IsNewerThan(NetworkTick) | Check if this tick is newer than another tick. Assumes both ticks are valid. |
Subtract(uint) | Subtract a delta from the tick, assumes the tick is valid. |
TicksSince(NetworkTick) | Compute the number of ticks which passed since an older tick. Assumes both ticks are valid. If the passed in tick is newer this will return a negative value. |
ToFixedString() | Convert the tick to a fixed string. Also handles invalid ticks. |
Operators
Name | Description |
---|---|
operator ==(in NetworkTick, in NetworkTick) | Compare two ticks, also works for invalid ticks. |
operator !=(in NetworkTick, in NetworkTick) | Compare two ticks, also works for invalid ticks. |