VisuTwin Canvas
C++ 3D Engine — Metal Backend
Loading...
Searching...
No Matches
animationComponentSystem.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2025-2026 Arnis Lektauers
4
5#include "framework/entity.h"
6
7namespace visutwin::canvas
8{
10 : ComponentSystem(engine, "animation")
11 {
12 if (engine && engine->systems()) {
13 engine->systems()->on("animationUpdate", [this](const float dt) {
14 onAnimationUpdate(dt);
15 }, this);
16 }
17 }
18
20 {
21 if (_engine && _engine->systems()) {
22 _engine->systems()->off("animationUpdate", HandleEventCallback(), this);
23 }
24 }
25
26 void AnimationComponentSystem::onAnimationUpdate(const float dt)
27 {
28 for (auto* component : AnimationComponent::instances()) {
29 if (!component) {
30 continue;
31 }
32
33 Entity* entity = component->entity();
34 if (!entity) {
35 continue;
36 }
37
38 if (component->enabled() && entity->enabled()) {
39 component->update(dt);
40 }
41 }
42 }
43}
static const std::vector< AnimationComponent * > & instances()
Central application orchestrator managing scenes, rendering, input, and resource loading.
Definition engine.h:38
std::function< void(const EventArgs &)> HandleEventCallback