Vixen
02b45cc4
csharp
public sealed class WorldSnapshot

A copy of a world, kept so that leaving play mode can put the scene back.

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

Remarks

This is what makes in-process play mode possible, and doc 11 states it as a constraint on the ECS rather than an afterthought: a world has to be cheaply copyable, and the archetype/chunk layout is what makes that true. A snapshot is a walk over the archetypes copying rows, not a serialisation pass.

⚠ An Entity is a slot in a world, so copying one verbatim into another world names the wrong thing. World.CopyComponentsFrom says so and leaves the fix-up to the caller, because nothing generic can know which fields are handles. What is fixed up here is the hierarchy — Parent, Child and Sibling — because those are the ones the engine itself declares. A game component holding an Entity comes back from play mode pointing at whatever is in that slot, and the way out of that is Remap, which is handed the whole translation table.

Restoring gives every entity a new handle, and the editor's selection holds old ones. That is why Restore returns the table rather than being a void: a selection that was not translated would highlight whatever entity happened to land in the slot, which is the sort of bug that looks like a rendering fault.

Fields and properties (1)

  • public int EntityCount

    How many entities were captured.

Methods (4)

  • public static WorldSnapshot Capture(World source)

    Takes a copy of a world.

  • public IReadOnlyDictionary<Entity, Entity> Restore(World target)

    Puts the world back to what was captured.

  • public static IReadOnlyList<Entity> Remap(IEnumerable<Entity> entities, IReadOnlyDictionary<Entity, Entity> translation)

    Translates a list of entities through a table, dropping the ones that are gone.

  • public void Dispose()

    Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Used by (2)

  • PlayModeControllerVixen.Editor.SceneView
  • SceneTestsVixen.Editor.SceneView.Tests