VisuTwin Canvas
C++ 3D Engine — Metal Backend
Loading...
Searching...
No Matches
component.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2025-2026 Arnis Lektauers
3//
4// Created by Arnis Lektauers on 09.09.2025.
5//
6#include "component.h"
7
8#include "framework/entity.h"
9
10namespace visutwin::canvas
11{
15
17 {
18 return _entity;
19 }
20
21 void Component::setEnabled(const bool value)
22 {
23 const bool oldValue = _enabled;
24 _enabled = value;
25 onSetEnabled(oldValue, value);
26 }
27
28 void Component::onSetEnabled(const bool oldValue, const bool newValue)
29 {
30 if (oldValue != newValue) {
31 if (_entity && _entity->enabled()) {
32 if (newValue) {
33 onEnable();
34 } else {
35 onDisable();
36 }
37 }
38 }
39 }
40}
Entity * entity() const
Definition component.cpp:16
virtual void onSetEnabled(bool oldValue, bool newValue)
Definition component.cpp:28
Component(IComponentSystem *system, Entity *entity)
Definition component.cpp:12
virtual void onEnable()
Definition component.h:56
virtual void onDisable()
Definition component.h:59
virtual void setEnabled(bool value)
Definition component.cpp:21
IComponentSystem * system() const
Definition component.h:47
ECS entity — a GraphNode that hosts components defining its behavior.
Definition entity.h:32