2024-01-31 20:01:22 +00:00
|
|
|
#include "level.hpp"
|
|
|
|
#include "entrance.hpp"
|
|
|
|
#include "godot_cpp/variant/utility_functions.hpp"
|
|
|
|
|
|
|
|
namespace godot {
|
|
|
|
void Level::_bind_methods() {}
|
|
|
|
|
|
|
|
Transform3D Level::get_entrance(String entranceName) {
|
2024-02-01 17:08:55 +00:00
|
|
|
if (entrances.has(entranceName)) {
|
|
|
|
Node3D* entrance =
|
|
|
|
Object::cast_to<Node3D>(this->entrances[entranceName]);
|
2024-01-31 20:01:22 +00:00
|
|
|
return entrance->get_global_transform();
|
|
|
|
} else {
|
|
|
|
return this->get_global_transform();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-01 17:08:55 +00:00
|
|
|
void Level::add_entrance(Entrance* entrance) {
|
|
|
|
String key = entrance->get_name();
|
|
|
|
if (this->entrances.has(key))
|
|
|
|
UtilityFunctions::push_error("Attempt to register entrance ", key,
|
|
|
|
" with duplicate key");
|
2024-01-31 20:01:22 +00:00
|
|
|
this->entrances[key] = entrance;
|
|
|
|
}
|
|
|
|
|
2024-02-01 17:08:55 +00:00
|
|
|
void Level::remove_entrance(Entrance* entrance) {
|
|
|
|
String key = entrance->get_name();
|
|
|
|
if (!this->entrances.has(key))
|
|
|
|
UtilityFunctions::push_error("Attempt to deregister entrance ", key,
|
|
|
|
" without registering it");
|
2024-01-31 20:01:22 +00:00
|
|
|
this->entrances.erase(key);
|
|
|
|
}
|
2024-02-01 17:08:55 +00:00
|
|
|
} // namespace godot
|