feat(ui): rework renderer to work with deltatime and ui rendering
This commit is contained in:
parent
b359f36fb7
commit
842c8fb19d
@ -5,50 +5,14 @@
|
|||||||
|
|
||||||
class SceneManager {
|
class SceneManager {
|
||||||
public:
|
public:
|
||||||
SceneManager(entt::registry& registry) : registry(registry), activeScene(entt::null) {}
|
SceneManager(entt::registry& registry);
|
||||||
|
|
||||||
void SetActiveScene(entt::entity scene) {
|
|
||||||
if (activeScene != entt::null) {
|
|
||||||
auto& currentScene = registry.get<SceneComponent>(activeScene);
|
|
||||||
currentScene.isActive = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
activeScene = scene;
|
|
||||||
auto& newScene = registry.get<SceneComponent>(activeScene);
|
|
||||||
newScene.isActive = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
entt::entity CreateScene() {
|
|
||||||
entt::entity scene = registry.create();
|
|
||||||
registry.emplace<SceneComponent>(scene, false);
|
|
||||||
return scene;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UpdateActiveScene() {
|
|
||||||
if (activeScene != entt::null) {
|
|
||||||
// Iterate over entities in the active scene that have an InputComponent
|
|
||||||
auto view = registry.view<InputComponent>();
|
|
||||||
for (auto entity : view) {
|
|
||||||
auto& inputComponent = view.get<InputComponent>(entity);
|
|
||||||
inputComponent.Update(); // This will call the input logic
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderActiveScene() {
|
|
||||||
if (activeScene != entt::null) {
|
|
||||||
// Iterate over entities in the active scene that have both SpriteComponent and TransformComponent
|
|
||||||
auto view = registry.view<SpriteComponent, TransformComponent>();
|
|
||||||
for (auto entity : view) {
|
|
||||||
auto& sprite = view.get<SpriteComponent>(entity);
|
|
||||||
auto& transform = view.get<TransformComponent>(entity);
|
|
||||||
|
|
||||||
// Render the sprite at the position defined by the TransformComponent
|
|
||||||
sprite.Render(transform);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
void SetActiveScene(entt::entity scene);
|
||||||
|
entt::entity CreateScene();
|
||||||
|
void UpdateActiveScene(float delta);
|
||||||
|
void RenderActiveScene();
|
||||||
|
void UpdateUI(entt::registry& registry);
|
||||||
|
void RenderUI(entt::registry& registry);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
entt::registry& registry;
|
entt::registry& registry;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user