Helios Engine 0.1.0
A modular ECS based data-oriented C++23 game engine
 
Loading...
Searching...
No Matches
commands.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <helios/core_pch.hpp>
4
14
15#include <concepts>
16#include <ranges>
17#include <tuple>
18#include <type_traits>
19#include <utility>
20#include <vector>
21
22namespace helios::ecs::details {
23
24/**
25 * @brief Command that executes a function with World reference.
26 * @details Wraps arbitrary functions for deferred execution during
27 * World::Update(). The function must be invocable with a World& parameter.
28 * @tparam F Function type that accepts World&
29 */
30template <typename F>
31 requires std::invocable<F, World&>
32class FunctionCmd final : public Command {
33public:
34 /**
35 * @brief Constructs function command.
36 * @tparam G Type of function to wrap
37 * @param func Function to execute, must accept World& parameter
38 */
39 template <typename G>
40 requires std::invocable<G, World&> && std::constructible_from<F, G&&>
41 explicit constexpr FunctionCmd(G&& func) noexcept(std::is_nothrow_constructible_v<F, G&&>)
42 : func_(std::forward<G>(func)) {}
43
44 constexpr FunctionCmd(const FunctionCmd&) noexcept(std::is_nothrow_copy_constructible_v<F>) = default;
47
50
51 /**
52 * @brief Executes the wrapped function.
53 * @param world World reference to pass to the function
54 */
55 void Execute(World& world) override { func_(world); }
56
57private:
58 F func_; ///< Stored function to execute
59};
60
61/**
62 * @brief Command to destroy a single entity.
63 * @details Removes entity and all its components from the world during
64 * execution. Will assert if the world does not own (entity index/generation
65 * mismatch) the entity.
66 */
68public:
69 /**
70 * @brief Constructs destroy entity command.
71 * @warning Triggers assertion if entity is invalid.
72 * @param entity Entity to destroy
73 */
74 explicit constexpr DestroyEntityCmd(Entity entity) noexcept;
75 constexpr DestroyEntityCmd(const DestroyEntityCmd&) noexcept = default;
78
81
82 /**
83 * @brief Executes entity destruction.
84 * @param world World to remove entity from
85 */
86 void Execute(World& world) override { world.DestroyEntity(entity_); }
87
88private:
89 Entity entity_; ///< Entity to destroy
90};
91
92constexpr DestroyEntityCmd::DestroyEntityCmd(Entity entity) noexcept : entity_(entity) {
93 HELIOS_ASSERT(entity.Valid(), "Failed to construct destroy entity command: Entity with index '{}' is invalid!",
94 entity.Index());
95}
96
97/**
98 * @brief Command to destroy multiple entities.
99 * @details Efficiently destroys multiple entities in a single operation.
100 * Will assert if any of the entities do not exist in the world (when world
101 * implementation updated).
102 */
104public:
105 /**
106 * @brief Constructs destroy entities command from range.
107 * @warning Triggers assertion if any entity is invalid.
108 * @tparam R Range type containing Entity elements
109 * @param entities Range of entities to destroy
110 */
111 template <std::ranges::range R>
112 requires std::same_as<std::ranges::range_value_t<R>, Entity>
113 explicit constexpr DestroyEntitiesCmd(const R& entities);
114 constexpr DestroyEntitiesCmd(const DestroyEntitiesCmd&) noexcept = default;
117
120
121 /**
122 * @brief Executes entities destruction.
123 * @param world World to remove entities from
124 */
125 void Execute(World& world) override { world.DestroyEntities(entities_); }
126
127private:
128 std::vector<Entity> entities_; ///< Entities to destroy
129};
130
131template <std::ranges::range R>
132 requires std::same_as<std::ranges::range_value_t<R>, Entity>
134 : entities_(std::ranges::begin(entities), std::ranges::end(entities)) {
135 for (const Entity& entity : entities_) {
136 HELIOS_ASSERT(entity.Valid(), "Failed to construct destroy entities command: Entity with index '{}' is invalid!",
137 entity.Index());
138 }
139}
140
141/**
142 * @brief Command to try destroy a single entity.
143 * @details Will destroy the entity only if it exists in the world. Invalid
144 * entity handle still asserts.
145 */
147public:
148 /**
149 * @brief Constructs try destroy entity command.
150 * @warning Triggers assertion if entity is invalid.
151 * @param entity Entity to destroy
152 */
153 explicit constexpr TryDestroyEntityCmd(Entity entity) noexcept;
154 constexpr TryDestroyEntityCmd(const TryDestroyEntityCmd&) noexcept = default;
157
160
161 /**
162 * @brief Executes entity destruction if it exists.
163 * @param world World to remove entity from
164 */
165 void Execute(World& world) override { world.TryDestroyEntity(entity_); }
166
167private:
168 Entity entity_;
169};
170
171constexpr TryDestroyEntityCmd::TryDestroyEntityCmd(Entity entity) noexcept : entity_(entity) {
172 HELIOS_ASSERT(entity.Valid(), "Failed to construct try destroy entity command: Entity with index '{}' is invalid!",
173 entity.Index());
174}
175
176/**
177 * @brief Command to try destroy multiple entities.
178 */
180public:
181 /**
182 * @brief Constructs try destroy entities command from range.
183 * @warning Triggers assertion if any entity is invalid.
184 * @tparam R Range type containing Entity elements
185 * @param entities Range of entities to destroy
186 */
187 template <std::ranges::range R>
188 requires std::same_as<std::ranges::range_value_t<R>, Entity>
189 explicit constexpr TryDestroyEntitiesCmd(const R& entities);
190 constexpr TryDestroyEntitiesCmd(const TryDestroyEntitiesCmd&) noexcept = default;
193
196
197 /**
198 * @brief Executes entities destruction if they exist.
199 * @param world World to remove entities from
200 */
201 void Execute(World& world) override { world.TryDestroyEntities(entities_); }
202
203private:
204 std::vector<Entity> entities_;
205};
206
207template <std::ranges::range R>
208 requires std::same_as<std::ranges::range_value_t<R>, Entity>
210 : entities_(std::ranges::begin(entities), std::ranges::end(entities)) {
211 for (const Entity& entity : entities_) {
212 HELIOS_ASSERT(entity.Valid(),
213 "Failed to construct try destroy entities command: Entity with index '{}' is invalid!",
214 entity.Index());
215 }
216}
217
218/**
219 * @brief Command to add a component to an entity.
220 * @details Adds component of type T to the specified entity during execution.
221 * If entity already has the component, it will be replaced.
222 * @tparam T Component type to add
223 */
224template <ComponentTrait T>
226public:
227 /**
228 * @brief Constructs add component command with copy.
229 * @warning Triggers assertion if entity is invalid.
230 * @param entity Entity to add component to
231 * @param component Component to copy
232 */
233 constexpr AddComponentCmd(Entity entity, const T& component) noexcept(std::is_nothrow_copy_constructible_v<T>);
234
235 /**
236 * @brief Constructs add component command with move.
237 * @warning Triggers assertion if entity is invalid.
238 * @param entity Entity to add component to
239 * @param component Component to move
240 */
241 constexpr AddComponentCmd(Entity entity, T&& component) noexcept(std::is_nothrow_move_constructible_v<T>);
242 constexpr AddComponentCmd(const AddComponentCmd&) noexcept(std::is_nothrow_copy_constructible_v<T>) = default;
245
248
249 /**
250 * @brief Executes component addition.
251 * @param world World to add component in
252 */
253 void Execute(World& world) override { world.AddComponent(entity_, std::move(component_)); }
254
255private:
256 Entity entity_; ///< Entity to add component to
257 T component_; ///< Component to add
258};
259
260template <ComponentTrait T>
262 const T& component) noexcept(std::is_nothrow_copy_constructible_v<T>)
263 : entity_(entity), component_(component) {
264 HELIOS_ASSERT(entity.Valid(), "Failed to construct add component command: Entity with index '{}' is invalid!",
265 entity.Index());
266}
267
268template <ComponentTrait T>
270 T&& component) noexcept(std::is_nothrow_move_constructible_v<T>)
271 : entity_(entity), component_(std::move(component)) {
272 HELIOS_ASSERT(entity.Valid(), "Failed to construct add component command: Entity with index '{}' is invalid!",
273 entity.Index());
274}
275
276/**
277 * @brief Command to add multiple components to an entity.
278 * @details Efficiently adds multiple components in a single operation.
279 * @tparam Ts Component types to add (must be unique)
280 */
281template <ComponentTrait... Ts>
282 requires utils::UniqueTypes<Ts...>
284public:
285 /// @cond DOXYGEN_SKIP
286 /**
287 * @brief Constructs add components command.
288 * @warning Triggers assertion if entity is invalid.
289 * @param entity Entity to add components to
290 * @param components Components to add
291 */
292 explicit(sizeof...(Ts) == 0) constexpr AddComponentsCmd(Entity entity, Ts&&... components) noexcept
293 : entity_(entity), components_(std::forward<Ts>(components)...) {
294 HELIOS_ASSERT(entity.Valid(),
295 "Failed to construct add components command: Entity with "
296 "index '{}' is invalid!",
297 entity.Index());
298 }
299 /// @endcond
300
301 constexpr AddComponentsCmd(const AddComponentsCmd&) noexcept = default;
304
307
308 /**
309 * @brief Executes components addition.
310 * @param world World to add components in
311 */
313
314private:
315 Entity entity_; ///< Entity to add components to
316 std::tuple<Ts...> components_; ///< Components to add
317};
318
320 requires utils::UniqueTypes<Ts...>
322 std::apply([&world, this](auto&&... args) { world.AddComponents(entity_, std::forward<decltype(args)>(args)...); },
323 std::move(components_));
324}
325
326/**
327 * @brief Command to try add a component (only if missing).
328 * @tparam T Component type
329 */
330template <ComponentTrait T>
332public:
333 /**
334 * @brief Constructs try add component command with copy.
335 * @warning Triggers assertion if entity is invalid.
336 * @param entity Entity to add component to
337 * @param component Component to copy
338 */
339 constexpr TryAddComponentCmd(Entity entity, const T& component) noexcept(std::is_nothrow_copy_constructible_v<T>);
340
341 /**
342 * @brief Constructs try add component command with move.
343 * @warning Triggers assertion if entity is invalid.
344 * @param entity Entity to add component to
345 * @param component Component to move
346 */
347 constexpr TryAddComponentCmd(Entity entity, T&& component) noexcept(std::is_nothrow_move_constructible_v<T>);
348 constexpr TryAddComponentCmd(const TryAddComponentCmd&) noexcept = default;
351
354
355 /**
356 * @brief Executes component addition if entity is missing it.
357 * @param world World to add component in
358 */
359 void Execute(World& world) override { world.TryAddComponent(entity_, std::move(component_)); }
360
361private:
362 Entity entity_;
363 T component_;
364};
365
366template <ComponentTrait T>
367constexpr TryAddComponentCmd<T>::TryAddComponentCmd(Entity entity, const T& component) noexcept(
368 std::is_nothrow_copy_constructible_v<T>)
369 : entity_(entity), component_(component) {
370 HELIOS_ASSERT(entity.Valid(), "Failed to construct try add component command: Entity with index '{}' is invalid!",
371 entity.Index());
372}
373
374template <ComponentTrait T>
376 T&& component) noexcept(std::is_nothrow_move_constructible_v<T>)
377 : entity_(entity), component_(std::move(component)) {
378 HELIOS_ASSERT(entity.Valid(), "Failed to construct try add component command: Entity with index '{}' is invalid!",
379 entity.Index());
380}
381
382/**
383 * @brief Command to try add multiple components (only missing ones).
384 * @tparam Ts Component types (must be unique)
385 */
386template <ComponentTrait... Ts>
387 requires utils::UniqueTypes<Ts...>
389public:
390 /// @cond DOXYGEN_SKIP
391 /**
392 * @brief Constructs try add components command.
393 * @warning Triggers assertion if entity is invalid.
394 * @param entity Entity to add components to
395 * @param components Components to add
396 */
397 explicit(sizeof...(Ts) == 0) constexpr TryAddComponentsCmd(Entity entity, Ts&&... components) noexcept;
398 /// @endcond
399
400 constexpr TryAddComponentsCmd(const TryAddComponentsCmd&) noexcept = default;
403
406
407 /**
408 * @brief Executes components addition if entity is missing them.
409 * @param world World to add components in
410 */
411 void Execute(World& world) override;
412
413private:
414 Entity entity_;
415 std::tuple<Ts...> components_;
416};
417
418/// @cond DOXYGEN_SKIP
420 requires utils::UniqueTypes<Ts...>
422 : entity_(entity), components_(std::forward<Ts>(components)...) {
423 HELIOS_ASSERT(entity.Valid(),
424 "Failed to construct try add components command: Entity with "
425 "index '{}' is invalid!",
426 entity.Index());
427}
428/// @endcond
429
430template <ComponentTrait... Ts>
431 requires utils::UniqueTypes<Ts...>
433 std::apply([&world, this](auto&&... args) { world.TryAddComponents(entity_, std::forward<decltype(args)>(args)...); },
434 std::move(components_));
435}
436
437/**
438 * @brief Command to remove a component from an entity.
439 * @details Removes component of type T from the specified entity during execution.
440 * @tparam T Component type to remove
441 */
442template <ComponentTrait T>
444public:
445 /**
446 * @brief Constructs remove component command.
447 * @warning Triggers assertion if entity is invalid.
448 * @param entity Entity to remove component from
449 */
450 explicit constexpr RemoveComponentCmd(Entity entity) noexcept;
451 constexpr RemoveComponentCmd(const RemoveComponentCmd&) noexcept = default;
454
457
458 /**
459 * @brief Executes component removal.
460 * @param world World to remove component from
461 */
462 void Execute(World& world) override { world.RemoveComponent<T>(entity_); }
463
464private:
465 Entity entity_; ///< Entity to remove component from
466};
467
468template <ComponentTrait T>
469constexpr RemoveComponentCmd<T>::RemoveComponentCmd(Entity entity) noexcept : entity_(entity) {
470 HELIOS_ASSERT(entity.Valid(), "Failed to construct remove component command: Entity with index '{}' is invalid!",
471 entity.Index());
472}
473
474/**
475 * @brief Command to remove multiple components from an entity.
476 * @details Efficiently removes multiple components in a single operation.
477 * @tparam Ts Component types to remove (must be unique)
478 */
479template <ComponentTrait... Ts>
480 requires utils::UniqueTypes<Ts...>
482public:
483 /**
484 * @brief Constructs remove components command.
485 * @warning Triggers assertion if entity is invalid.
486 * @param entity Entity to remove components from
487 */
488 explicit constexpr RemoveComponentsCmd(Entity entity) noexcept;
489 constexpr RemoveComponentsCmd(const RemoveComponentsCmd&) noexcept = default;
492
495
496 /**
497 * @brief Executes components removal.
498 * @param world World to remove components from
499 */
500 void Execute(World& world) override { world.RemoveComponents<Ts...>(entity_); }
501
502private:
503 Entity entity_; ///< Entity to remove components from
504};
505
506template <ComponentTrait... Ts>
507 requires utils::UniqueTypes<Ts...>
509 HELIOS_ASSERT(entity.Valid(), "Failed to construct remove components command: Entity with index '{}' is invalid!",
510 entity.Index());
511}
512
513/**
514 * @brief Command to try remove a single component (only if present).
515 * @tparam T Component type
516 */
517template <ComponentTrait T>
519public:
520 /**
521 * @brief Constructs try remove component command.
522 * @warning Triggers assertion if entity is invalid.
523 * @param entity Entity to remove component from
524 */
525 explicit constexpr TryRemoveComponentCmd(Entity entity) noexcept;
526 constexpr TryRemoveComponentCmd(const TryRemoveComponentCmd&) noexcept = default;
529
532
533 /**
534 * @brief Executes component removal if entity has it.
535 * @param world World to remove component from
536 */
537 void Execute(World& world) override { world.TryRemoveComponent<T>(entity_); }
538
539private:
540 Entity entity_; ///< Entity to remove component from
541};
542
543template <ComponentTrait T>
545 HELIOS_ASSERT(entity.Valid(), "Failed to construct try remove component command: Entity with index '{}' is invalid!",
546 entity.Index());
547}
548
549/**
550 * @brief Command to try remove multiple components (only those present).
551 * @tparam Ts Component types (must be unique)
552 */
553template <ComponentTrait... Ts>
554 requires utils::UniqueTypes<Ts...>
556public:
557 /**
558 * @brief Constructs try remove components command.
559 * @warning Triggers assertion if entity is invalid.
560 * @param entity Entity to remove components from
561 */
562 explicit constexpr TryRemoveComponentsCmd(Entity entity) noexcept;
563 constexpr TryRemoveComponentsCmd(const TryRemoveComponentsCmd&) noexcept = default;
566
569
570 /**
571 * @brief Executes components removal if entity has them.
572 * @param world World to remove components from
573 */
574 void Execute(World& world) override { world.TryRemoveComponents<Ts...>(entity_); }
575
576private:
577 Entity entity_; ///< Entity to remove components from
578};
579
580template <ComponentTrait... Ts>
581 requires utils::UniqueTypes<Ts...>
583 HELIOS_ASSERT(entity.Valid(), "Failed to construct try remove components command: Entity with index '{}' is invalid!",
584 entity.Index());
585}
586
587/**
588 * @brief Command to clear all components from an entity.
589 * @details Removes all components from the specified entity during execution.
590 */
592public:
593 /**
594 * @brief Constructs clear components command.
595 * @warning Triggers assertion if entity is invalid.
596 * @param entity Entity to clear components from
597 */
598 explicit constexpr ClearComponentsCmd(Entity entity) noexcept;
599 constexpr ClearComponentsCmd(const ClearComponentsCmd&) noexcept = default;
602
605
606 /**
607 * @brief Executes component clearing.
608 * @param world World to clear components in
609 */
610 void Execute(World& world) override { world.ClearComponents(entity_); }
611
612private:
613 Entity entity_; ///< Entity to clear components from
614};
615
616constexpr ClearComponentsCmd::ClearComponentsCmd(Entity entity) noexcept : entity_(entity) {
617 HELIOS_ASSERT(entity.Valid(), "Failed to construct clear components command: Entity with index '{}' is invalid!",
618 entity.Index());
619}
620
621/**
622 * @brief Command to insert a resource into the world.
623 * @details Adds resource of type T to the world during execution.
624 * If world already has the resource, it will be replaced.
625 * @tparam T Resource type to insert
626 */
627template <ResourceTrait T>
629public:
630 /**
631 * @brief Constructs insert resource command with copy.
632 * @param resource Resource to copy
633 */
634 explicit constexpr InsertResourceCmd(const T& resource) noexcept(std::is_nothrow_copy_constructible_v<T>)
635 : resource_(resource) {}
636
637 /**
638 * @brief Constructs insert resource command with move.
639 * @param resource Resource to move
640 */
641 explicit constexpr InsertResourceCmd(T&& resource) noexcept(std::is_nothrow_move_constructible_v<T>)
642 : resource_(std::move(resource)) {}
643
644 constexpr InsertResourceCmd(const InsertResourceCmd&) noexcept(std::is_nothrow_copy_constructible_v<T>) = default;
647
649 default;
650
652
653 /**
654 * @brief Executes resource insertion.
655 * @param world World to insert resource into
656 */
657 void Execute(World& world) override { world.InsertResource(std::move(resource_)); }
658
659private:
660 T resource_; ///< Resource to insert
661};
662
663/**
664 * @brief Command to try insert a resource (only if missing).
665 * @tparam T Resource type
666 */
667template <ResourceTrait T>
669public:
670 /**
671 * @brief Constructs try insert resource command with copy.
672 * @param resource Resource to copy
673 */
674 explicit constexpr TryInsertResourceCmd(const T& resource) noexcept(std::is_nothrow_copy_constructible_v<T>)
675 : resource_(resource) {}
676
677 /**
678 * @brief Constructs try insert resource command with move.
679 * @param resource Resource to move
680 */
681 explicit constexpr TryInsertResourceCmd(T&& resource) noexcept(std::is_nothrow_move_constructible_v<T>)
682 : resource_(std::move(resource)) {}
683
684 constexpr TryInsertResourceCmd(const TryInsertResourceCmd&) noexcept = default;
687
690
691 /**
692 * @brief Executes resource insertion if it doesn't exist.
693 * @param world World to insert resource into
694 */
695 void Execute(World& world) override { world.TryInsertResource(std::move(resource_)); }
696
697private:
698 T resource_; ///< Resource to insert
699};
700
701/**
702 * @brief Command to remove a resource from the world.
703 * @details Removes resource of type T from the world during execution.
704 * @tparam T Resource type to remove
705 */
706template <ResourceTrait T>
708public:
713
716
717 /**
718 * @brief Executes resource removal.
719 * @param world World to remove resource from
720 */
721 void Execute(World& world) override { world.RemoveResource<T>(); }
722};
723
724/**
725 * @brief Command to try remove a resource (only if present).
726 * @tparam T Resource type
727 */
728template <ResourceTrait T>
745
746/**
747 * @brief Command to clear all events of a specific type from the queue.
748 * @tparam T Event type to clear
749 */
750template <EventTrait T>
752public:
757
760
761 /**
762 * @brief Executes the command to clear events of type T.
763 * @param world Reference to the world
764 */
765 void Execute(World& world) override { world.ClearEvents<T>(); }
766};
767
768/**
769 * @brief Command to clear all event queues without removing registration.
770 */
772public:
777
780
781 /**
782 * @brief Executes the command to clear all event queues.
783 * @param world Reference to the world
784 */
785 void Execute(World& world) override { world.ClearAllEventQueues(); }
786};
787
788} // namespace helios::ecs::details
#define HELIOS_ASSERT(condition,...)
Assertion macro that aborts execution in debug builds.
Definition assert.hpp:140
Base class for all commands to be executed in the world.
Definition command.hpp:12
Unique identifier for entities with generation counter to handle recycling.
Definition entity.hpp:21
constexpr bool Valid() const noexcept
Checks if the entity is valid.
Definition entity.hpp:58
constexpr IndexType Index() const noexcept
Gets the index component of the entity.
Definition entity.hpp:75
The World class manages entities with their components and systems.
Definition world.hpp:53
Command to add a component to an entity.
Definition commands.hpp:225
void Execute(World &world) override
Executes component addition.
Definition commands.hpp:253
constexpr AddComponentCmd(Entity entity, const T &component) noexcept(std::is_nothrow_copy_constructible_v< T >)
Constructs add component command with copy.
Definition commands.hpp:261
constexpr AddComponentCmd(const AddComponentCmd &) noexcept(std::is_nothrow_copy_constructible_v< T >)=default
constexpr AddComponentCmd(AddComponentCmd &&) noexcept(std::is_nothrow_move_constructible_v< T >)=default
Command to add multiple components to an entity.
Definition commands.hpp:283
constexpr AddComponentsCmd(AddComponentsCmd &&) noexcept=default
constexpr AddComponentsCmd(const AddComponentsCmd &) noexcept=default
void Execute(World &world) override
Executes components addition.
Definition commands.hpp:321
Command to clear all event queues without removing registration.
Definition commands.hpp:771
constexpr ClearAllEventsCmd() noexcept=default
Command to clear all components from an entity.
Definition commands.hpp:591
constexpr ClearComponentsCmd(const ClearComponentsCmd &) noexcept=default
constexpr ClearComponentsCmd(ClearComponentsCmd &&) noexcept=default
Command to clear all events of a specific type from the queue.
Definition commands.hpp:751
constexpr ClearEventsCmd() noexcept=default
Command to destroy multiple entities.
Definition commands.hpp:103
constexpr DestroyEntitiesCmd(DestroyEntitiesCmd &&) noexcept=default
constexpr DestroyEntitiesCmd(const DestroyEntitiesCmd &) noexcept=default
constexpr DestroyEntitiesCmd(const R &entities)
Constructs destroy entities command from range.
Definition commands.hpp:133
void Execute(World &world) override
Executes entities destruction.
Definition commands.hpp:125
Command to destroy a single entity.
Definition commands.hpp:67
constexpr DestroyEntityCmd(Entity entity) noexcept
Constructs destroy entity command.
Definition commands.hpp:92
void Execute(World &world) override
Executes entity destruction.
Definition commands.hpp:86
constexpr DestroyEntityCmd(DestroyEntityCmd &&) noexcept=default
constexpr DestroyEntityCmd(const DestroyEntityCmd &) noexcept=default
Command that executes a function with World reference.
Definition commands.hpp:32
constexpr FunctionCmd(const FunctionCmd &) noexcept(std::is_nothrow_copy_constructible_v< F >)=default
constexpr FunctionCmd(FunctionCmd &&) noexcept(std::is_nothrow_move_constructible_v< F >)=default
constexpr FunctionCmd(G &&func) noexcept(std::is_nothrow_constructible_v< F, G && >)
Constructs function command.
Definition commands.hpp:41
void Execute(World &world) override
Executes the wrapped function.
Definition commands.hpp:55
Command to insert a resource into the world.
Definition commands.hpp:628
constexpr InsertResourceCmd(const T &resource) noexcept(std::is_nothrow_copy_constructible_v< T >)
Constructs insert resource command with copy.
Definition commands.hpp:634
constexpr InsertResourceCmd(const InsertResourceCmd &) noexcept(std::is_nothrow_copy_constructible_v< T >)=default
constexpr InsertResourceCmd(InsertResourceCmd &&) noexcept(std::is_nothrow_move_constructible_v< T >)=default
constexpr InsertResourceCmd(T &&resource) noexcept(std::is_nothrow_move_constructible_v< T >)
Constructs insert resource command with move.
Definition commands.hpp:641
Command to remove a component from an entity.
Definition commands.hpp:443
constexpr RemoveComponentCmd(const RemoveComponentCmd &) noexcept=default
constexpr RemoveComponentCmd(RemoveComponentCmd &&) noexcept=default
Command to remove multiple components from an entity.
Definition commands.hpp:481
constexpr RemoveComponentsCmd(RemoveComponentsCmd &&) noexcept=default
constexpr RemoveComponentsCmd(const RemoveComponentsCmd &) noexcept=default
Command to remove a resource from the world.
Definition commands.hpp:707
constexpr RemoveResourceCmd() noexcept=default
Command to try add a component (only if missing).
Definition commands.hpp:331
constexpr TryAddComponentCmd(Entity entity, const T &component) noexcept(std::is_nothrow_copy_constructible_v< T >)
Constructs try add component command with copy.
Definition commands.hpp:367
constexpr TryAddComponentCmd(TryAddComponentCmd &&) noexcept=default
constexpr TryAddComponentCmd(const TryAddComponentCmd &) noexcept=default
Command to try add multiple components (only missing ones).
Definition commands.hpp:388
constexpr TryAddComponentsCmd(const TryAddComponentsCmd &) noexcept=default
constexpr TryAddComponentsCmd(TryAddComponentsCmd &&) noexcept=default
Command to try destroy multiple entities.
Definition commands.hpp:179
void Execute(World &world) override
Executes entities destruction if they exist.
Definition commands.hpp:201
constexpr TryDestroyEntitiesCmd(TryDestroyEntitiesCmd &&) noexcept=default
constexpr TryDestroyEntitiesCmd(const R &entities)
Constructs try destroy entities command from range.
Definition commands.hpp:209
constexpr TryDestroyEntitiesCmd(const TryDestroyEntitiesCmd &) noexcept=default
Command to try destroy a single entity.
Definition commands.hpp:146
constexpr TryDestroyEntityCmd(const TryDestroyEntityCmd &) noexcept=default
constexpr TryDestroyEntityCmd(TryDestroyEntityCmd &&) noexcept=default
constexpr TryDestroyEntityCmd(Entity entity) noexcept
Constructs try destroy entity command.
Definition commands.hpp:171
void Execute(World &world) override
Executes entity destruction if it exists.
Definition commands.hpp:165
Command to try insert a resource (only if missing).
Definition commands.hpp:668
constexpr TryInsertResourceCmd(const T &resource) noexcept(std::is_nothrow_copy_constructible_v< T >)
Constructs try insert resource command with copy.
Definition commands.hpp:674
constexpr TryInsertResourceCmd(T &&resource) noexcept(std::is_nothrow_move_constructible_v< T >)
Constructs try insert resource command with move.
Definition commands.hpp:681
constexpr TryInsertResourceCmd(const TryInsertResourceCmd &) noexcept=default
constexpr TryInsertResourceCmd(TryInsertResourceCmd &&) noexcept=default
Command to try remove a single component (only if present).
Definition commands.hpp:518
constexpr TryRemoveComponentCmd(const TryRemoveComponentCmd &) noexcept=default
constexpr TryRemoveComponentCmd(TryRemoveComponentCmd &&) noexcept=default
Command to try remove multiple components (only those present).
Definition commands.hpp:555
constexpr TryRemoveComponentsCmd(TryRemoveComponentsCmd &&) noexcept=default
constexpr TryRemoveComponentsCmd(const TryRemoveComponentsCmd &) noexcept=default
Command to try remove a resource (only if present).
Definition commands.hpp:729
constexpr TryRemoveResourceCmd() noexcept=default
Concept to check if a type can be used as a component.
Definition component.hpp:39
BasicQuery< World, Allocator, Components... > Query
Type alias for query with mutable world access.
Definition query.hpp:2481
STL namespace.