新增 GameFlow 运行时状态机:PIE 与独立运行统一生命周期
Stopped→Loading→Running↔Paused 单一状态源,编辑器 Play/Stop 与 main.cpp 独立运行共用同一套加载/恢复/暂停语义
This commit is contained in:
+30
-13
@@ -17,7 +17,8 @@
|
||||
#include "EditorContext.h"
|
||||
#include "panels/ViewportPanel.h" // ViewportInputState(成员按值持有)
|
||||
|
||||
#include <Engine/Core/Types.h> // u32(SelectEntity 位模式转换)
|
||||
#include <Engine/Core/Types.h> // u32(SelectEntity 位模式转换)
|
||||
#include <Engine/Core/GameFlow.h> // PIE 状态权威(IsPlaying 直查)
|
||||
|
||||
#include <entt/entt.hpp>
|
||||
|
||||
@@ -60,19 +61,35 @@ public:
|
||||
void RequestQuit() { m_ShowQuitConfirm = true; }
|
||||
|
||||
// ---- PIE(Play-In-Editor,UE 主工具栏语义)----
|
||||
bool IsPlaying() const { return m_Playing; }
|
||||
bool IsPaused() const { return m_Paused; }
|
||||
// Play:内存快照当前场景 → 切 gameView(Viewport 内嵌 primary 相机
|
||||
// 渲染,UE PIE 语义;不切全屏)→ 解冻时间;
|
||||
// Stop:快照原子换血恢复 → 回编辑器渲染 → 冻结时间。
|
||||
// 编辑器态默认 timeScale=0(物理冻结 = UE 语义),Play 解冻
|
||||
// 状态权威 = GameFlow(EditorContext::flow);编辑器只是转换的
|
||||
// 发起者(Request*)与监听器(快照/恢复挂在 →Loading/→Stopped)
|
||||
bool IsPlaying() const
|
||||
{
|
||||
return m_Ctx.flow &&
|
||||
(m_Ctx.flow->IsIn(Engine::GameFlowState::Running) ||
|
||||
m_Ctx.flow->IsIn(Engine::GameFlowState::Paused));
|
||||
}
|
||||
bool IsPaused() const
|
||||
{
|
||||
return m_Ctx.flow &&
|
||||
m_Ctx.flow->IsIn(Engine::GameFlowState::Paused);
|
||||
}
|
||||
// Play:RequestStart → →Loading 监听器做快照 + 切 gameView(Viewport
|
||||
// 内嵌 primary 相机渲染,UE PIE 语义;不切全屏)→ 同步加载完成
|
||||
// CompleteLoading → Running 解冻;Stop:RequestStop → →Stopped 监听器
|
||||
// 快照原子换血恢复 → 回编辑器渲染。编辑器态默认冻结(GameFlow 构造
|
||||
// 即 timeScale=0),Play 解冻由 GameFlow 权威处理
|
||||
void TogglePlay();
|
||||
// PIE 暂停切换(UE Pause 语义):timeScale 0 ↔ 1
|
||||
// PIE 暂停切换(UE Pause 语义):Running ↔ Paused(timeScale 由
|
||||
// GameFlow 权威处理)。运行态才有意义(编辑器态本来就冻结,
|
||||
// Pause 按钮不出现)
|
||||
void TogglePause();
|
||||
|
||||
private:
|
||||
void DoPlay(); // TogglePlay 的 Play 半程(快照 + 切渲染 + 解冻)
|
||||
void DoStop(); // TogglePlay 的 Stop 半程(恢复 + 回编辑器 + 冻结)
|
||||
// GameFlow 监听器(Init 注册):编辑器快照/恢复挂在此处——
|
||||
// GameFlow 不知场景,转换的副作用由消费端自己挂
|
||||
void OnFlowEnterLoading(); // →Loading:快照 + 切 gameView + 同步完成加载
|
||||
void OnFlowEnterStopped(); // →Stopped:快照换血恢复 + 回编辑器渲染
|
||||
|
||||
// ---- 选中状态 ----
|
||||
// 同步描边:Renderer 落帧后 SelectionMask/Outline 只画选中实体。
|
||||
@@ -135,9 +152,9 @@ private:
|
||||
bool m_ShowLoadModal = false;
|
||||
char m_ScenePathBuf[256] = "scenes/sandbox.scene";
|
||||
|
||||
// PIE 状态:Play 时场景 YAML 内存快照,Stop 时原子换血恢复
|
||||
bool m_Playing = false;
|
||||
bool m_Paused = false; // PIE 暂停(timeScale=0;Stop 时复位)
|
||||
// PIE 镜像态(面板只读指针消费;权威 = GameFlow,Draw 开头同步)
|
||||
bool m_PlayingMirror = false;
|
||||
bool m_PausedMirror = false;
|
||||
std::string m_PlaySnapshot;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user