Vixen
feb85697
csharp
public interface IPlaySession

Play mode as a service: what the transport does, callable without a window.

Read the guide page for this →

Remarks

Doc 50 § D2's first service (#1289). Play, Pause, Step and Stop used to be private methods on the application, closed over its fields, so a plugin that wanted "enter play the way F5 does" could not call it and a test that wanted it had to open a whole editor. The transport's four commands are now names for the four verbs here, registered by PlayModule through the same PluginContext a third party uses.

⚠ It extends IActivePlaySession rather than standing beside it. That seam (#470) is the read half — "is a session running, and what is it" — and was already published; a second interface answering the same question would be two seams for one thing. A reader that only wants the session keeps asking for the narrow one.

⚠ What play does to the rest of the editor is not here. Maximising the viewport, clearing the console, the notification and the "not running everything" report are the workspace's and the diagnostics' concerns; they subscribe to Entered and Left, which is the callback doc 50 says the composition root supplies until those contexts are services of their own.

Fields and properties (3)

  • PlayState State

    Editing, playing, or paused.

  • bool IsPlaying

    Whether a session is running, paused or not.

  • DiagnosticOverlays Overlays

    The registry a session's diagnostic overlays are registered in and switched through.

Events (2)

  • Action<IPlaySession>? Entered

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

  • Action<IPlaySession>? Left

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

Methods (6)

  • bool IsOverlayOn(string name)

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

  • void SwitchOverlay(string name)

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

  • bool Enter()

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

  • IReadOnlyList<Entity> Leave()

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

  • void TogglePause()

    Pauses a running session, or resumes a paused one.

  • void StepFrame()

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

Used by (7)

  • EditorApplicationVixen.Editor.App
  • EditorPlaySessionVixen.Editor.SceneView
  • EditorPlaySessionTestsVixen.Editor.SceneView.Tests
  • PlayModuleVixen.Editor.App
  • PlayModuleTestsVixen.Editor.App.Tests
  • ProjectAssemblyTestsVixen.Editor.App.Tests
  • ServiceReachTestsVixen.Editor.App.Tests