Skip to content

EntitySnapshot Class

Definition

Namespace: Brine2D.ECS.Serialization

Serializable snapshot of an entity's state.

C#
public class EntitySnapshot

Inheritance System.Object → EntitySnapshot

Remarks

ID remapping:Id stores the entity's Id at the time the snapshot was taken. When the snapshot is restored, RestoreWorldFromSnapshot\(IEntityWorld, WorldSnapshot\) creates brand-new entities that receive fresh runtime IDs assigned by the Entity counter. The snapshot ID is not re-injected into the restored entity's runtime ID. It is used only to reconstruct the parent–child hierarchy (via ParentId) and is otherwise discarded after restoration.

If your components store cross-entity references as System.Int64 entity IDs (e.g., an AI target, a joint partner), those IDs will be stale after a restore. Re-resolve such references after restoration, or store entity names/tags instead.

Properties
Id The runtime ID of the entity at snapshot time. Used during restore to reconstruct the parent–child hierarchy. Not injected back into the restored entity.
ParentId The runtime ID of this entity's parent at snapshot time, or 0 if this is a root entity. Used during RestoreWorldFromSnapshot\(IEntityWorld, WorldSnapshot\) to re-parent entities after all entities have been created \(two\-pass restore\).