Add play mode functionality and player start markers in viewport

This commit is contained in:
2026-03-31 03:06:48 +02:00
parent ce846a3464
commit e658c8dc10
3 changed files with 137 additions and 86 deletions

View File

@@ -37,6 +37,7 @@ export class EditorStore {
private document: SceneDocument;
private selection: EditorSelection = { kind: "none" };
private toolMode: ToolMode = "select";
private previousEditingToolMode: Exclude<ToolMode, "play"> = "select";
private readonly history = new CommandHistory();
private readonly listeners = new Set<EditorStoreListener>();
private readonly storage: KeyValueStorage | null;
@@ -81,10 +82,36 @@ export class EditorStore {
return;
}
if (toolMode !== "play") {
this.previousEditingToolMode = toolMode;
}
this.toolMode = toolMode;
this.emit();
}
enterPlayMode() {
if (this.toolMode === "play") {
return;
}
if (this.toolMode !== "play") {
this.previousEditingToolMode = this.toolMode;
}
this.toolMode = "play";
this.emit();
}
exitPlayMode() {
if (this.toolMode !== "play") {
return;
}
this.toolMode = this.previousEditingToolMode;
this.emit();
}
setSelection(selection: EditorSelection) {
this.selection = selection;
this.emit();
@@ -124,6 +151,7 @@ export class EditorStore {
this.document = document;
this.selection = { kind: "none" };
this.toolMode = "select";
this.previousEditingToolMode = "select";
if (resetHistory) {
this.history.clear();