|
4 | 4 | #include "ecsact/runtime/core.h"
|
5 | 5 |
|
6 | 6 | namespace ecsact_entt_rt {
|
7 |
| - struct execution_events_collector { |
8 |
| - const ecsact_execution_events_collector* target; |
9 | 7 |
|
10 |
| - inline bool has_init_callback() const { |
11 |
| - return target->init_callback != nullptr; |
12 |
| - } |
| 8 | +struct execution_events_collector { |
| 9 | + const ecsact_execution_events_collector* target; |
13 | 10 |
|
14 |
| - inline bool has_update_callback() const { |
15 |
| - return target->update_callback != nullptr; |
16 |
| - } |
| 11 | + inline bool has_init_callback() const { |
| 12 | + return target->init_callback != nullptr; |
| 13 | + } |
17 | 14 |
|
18 |
| - inline bool has_remove_callback() const { |
19 |
| - return target->remove_callback != nullptr; |
20 |
| - } |
| 15 | + inline bool has_update_callback() const { |
| 16 | + return target->update_callback != nullptr; |
| 17 | + } |
21 | 18 |
|
22 |
| - template<typename C> |
23 |
| - requires(!std::is_empty_v<C>) |
24 |
| - void invoke_init_callback |
25 |
| - ( ecsact_entity_id entity |
26 |
| - , const C& component |
27 |
| - ) |
28 |
| - { |
29 |
| - target->init_callback( |
30 |
| - ECSACT_EVENT_INIT_COMPONENT, |
31 |
| - static_cast<ecsact_entity_id>(entity), |
32 |
| - static_cast<ecsact_component_id>(C::id), |
33 |
| - static_cast<const void*>(&component), |
34 |
| - target->init_callback_user_data |
35 |
| - ); |
36 |
| - } |
| 19 | + inline bool has_remove_callback() const { |
| 20 | + return target->remove_callback != nullptr; |
| 21 | + } |
37 | 22 |
|
38 |
| - template<typename C> |
39 |
| - requires(std::is_empty_v<C>) |
40 |
| - void invoke_init_callback |
41 |
| - ( ecsact_entity_id entity |
42 |
| - ) |
43 |
| - { |
44 |
| - target->init_callback( |
45 |
| - ECSACT_EVENT_INIT_COMPONENT, |
46 |
| - static_cast<ecsact_entity_id>(entity), |
47 |
| - static_cast<ecsact_component_id>(C::id), |
48 |
| - nullptr, |
49 |
| - target->init_callback_user_data |
50 |
| - ); |
51 |
| - } |
| 23 | + template<typename C> |
| 24 | + requires(!std::is_empty_v<C>) |
| 25 | + void invoke_init_callback(ecsact_entity_id entity, const C& component) { |
| 26 | + target->init_callback( |
| 27 | + ECSACT_EVENT_INIT_COMPONENT, |
| 28 | + static_cast<ecsact_entity_id>(entity), |
| 29 | + static_cast<ecsact_component_id>(C::id), |
| 30 | + static_cast<const void*>(&component), |
| 31 | + target->init_callback_user_data |
| 32 | + ); |
| 33 | + } |
52 | 34 |
|
53 |
| - template<typename C> |
54 |
| - requires(!std::is_empty_v<C>) |
55 |
| - void invoke_update_callback |
56 |
| - ( ecsact_entity_id entity |
57 |
| - , const C& component |
58 |
| - ) |
59 |
| - { |
60 |
| - target->update_callback( |
61 |
| - ECSACT_EVENT_UPDATE_COMPONENT, |
62 |
| - static_cast<ecsact_entity_id>(entity), |
63 |
| - static_cast<ecsact_component_id>(C::id), |
64 |
| - static_cast<const void*>(&component), |
65 |
| - target->update_callback_user_data |
66 |
| - ); |
67 |
| - } |
| 35 | + template<typename C> |
| 36 | + requires(std::is_empty_v<C>) |
| 37 | + void invoke_init_callback(ecsact_entity_id entity) { |
| 38 | + target->init_callback( |
| 39 | + ECSACT_EVENT_INIT_COMPONENT, |
| 40 | + static_cast<ecsact_entity_id>(entity), |
| 41 | + static_cast<ecsact_component_id>(C::id), |
| 42 | + nullptr, |
| 43 | + target->init_callback_user_data |
| 44 | + ); |
| 45 | + } |
68 | 46 |
|
69 |
| - template<typename C> |
70 |
| - requires(std::is_empty_v<C>) |
71 |
| - void invoke_update_callback |
72 |
| - ( ecsact_entity_id entity |
73 |
| - ) |
74 |
| - { |
75 |
| - target->update_callback( |
76 |
| - ECSACT_EVENT_UPDATE_COMPONENT, |
77 |
| - static_cast<ecsact_entity_id>(entity), |
78 |
| - static_cast<ecsact_component_id>(C::id), |
79 |
| - nullptr, |
80 |
| - target->update_callback_user_data |
81 |
| - ); |
82 |
| - } |
| 47 | + template<typename C> |
| 48 | + requires(!std::is_empty_v<C>) |
| 49 | + void invoke_update_callback(ecsact_entity_id entity, const C& component) { |
| 50 | + target->update_callback( |
| 51 | + ECSACT_EVENT_UPDATE_COMPONENT, |
| 52 | + static_cast<ecsact_entity_id>(entity), |
| 53 | + static_cast<ecsact_component_id>(C::id), |
| 54 | + static_cast<const void*>(&component), |
| 55 | + target->update_callback_user_data |
| 56 | + ); |
| 57 | + } |
83 | 58 |
|
84 |
| - template<typename C> |
85 |
| - requires(!std::is_empty_v<C>) |
86 |
| - void invoke_remove_callback |
87 |
| - ( ecsact_entity_id entity |
88 |
| - , const C& component |
89 |
| - ) |
90 |
| - { |
91 |
| - target->remove_callback( |
92 |
| - ECSACT_EVENT_REMOVE_COMPONENT, |
93 |
| - static_cast<ecsact_entity_id>(entity), |
94 |
| - static_cast<ecsact_component_id>(C::id), |
95 |
| - static_cast<const void*>(&component), |
96 |
| - target->remove_callback_user_data |
97 |
| - ); |
98 |
| - } |
| 59 | + template<typename C> |
| 60 | + requires(std::is_empty_v<C>) |
| 61 | + void invoke_update_callback(ecsact_entity_id entity) { |
| 62 | + target->update_callback( |
| 63 | + ECSACT_EVENT_UPDATE_COMPONENT, |
| 64 | + static_cast<ecsact_entity_id>(entity), |
| 65 | + static_cast<ecsact_component_id>(C::id), |
| 66 | + nullptr, |
| 67 | + target->update_callback_user_data |
| 68 | + ); |
| 69 | + } |
99 | 70 |
|
100 |
| - template<typename C> |
101 |
| - requires(std::is_empty_v<C>) |
102 |
| - void invoke_remove_callback |
103 |
| - ( ecsact_entity_id entity |
104 |
| - ) |
105 |
| - { |
106 |
| - target->remove_callback( |
107 |
| - ECSACT_EVENT_REMOVE_COMPONENT, |
108 |
| - static_cast<ecsact_entity_id>(entity), |
109 |
| - static_cast<ecsact_component_id>(C::id), |
110 |
| - nullptr, |
111 |
| - target->remove_callback_user_data |
112 |
| - ); |
113 |
| - } |
114 |
| - }; |
115 |
| -} |
| 71 | + template<typename C> |
| 72 | + requires(!std::is_empty_v<C>) |
| 73 | + void invoke_remove_callback(ecsact_entity_id entity, const C& component) { |
| 74 | + target->remove_callback( |
| 75 | + ECSACT_EVENT_REMOVE_COMPONENT, |
| 76 | + static_cast<ecsact_entity_id>(entity), |
| 77 | + static_cast<ecsact_component_id>(C::id), |
| 78 | + static_cast<const void*>(&component), |
| 79 | + target->remove_callback_user_data |
| 80 | + ); |
| 81 | + } |
| 82 | + |
| 83 | + template<typename C> |
| 84 | + requires(std::is_empty_v<C>) |
| 85 | + void invoke_remove_callback(ecsact_entity_id entity) { |
| 86 | + target->remove_callback( |
| 87 | + ECSACT_EVENT_REMOVE_COMPONENT, |
| 88 | + static_cast<ecsact_entity_id>(entity), |
| 89 | + static_cast<ecsact_component_id>(C::id), |
| 90 | + nullptr, |
| 91 | + target->remove_callback_user_data |
| 92 | + ); |
| 93 | + } |
| 94 | +}; |
| 95 | + |
| 96 | +} // namespace ecsact_entt_rt |
0 commit comments