Vixen
02b45cc4
csharp
public sealed class NetworkSpawner

Spawns and despawns networked instances. Server-side.

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

Remarks

Instantiate here and the clients follow. A spawn puts a NetworkSpawn on the instance's root; the root is a replicated entity like any other, so the snapshot carries it out, and a client's spawn system builds the same prefab from the same id. Nothing here writes a packet — which is the point, because a spawn that travelled by its own route would need its own answer to interest, to loss, and to what a late joiner is owed, and the snapshot already has all three.

Despawn is the same trick backwards. Destroying the entity takes it out of what the interest resolver returns, and leaving interest already means "drop it" — so a client cannot tell destruction from walking over the horizon, and does not need to. What this adds is telling ReplicationServer to stop tracking the ids, which is memory rather than correctness.

Fields and properties (7)

  • public NetworkOwnership? Ownership

    Who owns what. Optional; without it a spawn's owner is only on the wire.

  • public NetworkRulesRegistry? Rules

    Who may do what. Optional; without it the server may spawn and nobody else may.

  • public ReplicationServer? Replication

    The replicator to tell about despawns, so it stops tracking them.

  • public SceneManager? Scenes

    The scenes this peer has loaded. Optional; without it spawns belong to no scene.

  • public NetworkSceneMap? SceneIds

    Which networked scene each local one is. Optional, and needed with Scenes.

  • public long SpawnedCount

    How many instances have been spawned.

  • public long DespawnedCount

    How many have been despawned.

Methods (6)

Used by (3)

  • NetworkSpawnTestsVixen.Net.Engine.Tests
  • PlayerSpawnerVixen.Net.Engine
  • PlayerSpawnerTestsVixen.Net.Engine.Tests