feat: improved Level entrances api error handling
parent
47b399299a
commit
0318fb9746
|
@ -7,7 +7,8 @@ void Level::_bind_methods() {}
|
||||||
|
|
||||||
Transform3D Level::get_entrance(String entranceName) {
|
Transform3D Level::get_entrance(String entranceName) {
|
||||||
if (entrances.has(entranceName)) {
|
if (entrances.has(entranceName)) {
|
||||||
Node3D *entrance = Object::cast_to<Node3D>(this->entrances[entranceName]);
|
Node3D* entrance =
|
||||||
|
Object::cast_to<Node3D>(this->entrances[entranceName]);
|
||||||
return entrance->get_global_transform();
|
return entrance->get_global_transform();
|
||||||
} else {
|
} else {
|
||||||
return this->get_global_transform();
|
return this->get_global_transform();
|
||||||
|
@ -17,14 +18,16 @@ Transform3D Level::get_entrance(String entranceName) {
|
||||||
void Level::add_entrance(Entrance* entrance) {
|
void Level::add_entrance(Entrance* entrance) {
|
||||||
String key = entrance->get_name();
|
String key = entrance->get_name();
|
||||||
if (this->entrances.has(key))
|
if (this->entrances.has(key))
|
||||||
UtilityFunctions::push_error("Attempt to register entrance ", key, " with duplicate key");
|
UtilityFunctions::push_error("Attempt to register entrance ", key,
|
||||||
|
" with duplicate key");
|
||||||
this->entrances[key] = entrance;
|
this->entrances[key] = entrance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Level::remove_entrance(Entrance* entrance) {
|
void Level::remove_entrance(Entrance* entrance) {
|
||||||
String key = entrance->get_name();
|
String key = entrance->get_name();
|
||||||
if (!this->entrances.has(key))
|
if (!this->entrances.has(key))
|
||||||
UtilityFunctions::push_error("Attempt to deregister entrance ", key, " without registering it");
|
UtilityFunctions::push_error("Attempt to deregister entrance ", key,
|
||||||
|
" without registering it");
|
||||||
this->entrances.erase(key);
|
this->entrances.erase(key);
|
||||||
}
|
}
|
||||||
}
|
} // namespace godot
|
||||||
|
|
Loading…
Reference in New Issue