PersistedEntityRecord
One persisted entity as the store holds it: enough to bring the entity back on any worker (prefab or scene object, container and pose, authority epoch) plus the opaque state blob the entity itself wrote (PersistentStateCodec: opted-in Ne...
Nebula · Packages/com.1by3.nebula/Runtime/Persistence/IPersistenceStore.cspublic sealed class PersistedEntityRecordOne persisted entity as the store holds it: enough to bring the entity back on any worker (prefab or scene object, container and pose, authority epoch) plus the opaque state blob the entity itself wrote (PersistentStateCodec: opted-in NetworkVariables and behaviour state, keyed by name). Plain data on purpose: nothing here depends on the storage backend.
Fields
Key
public string Key = "";Stable identity of the entity across runs and workers (PersistentEntity.Key).
PrefabId
public ushort PrefabId = ushort.MaxValue;Prefab index at save time (NetworkPrefabs); ushort.MaxValue for a scene entity.
PrefabName
public string PrefabName = "";Prefab asset name, so a restore can recover from a reordered prefab list.
SceneId
public uint SceneId;Non-zero: the record belongs to a scene entity with this NetworkIdentity.SceneId.
ScopeKey
public string ScopeKey = "";Opaque scope key of the scope the entity was in (NetworkIdentity.ScopeKey at save time): EntityLocation.PublicScope (empty) for the public world, the instance key inside an instance. A record written before the key was recorded reads as the public world.
ContainerId
public string ContainerId = "";Static or runtime container the entity was in (its Container.ContainerId), or "" when it was in none or inside a carrier.
PartId
public string PartId = "";The scope part id of the container in ContainerId at save time (InstanceContainerInfo.PartId, the same string the container's lease row carries), or "" when the container has none or the record was written before part ids were recorded. For a chunk of a scoped grid it is the chunk's coordinate, c/x/y/z (ChunkKeys.PartId). A scoped chunk's container id is a hash of the scope key and this string and cannot be turned back into a coordinate, so this field is how a process that never named the chunk places the record: see ChunkKeys.TryCoordOf. Setting Location to another scope or container clears it.
CarrierKey
public string CarrierKey = "";When the entity was inside a dynamic container: the persistence key of the carrier. "" otherwise.
LocalPosition
public Vector3 LocalPosition;Pose in the container's local space (world space when there was no container).
LocalRotation
public Quaternion LocalRotation = Quaternion.identity;Velocity
public Vector3 Velocity;Epoch
public uint Epoch;Authority epoch at save time. The store rejects a save whose epoch is older than what it holds.
ServerDriven
public bool ServerDriven;Spawned with NebulaWorker.SpawnServerDriven.
Owned
public bool Owned;A client owned the entity when it was saved. Such records are not restored automatically (there is no client to own the result); the game restores them on demand.
Name
public string Name = "";GameObject name at save time (cosmetic).
State
public byte[] State = Array.Empty<byte>();Opaque state blob written by PersistentStateCodec.
Version
public ulong Version;Bumped by the store on every accepted save.
SavedAt
public DateTime SavedAt;SavedBy
public string SavedBy = "";Id of the worker that wrote the record.
Properties
Location
public EntityLocation Location { get; set; }The saved location as the contract's triple (EntityLocation): ScopeKey, ContainerId and the local pose. For an entity saved inside a carrier the container id is empty and CarrierKey names the carrier instead, because a dynamic container's id lives only as long as its carrier's net id. Setting it writes the three fields back and leaves CarrierKey alone. When the scope or the container changes, it also clears PartId, which named the old container.
Methods
Clone
public PersistedEntityRecord Clone();ToString
public override string ToString();