feat: generalising of NPC logic

This commit is contained in:
Sara Gerretsen 2026-02-02 20:51:14 +01:00
parent 41bcf4cdf7
commit 1625a11c42
6 changed files with 74 additions and 37 deletions

View file

@ -2,6 +2,8 @@
#include "core/os/memory.h"
#include "scene/animation/animation_player.h"
#include "wave_survival/macros.h"
#include "wave_survival/npc_unit.h"
#include "wave_survival/player_detector.h"
#include "wave_survival/state_machine.h"
void EnemyRifleman::_bind_methods() {
@ -19,7 +21,7 @@ void EnemyRifleman::on_child_entered(Node *node) {
void EnemyRifleman::ready() {
this->fsm->add_state(memnew(RiflemanPatrolState));
this->fsm->add_state(memnew(RiflemanSeekState));
this->fsm->add_state(memnew(RiflemanChaseState));
this->fsm->add_state(memnew(RiflemanFireState));
}
@ -57,5 +59,15 @@ EnemyRifleman *RiflemanState::get_target() const {
return cast_to<EnemyRifleman>(get_body());
}
void RiflemanPatrolState::enter_state() {
String RiflemanPatrolState::get_next_state() const {
if (get_body()->get_unit()->is_aware_of_player()) {
return RiflemanChaseState::get_class_static();
}
return get_class();
}
String RiflemanChaseState::get_next_state() const {
if (get_body()->get_detector()->line_of_sight_exists()) {
}
return get_class();
}