feat: saving entities (WIP)

This commit is contained in:
MihailRis
2024-07-05 05:16:31 +03:00
parent 019a88ef84
commit f0270d3391
24 changed files with 290 additions and 101 deletions
+11
View File
@@ -295,6 +295,7 @@ void scripting::on_entity_spawn(
funcsset.on_despawn = lua::hasfield(L, "on_despawn");
funcsset.on_trigger_enter = lua::hasfield(L, "on_trigger_enter");
funcsset.on_trigger_exit = lua::hasfield(L, "on_trigger_exit");
funcsset.on_save = lua::hasfield(L, "on_save");
lua::pop(L, 2);
component->env = compenv;
@@ -355,6 +356,16 @@ bool scripting::on_entity_fall(const Entity& entity) {
return true;
}
bool scripting::on_entity_save(const Entity& entity) {
const auto& script = entity.getScripting();
for (auto& component : script.components) {
if (component->funcsset.on_save) {
process_entity_callback(component->env, "on_save", nullptr);
}
}
return true;
}
void scripting::on_trigger_enter(const Entity& entity, size_t index, entityid_t oid) {
const auto& script = entity.getScripting();
for (auto& component : script.components) {