Skip to content

Commit db1a58d

Browse files
committed
Change execution options, going to remove entity manager and all its associated pieces
1 parent 94b3c74 commit db1a58d

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

reference/async_reference/util/types.hh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,23 @@ struct cpp_execution_component {
3333
std::vector<std::byte> data;
3434
};
3535

36+
struct cpp_component {
37+
ecsact_component_id _id;
38+
std::vector<std::byte> data;
39+
};
40+
41+
struct entity_create_options {
42+
std::vector<cpp_component> components;
43+
};
44+
3645
struct action_info {
3746
ecsact_action_id action_id;
3847
std::vector<std::byte> serialized_data;
3948
};
4049

4150
struct cpp_execution_options {
51+
std::vector<entity_create_options> create_entities;
52+
std::vector<ecsact_entity_id> destroy_entities;
4253
std::vector<cpp_execution_component> adds;
4354
std::vector<cpp_execution_component> updates;
4455
std::vector<cpp_execution_component> removes;
@@ -57,6 +68,12 @@ struct cpp_execution_options {
5768
if(actions.size() > 0) {
5869
return true;
5970
}
71+
if(create_entities.size() > 0) {
72+
return true;
73+
}
74+
if(destroy_entities.size() > 0) {
75+
return true;
76+
}
6077
return false;
6178
}
6279
};

reference/async_reference/util/util.cc

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ types::cpp_execution_options util::c_to_cpp_execution_options(
172172
cpp_options.updates.reserve(options.update_components_length);
173173
cpp_options.removes.reserve(options.remove_components_length);
174174
cpp_options.actions.reserve(options.actions_length);
175+
cpp_options.create_entities.reserve(options.create_entities_length);
176+
cpp_options.destroy_entities.reserve(options.destroy_entities_length);
175177

176178
if(options.add_components != nullptr) {
177179
for(int i = 0; i < options.add_components_length; i++) {
@@ -235,6 +237,35 @@ types::cpp_execution_options util::c_to_cpp_execution_options(
235237
cpp_options.actions.push_back(action_info);
236238
}
237239
}
240+
241+
if(options.create_entities_components != nullptr) {
242+
for(int i = 0; i < options.create_entities_length; i++) {
243+
types::entity_create_options entity_to_create{};
244+
auto component_list_length = options.create_entities_components_length[i];
245+
entity_to_create.components.reserve(component_list_length);
246+
247+
for(int j = 0; j < component_list_length; j++) {
248+
types::cpp_component new_entity_component{};
249+
250+
auto component = options.create_entities_components[i][j];
251+
auto serialized_component = ecsact::serialize(component);
252+
253+
new_entity_component._id = component.component_id;
254+
new_entity_component.data = serialized_component;
255+
entity_to_create.components.push_back(new_entity_component);
256+
}
257+
cpp_options.create_entities.push_back(entity_to_create);
258+
}
259+
}
260+
261+
if(options.destroy_entities != nullptr) {
262+
cpp_options.destroy_entities.insert(
263+
cpp_options.destroy_entities.begin(),
264+
options.destroy_entities,
265+
options.destroy_entities + options.destroy_entities_length
266+
);
267+
}
268+
238269
return cpp_options;
239270
}
240271

0 commit comments

Comments
 (0)