feat: implemented enemy wretched patrol and chase states
This commit is contained in:
parent
1b0e4384b9
commit
9517588415
12 changed files with 224 additions and 17 deletions
|
|
@ -2,15 +2,24 @@
|
|||
#include "enemy_body.h"
|
||||
#include "macros.h"
|
||||
#include "patrol_path.h"
|
||||
#include "player_detector.h"
|
||||
|
||||
void NpcUnit::_bind_methods() {
|
||||
BIND_HPROPERTY(Variant::OBJECT, patrol_path, PROPERTY_HINT_NODE_TYPE, "PatrolPath");
|
||||
}
|
||||
|
||||
void NpcUnit::on_npc_awareness_changed(bool value) {
|
||||
if (value) {
|
||||
this->aware_of_player = true;
|
||||
}
|
||||
}
|
||||
|
||||
void NpcUnit::child_added(Node *node) {
|
||||
if (EnemyBody * npc{ cast_to<EnemyBody>(node) }) {
|
||||
this->npcs.push_back(npc);
|
||||
npc->set_unit(this);
|
||||
PlayerDetector *detector{ cast_to<PlayerDetector>(npc->get_node(NodePath("%PlayerDetector"))) };
|
||||
detector->connect(PlayerDetector::sig_awareness_changed, callable_mp(this, &self_type::on_npc_awareness_changed));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -40,7 +49,7 @@ PatrolPath *NpcUnit::get_patrol_path() const {
|
|||
}
|
||||
|
||||
bool NpcUnit::is_aware_of_player() const {
|
||||
return false;
|
||||
return this->aware_of_player;
|
||||
}
|
||||
|
||||
void NpcUnit::set_patrol_speed(float speed) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue