EntitySpawnMsg
Full description of an entity.
Nebula · Packages/com.1by3.nebula/Runtime/Protocol/Messages.cspublic struct EntitySpawnMsgFull description of an entity. Sent as EntitySpawn (to gateway/clients), GhostSpawn (to a neighbor worker) and as the payload of AuthorityTransfer. Receivers treat a spawn for a known netId as an update (owner/epoch/container/vars), never as a duplicate instantiation.
Fields
NetId
public ulong NetId;PrefabId
public ushort PrefabId;OwnerClientId
public ulong OwnerClientId;Container
public ContainerRef Container;The container the pose is expressed in (static index, or the carrier's net id for a dynamic container).
Epoch
public uint Epoch;OwnerWorkerIndex
public ushort OwnerWorkerIndex;LocalPosition
public Vector3 LocalPosition;LocalRotation
public Quaternion LocalRotation;Velocity
public Vector3 Velocity;Flags
public EntityFlags Flags;LocalScale
public Vector3 LocalScale;SceneId
public uint SceneId;Non-zero: bind the receiver's own copy of the scene object with this NetworkIdentity.SceneId instead of instantiating PrefabId.
Vars
public byte[] Vars;State
public byte[] State;Keyframe from every sync behavior (NetworkIdentity.WriteSyncSnapshot); empty when the prefab has none.
OwnerIdentity
public string OwnerIdentity;The owning player's PlayerIdentity; empty for entities no player owns. Travels with the entity through ghosting and handover.
RelevanceRadius
public float RelevanceRadius;Meters this entity is relevant at, from its prefab (NetworkIdentity.RelevanceRadius); 0 means the mesh default. Sent as an f16, so it is precise to about a meter at the default ceiling.
InterestFlags
public EntityInterestFlags InterestFlags;Per-prefab interest flags (NetworkIdentity.AlwaysRelevant).
InterestGroup
public byte InterestGroup;A game-defined bucket a policy can filter on (NetworkIdentity.InterestGroup).
ViewSeq
public ushort ViewSeq;Gateway -> client: which view of this net id the spawn belongs to. It increases every time the gateway lets the entity into this client's set, so a despawn from an older view cannot kill a replica the client has just re-entered. Workers send 0.
CohesionGroup
public uint CohesionGroup;The entity's cohesion group (NetworkIdentity.CohesionGroup), 0 for none. It travels with every spawn, ghost spawn and handover, so each worker holding a copy knows which group the entity is in and a handover of any member can take the rest with it (protocol 18, docs/cohesion-hints.md).
CostWeight
public float CostWeight;What the game says this entity costs to simulate, as a multiplier on its category weight (NetworkIdentity.EffectiveCostWeight, protocol 18). It travels with the entity so the worker it lands on reports the same cost for it. Sent as an f16; zero is a valid weight. A missing field reads as -1, which leaves the receiver's current weight unchanged.
AudienceGeneration
public uint AudienceGeneration;Worker to gateway and worker to worker: the entity's audience generation (NetworkIdentity.SyncAudienceGeneration), raised every time a SyncAudience.Custom member set changes. It travels with the entity through ghosting and handover, so it never goes back, and a gateway holds back a restricted chunk stamped with a newer generation than the member sets it has (protocol 20, trailing and optional, written only when it or Audience is set). A gateway never forwards it to a client.
Audience
public byte[] Audience;Worker to gateway and worker to worker: the member sets of the entity's Custom behaviors (SyncAudienceCodec), or null when it has none. A gateway never forwards it to a client.
Maps
public byte[] Maps;Every NetworkMap<TKey, TValue> of the entity in full (a NetworkMapCodec section), or null when it has none (protocol 21, trailing and optional, docs/replicated-collections.md D5). A gateway keeps it current with each MsgId.EntityMaps and hands it to a late joiner.
OwnerClaims
public IReadOnlyDictionary<string, string> OwnerClaims;Worker to worker only: the owning player's forwarded token claims (NetworkIdentity.OwnerClaims), or null when there are none (protocol 22, trailing and optional, after Maps). It travels with every ghost spawn and handover, so each worker holding a copy of a player's entity can read the claims. A spawn for a gateway never carries it, and ForClient clears it.
DriverClientId
public ulong DriverClientId;The client that drives this server-owned entity (NetworkIdentity.DriverClientId), 0 for none (protocol 25, trailing and optional, after OwnerClaims, docs/driven-vehicles.md). The gateway accepts MsgId.DriveInput for the entity from this client only, and the client it names predicts the entity. It travels with every spawn, ghost spawn and handover.
Methods
From
public static EntitySpawnMsg From(NetworkIdentity id, NetworkWriter scratch, bool forGateway = false);| Parameter | Description |
|---|---|
id | The entity. |
scratch | A writer this reuses. |
forGateway | True for a spawn sent to a gateway: chunks of SyncAudience.WorkersOnly behaviors are left out, since no client may have them. A ghost spawn or a handover carries every behavior. |
Write
public void Write(NetworkWriter w, MsgId id);WriteBody
public void WriteBody(NetworkWriter w);
public void WriteBody(NetworkWriter w, bool embedded);Write the body. embedded is true when more fields follow it in the same message (an AuthorityTransferMsg): the audience section is then always written, since a reader cannot tell it apart from the fields after it. A standalone spawn writes it only when it holds something.
ForClient
public EntitySpawnMsg ForClient();This spawn as a client may see it: the fields only workers and gateways use are cleared.
Read
public static EntitySpawnMsg Read(NetworkReader r);
public static EntitySpawnMsg Read(NetworkReader r, bool embedded);Read a body written by WriteBody with the same embedded.