chore: removed debug prints and formatted enemy_world_state.cpp

This commit is contained in:
Sara 2025-03-14 14:22:18 +01:00
parent 4178c08102
commit 1c2522d2ea

View file

@ -23,11 +23,9 @@ void EnemyWorldState::_process(double) {
if(!this->health->is_conscious())
return;
if(this->select_and_set_target_on_process) {
gd::UtilityFunctions::print("!!! ", this->get_path(), " requested, select_and_set_target");
this->select_and_set_target_on_process = false;
this->select_and_set_target();
} else if(!this->parent_unit->has_plan()) {
gd::UtilityFunctions::print("!!! ", this->get_path(), " no plan, select_and_set_target");
this->select_and_set_target();
}
}
@ -41,6 +39,9 @@ void EnemyWorldState::on_awareness_entered(gd::Node3D *node) {
void EnemyWorldState::on_awareness_exited(gd::Node3D *node) {
if(Unit * unit{gd::Object::cast_to<Unit>(node)})
this->remove_aware_unit(unit);
if(node == this->target_node) {
this->target_node = nullptr;
}
}
void EnemyWorldState::on_damaged(EntityHealth *, int, Unit *source) {
@ -52,13 +53,13 @@ void EnemyWorldState::on_damaged(EntityHealth *, int, Unit *source) {
Unit *EnemyWorldState::select_target_from_known_with_priority(float *out_priority) {
Unit *out{gd::Object::cast_to<Unit>(target_node)};
// prioritze current target if it is still valid
if(out != nullptr && this->known_enemies.has(out)) {
*out_priority = INFINITY;
return out;
} else {
*out_priority = -INFINITY;
}
// prioritze current target if it is still valid
if(out != nullptr && this->known_enemies.has(out)) {
*out_priority = INFINITY;
return out;
} else {
*out_priority = -INFINITY;
}
for(Unit *unit : this->known_enemies) {
if(!this->get_can_see_node(unit))
continue;
@ -113,7 +114,6 @@ void EnemyWorldState::on_aware_unit_death(Unit *, Unit *dead_entity) {
}
void EnemyWorldState::select_and_set_target() {
gd::UtilityFunctions::print("!!! ", this->get_path(), " select_and_set_target");
this->try_set_target(this->select_target_from_known());
}