CurveOutput
A class in Root.Township, the global namespace.
A networked looping timer that runs a value along an AnimationCurve and sends it to a FloatUnityEvent every frame. The server owns start, stop and reset and resyncs clients now and then; progress and running state are saved.
- Listed in Global namespace: C to D
- Inherits or implements
NetworkEntityBehaviour,ISavable<CurveOutputSaveData>,ISavableSave<CurveOutputSaveData>,ISavableSaveBase - Derived types
CurveOutputSaveData
Constructors
| Member | What it is |
|---|---|
CurveOutput() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
10 private and internal fields
| Member | What it is |
|---|---|
private AltaCoroutine coroutine | The running UpdateTime coroutine. |
private AnimationCurve curve | Curve sampled with progress from 0 to 1. |
private CurveOutputSaveData data | Saved state: progress and whether it is running. |
private float magnitude | Multiplier on the curve value. |
private FloatUnityEvent output | Event that receives the value each frame. |
private float speed | Loops per second. |
private MethodSync sync | Start sync (also used for periodic resync). |
private float syncInterval | Server: seconds between resyncs (60 by default). |
private MethodSync syncReset | Reset sync. |
private MethodSync syncStop | Stop sync. |
Methods
| Member | What it is |
|---|---|
override void Initialize() | Sets up the start, stop and reset syncs; on clients it turns periodic resync off. |
override void InitializeAsServer(SpawnData spawnData) | Server: restarts the timer if the save says it was running. |
override void OnConnected(Player player) | Server: sends a joining player a start or stop sync with the current progress. |
void ResetState() | Server: if running, stops, sets progress to 0, outputs the start value and tells clients to reset. |
void SetRunning(bool isRunning) | Calls StartRunning or StopRunning. Handy as a UnityEvent target. |
void StartRunning() | Server: starts the timer if it isn't running and tells clients. |
void StopRunning() | Server: stops the timer if it is running and sends clients the progress it stopped at. |
4 private and internal methods
| Member | What it is |
|---|---|
private void SyncReset(IPlayer player, Stream stream) | Client: stops the timer, sets progress to 0 and outputs the start value. |
private void SyncStart(IPlayer player, Stream stream) | Client: reads the server's progress and restarts the timer from it. |
private void SyncStop(IPlayer player, Stream stream) | Client: reads the server's progress, stops the timer and outputs that value. |
private IEnumerator UpdateTime() (iterator) | Coroutine that outputs the curve value times magnitude each frame, advances progress by speed (wrapping at 1) and resyncs every syncInterval. |