Vixen
feb85697
csharp
public sealed class EditorPlaySession

The editor's play session: the transport's verbs over a PlayModeController.

Read the guide page for this →

Remarks

Moved out of the application, not rewritten (#1289). EnterPlay, LeavePlay, the pause toggle, ReportPlayGaps' wording, ProjectSystems and DrainPlayDiagnostics were private on EditorApplication; the debug draw, the overlay registry and the drained segments were its fields. They are this object's now, and the application constructs one, ticks it, publishes it, and subscribes to Entered and Left for the parts that are the workspace's.

⚠ The selection is asked for, not held. Stop translates the selection through the restore's handle map, and which selection that is — the active scene's — is the composition root's answer and can change while a session runs.

Fields and properties (7)

  • public PlayModeController Controller

    Snapshot, restore, and what state the transport is in.

  • public PlayState State

    Editing, playing, or paused.

  • public bool IsPlaying

    Whether a session is running, paused or not.

  • public PlaySession? Current

    The running session, or when nothing is playing.

  • public DebugDraw Debug

    Where a running play session's overlays put their world geometry.

  • public DiagnosticOverlays Overlays
  • public IReadOnlyList<LineVertex> DiagnosticLines

    The overlays' world geometry, as segment pairs a pane's line pass takes.

Events (2)

  • public Action<IPlaySession>? Entered

    Raised after a session has started, so the rest of the editor can follow.

  • public Action<IPlaySession>? Left

    Raised after a session has stopped and the scene has been restored.

Methods (10)

  • public EditorPlaySession(PlayModeController controller, Func<Selection<Entity>> selection)

    Wraps a controller.

  • public bool IsOverlayOn(string name)

    Whether a diagnostic overlay is on: the live one if a session has it, the wish if not.

  • public void SwitchOverlay(string name)

    Flips a diagnostic overlay — the wish, and the live overlay with it if a session runs one.

  • public bool Enter()

    Enters play mode: snapshots the scene and starts stepping it.

  • public IReadOnlyList<Entity> Leave()

    Stops, restores the scene, and translates the selection back through the restore.

  • public void TogglePause()

    Pauses a running session, or resumes a paused one.

  • public void StepFrame()

    Advances a paused session by a frame, entering play paused if nothing was running.

  • public bool Tick(TimeSpan delta)

    Runs one frame of the session, if one is running, and drains what its overlays drew.

  • public string DescribeRunning()

    What the session runs, said in a sentence.

  • public string? DescribeMissing(Assembly? project)

    Names anything this session is not running, or when that is nothing.

Used by (6)

  • EditorApplicationVixen.Editor.App
  • EditorPlaySessionTestsVixen.Editor.SceneView.Tests
  • PaneOverlaysVixen.Editor.App
  • PlayModuleVixen.Editor.App
  • PlayModuleTestsVixen.Editor.App.Tests
  • SceneEditingVixen.Editor.App