R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
EntityBuilder.hpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2025
3** rtype
4** File description:
5** EntityBuilder - Fluent builder pattern for entity creation
6*/
7
8#pragma once
9
10#include <functional>
11#include <memory>
12#include "ECSWorld.hpp"
13
14namespace ecs::wrapper {
15
24 private:
25 // The world pointer is kept for API completeness; some builds may not
26 // reference it directly which can trigger unused-field warnings.
27 [[maybe_unused]] ECSWorld *_world;
29
30 public:
36 explicit EntityBuilder(ECSWorld *world);
37
45 template <typename T>
46 EntityBuilder &with(const T &component);
47
55 template <typename T>
56 EntityBuilder &with(std::function<T()> factory);
57
70 EntityBuilder &configure(std::function<void(Entity &)> configurator);
71
77 Entity build();
78
82 operator Entity();
83 };
84
85} // namespace ecs::wrapper
86
87#include "EntityBuilder.tpp"
High-level ECS manager providing clean server-side API.
Definition ECSWorld.hpp:122
Builder pattern for creating entities with multiple components.
EntityBuilder & with(std::function< T()> factory)
Add a component using a factory function.
EntityBuilder & configure(std::function< void(Entity &)> configurator)
Apply a configuration function to the entity.
EntityBuilder & with(const T &component)
Add a component to the entity being built.
Entity build()
Finalize and return the built entity.
High-level entity wrapper providing fluent interface.
Definition ECSWorld.hpp:33