Class SyncTimer
A SyncObject to efficiently synchronize timers over the network.
Inheritance
Implements
Inherited Members
Namespace: FishNet.Object.Synchronizing
Assembly: FishNet.Runtime.dll
Syntax
public class SyncTimer : SyncBase, ICustomSync
Constructors
SyncTimer(SyncTypeSettings)
Declaration
public SyncTimer(SyncTypeSettings settings = default(SyncTypeSettings))
Parameters
| Type | Name | Description |
|---|---|---|
| SyncTypeSettings | settings |
Properties
Duration
Starting duration of the timer.
Declaration
public float Duration { get; }
Property Value
| Type | Description |
|---|---|
| System.Single |
Elapsed
How much time has passed since the timer started.
Declaration
public float Elapsed { get; }
Property Value
| Type | Description |
|---|---|
| System.Single |
Paused
True if the SyncTimer is currently paused. Calls to Update(float) will be ignored when paused.
Declaration
public bool Paused { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Remaining
Time remaining on the timer. When the timer is expired this value will be 0f.
Declaration
public float Remaining { get; }
Property Value
| Type | Description |
|---|---|
| System.Single |
Methods
GetSerializedType()
Return the serialized type.
Declaration
public object GetSerializedType()
Returns
| Type | Description |
|---|---|
| System.Object |
Initialized()
Called when the SyncType has been registered, but not yet initialized over the network.
Declaration
protected override void Initialized()
Overrides
OnStartCallback(Boolean)
Called after OnStartXXXX has occurred.
Declaration
protected override void OnStartCallback(bool asServer)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | asServer | True if OnStartServer was called, false if OnStartClient. |
Overrides
PauseTimer(Boolean)
Pauses the timer. Calling while already paused will be result in no action.
Declaration
public void PauseTimer(bool sendRemaining = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | sendRemaining | True to send Remaining with this operation. |
StartTimer(Single, Boolean)
Starts a timer. If called when a timer is already active then StopTimer will automatically be sent.
Declaration
public void StartTimer(float remaining, bool sendRemainingOnStop = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | remaining | Time in which the timer should start with. |
| System.Boolean | sendRemainingOnStop | True to include remaining time when automatically sending StopTimer. |
StopTimer(Boolean)
Stops and resets the timer.
Declaration
public void StopTimer(bool sendRemaining = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | sendRemaining |
UnpauseTimer()
Unpauses the timer. Calling while already unpaused will be result in no action.
Declaration
public void UnpauseTimer()
Update()
Removes time passed from Remaining since the last unscaled time using this method.
Declaration
public void Update()
Update(Single)
Removes delta from Remaining for server and client. This also resets unscaledTime delta for Update().
Declaration
public void Update(float delta)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | delta | Value to remove from Remaining. |
WriteDelta(PooledWriter, Boolean)
Writes all changed values.
Declaration
protected override void WriteDelta(PooledWriter writer, bool resetSyncTick = true)
Parameters
| Type | Name | Description |
|---|---|---|
| PooledWriter | writer | |
| System.Boolean | resetSyncTick | True to set the next time data may sync. |
Overrides
WriteFull(PooledWriter)
Writes all values.
Declaration
protected override void WriteFull(PooledWriter writer)
Parameters
| Type | Name | Description |
|---|---|---|
| PooledWriter | writer |
Overrides
Events
OnChange
Called when a timer operation occurs.
Declaration
public event SyncTimer.SyncTypeChanged OnChange
Event Type
| Type | Description |
|---|---|
| SyncTimer.SyncTypeChanged |