ContainerRef
How a container is named on the wire.
Nebula · Packages/com.1by3.nebula/Runtime/Containers/ContainerRef.cspublic readonly struct ContainerRef : IEquatable<ContainerRef>How a container is named on the wire. A static container (authored into the scene or baked into the world manifest) is its dense registry Index, identical in every process. A dynamic container (one an entity carries on its root: a ship, a train, a moving station) has no stable index, since it is created and destroyed at runtime by whichever worker spawns its carrier; it is named by the carrier's NetId, which is already mesh-unique and follows the entity through every handover. A runtime container (one the game registered while the mesh runs, see ContainerRegistry.RegisterRuntime) is named by the 64-bit id the game gave it. On the wire that is two bytes for a static container and ten for a dynamic or runtime one.
Constructors
ContainerRef
public ContainerRef(ushort index, ulong netId = 0);Fields
NoneIndex
public const ushort NoneIndex = ushort.MaxValue;Index of "no container".
DynamicIndex
public const ushort DynamicIndex = ushort.MaxValue - 1;Index that says "dynamic: look at NetId".
RuntimeIndex
public const ushort RuntimeIndex = ushort.MaxValue - 2;Index that says "runtime: look at RuntimeId".
MaxWireSize
public const int MaxWireSize = 2 + 8;Largest serialized size (a dynamic or runtime reference), for sizing fixed batches.
Index
public readonly ushort Index;NetId
public readonly ulong NetId;The 64-bit payload: the carrier's net id for a dynamic reference, the game's id for a runtime one, 0 otherwise.
None
public static readonly ContainerRef None = new ContainerRef(NoneIndex);Properties
IsNone
public bool IsNone { get; }IsDynamic
public bool IsDynamic { get; }IsRuntime
public bool IsRuntime { get; }IsStatic
public bool IsStatic { get; }Names a container of the baked set (a dense index).
RuntimeId
public ulong RuntimeId { get; }The game's id of the runtime container this names (0 for any other reference).
MayArriveLater
public bool MayArriveLater { get; }The container may be unknown on this process for a while and show up later: a dynamic container arrives with its carrier, a runtime container with its lease. Messages naming one that has not arrived wait for it instead of being dropped.
NamesAContainer
public bool NamesAContainer { get; }The reference names a container (it is not None). A client that cannot resolve one holds the update that names it, whatever the container's kind, instead of placing the entity in the public world, where its container-local coordinates would be read from the world root (docs/portals.md D20). Only None means "no container".
Methods
Of
public static ContainerRef Of(Container container);The reference for container (None for null).
Dynamic
public static ContainerRef Dynamic(ulong carrierNetId);A reference to the dynamic container carried by entity carrierNetId.
Runtime
public static ContainerRef Runtime(ulong runtimeId);A reference to the runtime container the game registered as runtimeId.
Resolve
public Container Resolve();The container this names in this process, or null when it is unknown here (see ContainerRegistry.Resolve).
Write
public void Write(NetworkWriter w);Read
public static ContainerRef Read(NetworkReader r);Equals
public bool Equals(ContainerRef other);
public override bool Equals(object obj);GetHashCode
public override int GetHashCode();operator ==
public static bool operator ==(ContainerRef a, ContainerRef b);operator !=
public static bool operator !=(ContainerRef a, ContainerRef b);ToString
public override string ToString();ContainerPlacement
Where a runtime container goes and what kind of container it is: its parent, its box, its authority and whether it gets its own physics frame.
ContainerRegistry
The container graph of the loaded level: every static Container, indexed deterministically so all processes agree on indices, plus adjacency (adjacent = bounds touch or overlap), plus the dynamic containers currently carried by entities ...