Vixen
02b45cc4
csharp
public abstract class NetworkModule

A composable, nestable unit of networked state.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

The primitive, and everything else here is built out of it — which is docs/plan/16's instruction rather than a preference: "building the built-ins out of the same primitive users get is the right discipline and proves the primitive". A SyncVar`1 is a field in a module; a behaviour's own state is a module; a health system that a dozen behaviours want is a module they each hold one of.

Modules nest, and a nested one's fields are the outer one's fields. Flattened at registration, so what reaches the wire is one lane layout rather than a tree walked per tick — and so the bandwidth report names a field Player.Vitals.Health without anything having to reconstruct the path.

State only. Remote calls stay where they were — a module holding RPCs would need its own entry in the manifest and its own ownership question, and neither has an answer that is different from the object's.

Fields and properties (4)

  • public string Name

    What this module is called within its parent, or the empty string at the root.

  • public IReadOnlyList<ISyncField> Fields

    Every field, this module's and its children's, in wire order.

  • public ReadOnlySpan<WireLane> Lanes

    The fixed-width layout the whole module occupies.

  • public bool IsDirty

    Whether anything in it has changed since it was last sent.

Methods (6)

  • protected TField Declare<TField>(TField field, string name) where TField : ISyncField

    Declares a field. Call from a constructor, before the module is used.

  • protected TModule Nest<TModule>(TModule module, string name) where TModule : NetworkModule

    Declares a nested module. Call from a constructor, before the module is used.

  • public void Seal(string path = "")

    Fixes the layout, after which nothing more may be declared.

  • public void Write(ref BitWriter writer)

    Writes every field.

  • public bool Apply(ref BitReader reader)

    Reads every field, in the order they were written.

  • public void ClearDirty()

    Marks everything as sent.

Used by (9)

  • EmptyVixen.Net.Engine.Tests
  • InventoryBehaviourVixen.Net.Engine.Tests
  • NetworkBehaviourVixen.Net.Engine
  • PlayerBehaviourVixen.Net.Engine.Tests
  • PlayerStateVixen.Net.Engine.Tests
  • SealedTooLateVixen.Net.Engine.Tests
  • SyncStateReplicatorVixen.Net.Engine
  • SyncStateTestsVixen.Net.Engine.Tests
  • VitalsModuleVixen.Net.Engine.Tests