9
9
#include " async_test.ecsact.systems.hh"
10
10
#include " ecsact/runtime/async.h"
11
11
#include " ecsact/runtime/dynamic.h"
12
+ #include " ecsact/runtime/core.hh"
12
13
13
14
using namespace std ::chrono_literals;
14
15
using std::chrono::duration_cast;
@@ -159,10 +160,19 @@ TEST(AsyncRef, AddUpdateAndRemove) {
159
160
cb_info.entity = entity_id;
160
161
};
161
162
163
+ // Declare core execution options
164
+ auto options = ecsact::core::execution_options{};
165
+
162
166
ecsact_async_events_collector entity_async_evc{};
163
167
entity_async_evc.async_entity_callback = entity_cb;
164
168
entity_async_evc.async_entity_callback_user_data = &cb_info;
165
169
170
+ auto my_needed_component = async_test::NeededComponent{};
171
+
172
+ options.create_entity ().add_component (&my_needed_component);
173
+
174
+ ecsact_async_enqueue_execution_options (options.c ());
175
+
166
176
auto start_tick = ecsact_async_get_current_tick ();
167
177
while (cb_info.wait != true ) {
168
178
ecsact_async_flush_events (nullptr , &entity_async_evc);
@@ -171,40 +181,18 @@ TEST(AsyncRef, AddUpdateAndRemove) {
171
181
ASSERT_LT (tick_diff, 10 );
172
182
}
173
183
184
+ options.clear ();
185
+
174
186
// Preparing add component data
175
- auto my_needed_component = async_test::NeededComponent{};
187
+ // auto my_needed_component = async_test::NeededComponent{};
176
188
auto my_update_component = async_test::ComponentUpdate{.value_to_update = 1 };
177
189
178
- std::array add_components{
179
- ecsact_component{
180
- .component_id = async_test::NeededComponent::id,
181
- .component_data = &my_needed_component,
182
- },
183
- ecsact_component{
184
- .component_id = async_test::ComponentUpdate::id,
185
- .component_data = &my_update_component,
186
- },
187
- };
188
- auto add_components_entities = std::array{cb_info.entity , cb_info.entity };
189
-
190
- ASSERT_EQ (add_components_entities.size (), add_components.size ());
190
+ // options.add_component(cb_info.entity, &my_needed_component);
191
+ options.add_component (cb_info.entity , &my_update_component);
191
192
192
193
// Adding components
193
- auto add_options = ecsact_execution_options{};
194
- add_options.add_components_length = add_components.size ();
195
- add_options.add_components_entities = add_components_entities.data ();
196
- add_options.add_components = add_components.data ();
197
- ecsact_async_enqueue_execution_options (add_options);
198
-
199
- // Prepare update component data
200
- my_update_component.value_to_update += 5 ;
201
- auto update_components = std::array{
202
- ecsact_component{
203
- .component_id = async_test::ComponentUpdate::id,
204
- .component_data = &my_update_component,
205
- },
206
- };
207
- auto component_update_entities = std::array{cb_info.entity };
194
+ ecsact_async_enqueue_execution_options (options.c ());
195
+ options.clear ();
208
196
209
197
// Prepare the events collector for the flush to make sure we got all the
210
198
// events we expected.
@@ -259,12 +247,16 @@ TEST(AsyncRef, AddUpdateAndRemove) {
259
247
ASSERT_EQ (comp->value_to_update , 6 );
260
248
};
261
249
250
+ // Prepare update component data
251
+ my_update_component.value_to_update += 5 ;
252
+
262
253
// Update components
263
- ecsact_execution_options update_options{};
264
- update_options.update_components_length = update_components.size ();
265
- update_options.update_components_entities = component_update_entities.data ();
266
- update_options.update_components = update_components.data ();
267
- ecsact_async_enqueue_execution_options (update_options);
254
+ options.update_component <async_test::ComponentUpdate>(
255
+ cb_info.entity ,
256
+ &my_update_component
257
+ );
258
+ ecsact_async_enqueue_execution_options (options.c ());
259
+ options.clear ();
268
260
269
261
start_tick = ecsact_async_get_current_tick ();
270
262
while (!cb_info.update_happened ) {
@@ -277,16 +269,11 @@ TEST(AsyncRef, AddUpdateAndRemove) {
277
269
evc.update_callback = {};
278
270
evc.update_callback_user_data = nullptr ;
279
271
280
- // Prepare remove component data
281
- auto remove_components = std::array{async_test::ComponentUpdate::id};
282
- auto components_remove_entities = std::array{cb_info.entity };
283
-
284
272
// Remove component
285
- auto remove_options = ecsact_execution_options{};
286
- remove_options.remove_components_length = remove_components.size ();
287
- remove_options.remove_components_entities = components_remove_entities.data ();
288
- remove_options.remove_components = remove_components.data ();
289
- ecsact_async_enqueue_execution_options (remove_options);
273
+ options.remove_component <async_test::ComponentUpdate>(cb_info.entity );
274
+
275
+ ecsact_async_enqueue_execution_options (options.c ());
276
+ options.clear ();
290
277
291
278
evc.remove_callback_user_data = &cb_info;
292
279
evc.remove_callback = //
0 commit comments