public sealed class SyncVar<T>A value the server sets and every client that can see the object ends up with.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
The convenient authoring style, and the same mechanism underneath as the ECS-native one. A module's fields become a lane layout, a lane layout is what DeltaCodec needs, and so a SyncVar is delta-encoded, priority-shed, acknowledged and attributed per field without a line of code here doing any of it.
Assigning it on a client changes nothing that lasts. The value is whatever the last snapshot said, so a local write is overwritten by the next one that mentions it. That is deliberately not an exception: prediction is a Phase 9+ feature with a design of its own, and a SyncVar that threw would make every optimistic UI update a crash.
Changed fires when a value arrives and differs, not when it is set locally on the server. So a handler is the place to react to a change, not the place to cause one — and the two ends run the same handler for the same reason.
Fields and properties (4)
public string NameWhat it is called, for bandwidth attribution.
public ReadOnlySpan<WireLane> LanesThe fixed-width fields it occupies, in the order Write puts them.
public bool IsDirtyWhether it has changed since the last ClearDirty.
public T ValueWhat it holds.
Events (1)
public Action<T, T>? ChangedRaised when a value arrives that differs from the one held.
Methods (7)
public SyncVar(T initial = default(T), IEqualityComparer<T>? comparer = null)Creates one.
public void Write(ref BitWriter writer)Writes the value.
public bool Apply(ref BitReader reader)Reads a value and takes it, raising whatever the field raises.
public void ClearDirty()Marks it as sent.
public void Rename(string name)Gives it its name, once it is known which module it is in.
public override string ToString()Returns a string that represents the current object.
public static implicit operator T(SyncVar<T> variable)Reads the value, so a sync var reads like the thing it holds.
Used by (4)
- PlayerStateVixen.Net.Engine.Tests
- SealedTooLateVixen.Net.Engine.Tests
- SyncStateTestsVixen.Net.Engine.Tests
- VitalsModuleVixen.Net.Engine.Tests