CoriEngine
Loading...
Searching...
No Matches
WorldSystem/Systems/Animation.cpp
Go to the documentation of this file.
1#include "Animation.hpp"
3
4namespace Cori {
5 namespace World {
6 namespace Systems {
7 void Animation::OnTickUpdate([[maybe_unused]] Core::GameTimer& gameTimer) {
9
11
12 for (const auto entity : view) {
14 }
15 }
16
18 m_Owner.GetRegistry().on_construct<Components::Entity::QuadAnimator>().connect<&Animation::OnQuadAnimationCreate>(this);
19
20 m_EntityPool.Init(m_Owner,
21 [](SceneHandle& scene) -> Entity {
22 static uint32_t count = 0;
23 Entity entity = scene.CreateEntity<EntityTags::DisposableEntityTag>(std::format("Temporary entity {}", count));
26 ++count;
27 return entity;
28 },
29 [](Entity& entity) {
30 auto& tr = entity.GetComponents<Components::Entity::Transform>();
31 tr.SetLocalScale({ 0.0f, 0.0f });
32 entity.UnlinkFromParent();
33 entity.DestroyChildren();
34 });
35
36 return true;
37 }
38
39 void Animation::OnQuadAnimationCreate(entt::registry& registry, entt::entity entity) {
40 Entity e = entt::handle{ registry, entity };
42 qa.m_Entity = e;
44 renderer.m_AnimatorBound = true;
45 }
46 }
47 }
48}
#define CORI_PROFILE_FUNCTION()
Definition Profiler.hpp:9
A GameTimer is responsible for managing everything that is connected with time, ticks,...
Definition Time.hpp:8
Responsible for playing animations when attached to an entity.
Entities are the essential part of WorldSystem.
Definition Entity.hpp:25
T & GetOrAddComponent(Args &&... args)
Retries or adds a component to the entity.
Definition Entity.hpp:112
T & AddComponent(Args &&... args)
Adds a component to the entity.
Definition Entity.hpp:39
decltype(auto) GetComponents()
Retries the references to the requested components of the entity.
Definition Entity.hpp:74
A handle for the scene, checks for scene validity before any call to the scene, if scene is invalid a...
Entity CreateEntity(const std::string &name)
Creates an Entity with a default set of components.
A wrapper for an EnTT compile-time view that provides an iterator to access Entity instances directly...
decltype(auto) Get(Entity entity)
Retries the components from an entity, both the components and the entity should be in a view,...
SceneHandle m_Owner
Definition System.hpp:38
void OnTickUpdate(Core::GameTimer &gameTimer) override
Anything connected to WorldSystem (ECS) is in this namespace.
Global engine namespace.
Every Entity has a transform component by default, essential for rendering.
void SetLocalScale(const glm::vec2 localScale)
Changes the local scale of the Entity.
Helper to exclude certain components from a static view.