Renamed BaseComponent to ECS::Component, removed enabled, renamed Position to Base

This commit is contained in:
2026-01-30 17:32:16 +02:00
parent 16c1a2c620
commit ff062567d8
4 changed files with 17 additions and 59 deletions

View File

@@ -13,36 +13,18 @@
#include <concepts>
namespace Tourmaline::Systems::ECS {
class World;
}
struct Component {
public:
virtual ~Component() = default;
};
template <typename T>
concept isAComponent = std::derived_from<T, ECS::Component>;
} // namespace Tourmaline::Systems::ECS
namespace Tourmaline::Systems::Components {
// Base
struct BaseComponent {
public:
virtual ~BaseComponent() = default;
};
template <typename T>
concept Component = std::derived_from<T, BaseComponent>;
// Builtin
struct Position : public BaseComponent {
Position(double x = 0, double y = 0, double z = 0) : x(x), y(y), z(z) {}
double x, y, z;
};
struct Enabled : public BaseComponent {
Enabled(ECS::World *world) : ownerWorld(world) {}
[[nodiscard]]
bool isEnabled();
void setEnabled(bool enable = true);
private:
bool enabled = true;
ECS::World *ownerWorld;
friend ECS::World;
struct Base : public ECS::Component {
Base() {}
};
} // namespace Tourmaline::Systems::Components
#endif