feat: add runtime play tick and play-mode scene editing semantics
This commit is contained in:
45
engine/include/XCEngine/Scene/RuntimeLoop.h
Normal file
45
engine/include/XCEngine/Scene/RuntimeLoop.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEngine/Scene/SceneRuntime.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace XCEngine {
|
||||
namespace Components {
|
||||
|
||||
class RuntimeLoop {
|
||||
public:
|
||||
struct Settings {
|
||||
float fixedDeltaTime = 1.0f / 50.0f;
|
||||
float maxFrameDeltaTime = 0.1f;
|
||||
uint32_t maxFixedStepsPerFrame = 4;
|
||||
};
|
||||
|
||||
explicit RuntimeLoop(Settings settings = {});
|
||||
|
||||
void SetSettings(const Settings& settings);
|
||||
const Settings& GetSettings() const { return m_settings; }
|
||||
|
||||
void Start(Scene* scene);
|
||||
void Stop();
|
||||
|
||||
void Tick(float deltaTime);
|
||||
void Pause();
|
||||
void Resume();
|
||||
void StepFrame();
|
||||
|
||||
bool IsRunning() const { return m_sceneRuntime.IsRunning(); }
|
||||
bool IsPaused() const { return m_paused; }
|
||||
Scene* GetScene() const { return m_sceneRuntime.GetScene(); }
|
||||
float GetFixedAccumulator() const { return m_fixedAccumulator; }
|
||||
|
||||
private:
|
||||
SceneRuntime m_sceneRuntime;
|
||||
Settings m_settings = {};
|
||||
float m_fixedAccumulator = 0.0f;
|
||||
bool m_paused = false;
|
||||
bool m_stepRequested = false;
|
||||
};
|
||||
|
||||
} // namespace Components
|
||||
} // namespace XCEngine
|
||||
Reference in New Issue
Block a user