Class SyncStopwatch
A SyncObject to efficiently synchronize Stopwatchs over the network.
Inheritance
Implements
Inherited Members
Namespace: FishNet.Object.Synchronizing
Assembly: FishNet.Runtime.dll
Syntax
public class SyncStopwatch : SyncBase, ICustomSync
Constructors
SyncStopwatch(SyncTypeSettings)
Declaration
public SyncStopwatch(SyncTypeSettings settings = default(SyncTypeSettings))
Parameters
| Type | Name | Description |
|---|---|---|
| SyncTypeSettings | settings |
Properties
Elapsed
How much time has passed since the Stopwatch started.
Declaration
public float Elapsed { get; }
Property Value
| Type | Description |
|---|---|
| System.Single |
Paused
True if the SyncStopwatch is currently paused. Calls to Update(float) will be ignored when paused.
Declaration
public bool Paused { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
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
PauseStopwatch(Boolean)
Pauses the Stopwatch. Calling while already paused will be result in no action.
Declaration
public void PauseStopwatch(bool sendElapsed = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | sendElapsed | True to send Remaining with this operation. |
StartStopwatch(Boolean)
Starts a Stopwatch. If called when a Stopwatch is already active then StopStopwatch will automatically be sent.
Declaration
public void StartStopwatch(bool sendElapsedOnStop = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | sendElapsedOnStop | True to include remaining time when automatically sending StopStopwatch. |
StopStopwatch(Boolean)
Stops and resets the Stopwatch.
Declaration
public void StopStopwatch(bool sendElapsed = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | sendElapsed |
UnpauseStopwatch()
Unpauses the Stopwatch. Calling while already unpaused will be result in no action.
Declaration
public void UnpauseStopwatch()
Update(Single)
Adds delta from Remaining for server and client.
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 Stopwatch operation occurs.
Declaration
public event SyncStopwatch.SyncTypeChanged OnChange
Event Type
| Type | Description |
|---|---|
| SyncStopwatch.SyncTypeChanged |