2026-04-02 19:37:35 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "EditorRuntimeMode.h"
|
|
|
|
|
#include "SceneSnapshot.h"
|
|
|
|
|
|
2026-04-03 13:22:30 +08:00
|
|
|
#include "Core/EditorEvents.h"
|
|
|
|
|
|
2026-04-02 19:37:35 +08:00
|
|
|
#include <XCEngine/Scene/RuntimeLoop.h>
|
|
|
|
|
|
2026-04-03 13:22:30 +08:00
|
|
|
#include <cstddef>
|
2026-04-02 19:37:35 +08:00
|
|
|
#include <cstdint>
|
|
|
|
|
|
|
|
|
|
namespace XCEngine {
|
|
|
|
|
namespace Editor {
|
|
|
|
|
|
|
|
|
|
class IEditorContext;
|
|
|
|
|
|
|
|
|
|
class PlaySessionController {
|
|
|
|
|
public:
|
|
|
|
|
void Attach(IEditorContext& context);
|
|
|
|
|
void Detach(IEditorContext& context);
|
|
|
|
|
|
|
|
|
|
void Update(IEditorContext& context, float deltaTime);
|
|
|
|
|
|
|
|
|
|
bool StartPlay(IEditorContext& context);
|
|
|
|
|
bool StopPlay(IEditorContext& context);
|
|
|
|
|
bool PausePlay(IEditorContext& context);
|
2026-04-02 19:56:07 +08:00
|
|
|
bool ResumePlay(IEditorContext& context);
|
|
|
|
|
bool StepPlay(IEditorContext& context);
|
2026-04-02 19:37:35 +08:00
|
|
|
|
2026-04-08 00:33:50 +08:00
|
|
|
::XCEngine::Components::Scene* GetRuntimeScene() const { return m_runtimeLoop.GetScene(); }
|
|
|
|
|
|
2026-04-02 19:37:35 +08:00
|
|
|
private:
|
2026-04-03 13:22:30 +08:00
|
|
|
void ResetRuntimeInputBridge();
|
|
|
|
|
void ApplyGameViewInputFrame(float deltaTime);
|
2026-04-08 00:33:50 +08:00
|
|
|
void EnsureRuntimeSceneSyncSubscription(IEditorContext& context);
|
|
|
|
|
void ClearRuntimeSceneSyncSubscription(IEditorContext& context);
|
|
|
|
|
void SyncRuntimeSceneIfNeeded(IEditorContext& context);
|
2026-04-03 13:22:30 +08:00
|
|
|
|
2026-04-02 19:37:35 +08:00
|
|
|
uint64_t m_playStartRequestedHandlerId = 0;
|
|
|
|
|
uint64_t m_playStopRequestedHandlerId = 0;
|
|
|
|
|
uint64_t m_playPauseRequestedHandlerId = 0;
|
2026-04-02 19:56:07 +08:00
|
|
|
uint64_t m_playResumeRequestedHandlerId = 0;
|
|
|
|
|
uint64_t m_playStepRequestedHandlerId = 0;
|
2026-04-03 13:22:30 +08:00
|
|
|
uint64_t m_gameViewInputFrameHandlerId = 0;
|
2026-04-08 00:33:50 +08:00
|
|
|
uint64_t m_runtimeSceneChangedHandlerId = 0;
|
2026-04-02 19:37:35 +08:00
|
|
|
SceneSnapshot m_editorSnapshot = {};
|
2026-04-03 13:22:30 +08:00
|
|
|
GameViewInputFrameEvent m_pendingGameViewInput = {};
|
|
|
|
|
GameViewInputFrameEvent m_appliedGameViewInput = {};
|
|
|
|
|
bool m_hasPendingGameViewInput = false;
|
2026-04-02 19:37:35 +08:00
|
|
|
XCEngine::Components::RuntimeLoop m_runtimeLoop;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Editor
|
|
|
|
|
} // namespace XCEngine
|