R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
IComponent.hpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2025
3** RTYPE
4** File description:
5** IComponent
6*/
7
8#pragma once
9
10#include <atomic>
11#include <cstddef>
12
13namespace ecs {
19 using ComponentType = std::size_t;
20
31 class IComponent {
32 public:
36 virtual ~IComponent() = default;
37
42 virtual ComponentType getType() const = 0;
43 };
44
55 static std::atomic<ComponentType> lastID{0};
56 return lastID.fetch_add(1);
57 }
58
74 template <typename T>
76 static ComponentType typeID = getUniqueComponentType();
77 return typeID;
78 }
79} // namespace ecs
Base interface for all ECS components.
virtual ~IComponent()=default
Virtual destructor.
virtual ComponentType getType() const =0
Get the unique type identifier for this component.
Maximum number of distinct component types supported by the Registry.
Definition GameLogic.hpp:26
std::size_t ComponentType
Type alias for component identification.
ComponentType getUniqueComponentType()
Generates a unique ID for each component type.
ComponentType getComponentType()
Get the unique type ID for a specific component type.