Skip to content

Commit 06aa191

Browse files
committed
Change execution options, going to remove entity manager and all its associated pieces
1 parent d974559 commit 06aa191

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
@@ -168,6 +168,8 @@ types::cpp_execution_options util::c_to_cpp_execution_options(
168168
cpp_options.updates.reserve(options.update_components_length);
169169
cpp_options.removes.reserve(options.remove_components_length);
170170
cpp_options.actions.reserve(options.actions_length);
171+
cpp_options.create_entities.reserve(options.create_entities_length);
172+
cpp_options.destroy_entities.reserve(options.destroy_entities_length);
171173

172174
if(options.add_components != nullptr) {
173175
for(int i = 0; i < options.add_components_length; i++) {
@@ -231,6 +233,35 @@ types::cpp_execution_options util::c_to_cpp_execution_options(
231233
cpp_options.actions.push_back(action_info);
232234
}
233235
}
236+
237+
if(options.create_entities_components != nullptr) {
238+
for(int i = 0; i < options.create_entities_length; i++) {
239+
types::entity_create_options entity_to_create{};
240+
auto component_list_length = options.create_entities_components_length[i];
241+
entity_to_create.components.reserve(component_list_length);
242+
243+
for(int j = 0; j < component_list_length; j++) {
244+
types::cpp_component new_entity_component{};
245+
246+
auto component = options.create_entities_components[i][j];
247+
auto serialized_component = ecsact::serialize(component);
248+
249+
new_entity_component._id = component.component_id;
250+
new_entity_component.data = serialized_component;
251+
entity_to_create.components.push_back(new_entity_component);
252+
}
253+
cpp_options.create_entities.push_back(entity_to_create);
254+
}
255+
}
256+
257+
if(options.destroy_entities != nullptr) {
258+
cpp_options.destroy_entities.insert(
259+
cpp_options.destroy_entities.begin(),
260+
options.destroy_entities,
261+
options.destroy_entities + options.destroy_entities_length
262+
);
263+
}
264+
234265
return cpp_options;
235266
}
236267

0 commit comments

Comments
 (0)