Remove unnecessary PlayMode enum

This commit is contained in:
Simon Lübeß
2026-09-13 21:16:09 +02:00
parent 8244033ac5
commit 8e9efbb367
+14 -23
View File
@@ -842,7 +842,7 @@ namespace GlitchyEditor
// In simulation mode we don't want any scripts to run, just physics. // In simulation mode we don't want any scripts to run, just physics.
_editorScene.CopyTo(runtimeScene, _sceneState == .Play); _editorScene.CopyTo(runtimeScene, _sceneState == .Play);
SetActiveScene(runtimeScene, startRuntime: (_sceneState == .Play), startSimulation: true, newPlayMode: (_sceneState == .Play ? .Play : .Simulation)); SetActiveScene(runtimeScene, startRuntime: (_sceneState == .Play), startSimulation: true, _sceneState);
if (_sceneState == .Play) if (_sceneState == .Play)
{ {
@@ -856,34 +856,25 @@ namespace GlitchyEditor
SwitchToPlayWindow(); SwitchToPlayWindow();
} }
enum PlayMode
{
Play,
Editor,
Simulation
}
/// Activates the given scene. /// Activates the given scene.
/// @param scene The scene to be activated. /// @param scene The scene to be activated.
/// @param startRuntime If set to true, the script runtime will be initialized for the given scene. /// @param startRuntime If set to true, the script runtime will be initialized for the given scene.
/// @param startSimulation If set to true, the physics simulation will be initialized for the given scene. /// @param startSimulation If set to true, the physics simulation will be initialized for the given scene.
private void SetActiveScene(Scene scene, bool startRuntime, bool startSimulation, PlayMode? newPlayMode = null) /// @param newSceneState The new scene state.
private void SetActiveScene(Scene scene, bool startRuntime, bool startSimulation, SceneState newSceneState)
{ {
_activeScene?.Stop(); _activeScene?.Stop();
if (newPlayMode != null) switch (newSceneState)
{ {
switch (newPlayMode.Value) case .Play:
{ ScriptEngine.ApplicationInfo.IsInPlayMode = true;
case .Play: case .Edit:
ScriptEngine.ApplicationInfo.IsInPlayMode = true; ScriptEngine.ApplicationInfo.IsInEditMode = true;
case .Editor: case .Simulate:
ScriptEngine.ApplicationInfo.IsInEditMode = true; // No scripts in Simulation
case .Simulation: ScriptEngine.ApplicationInfo.IsInEditMode = false;
// No scripts in Simulation ScriptEngine.ApplicationInfo.IsInPlayMode = false;
ScriptEngine.ApplicationInfo.IsInEditMode = false;
ScriptEngine.ApplicationInfo.IsInPlayMode = false;
}
} }
if (scene != null) if (scene != null)
@@ -926,11 +917,11 @@ namespace GlitchyEditor
Log.EngineLogger.Trace("Stopping current scene and returing to edit mode..."); Log.EngineLogger.Trace("Stopping current scene and returing to edit mode...");
SetActiveScene(_editorScene, startRuntime: true, startSimulation: false, newPlayMode: .Editor);
_editor.SceneViewportWindow.EditorMode = true; _editor.SceneViewportWindow.EditorMode = true;
_sceneState = .Edit; _sceneState = .Edit;
SetActiveScene(_editorScene, startRuntime: true, startSimulation: false, _sceneState);
_editor.CurrentScene = _activeScene; _editor.CurrentScene = _activeScene;
_isPaused = false; _isPaused = false;