53 lines
1 KiB
C++
53 lines
1 KiB
C++
#include "npc_unit.h"
|
|
#include "enemy_body.h"
|
|
#include "macros.h"
|
|
#include "patrol_path.h"
|
|
|
|
void NpcUnit::_bind_methods() {
|
|
BIND_HPROPERTY(Variant::OBJECT, patrol_path, PROPERTY_HINT_NODE_TYPE, "PatrolPath");
|
|
}
|
|
|
|
void NpcUnit::child_added(Node *node) {
|
|
if (EnemyBody * npc{ cast_to<EnemyBody>(node) }) {
|
|
this->npcs.push_back(npc);
|
|
npc->set_unit(this);
|
|
}
|
|
}
|
|
|
|
void NpcUnit::enter_tree() {
|
|
this->connect("child_entered_tree", callable_mp(this, &self_type::child_added));
|
|
}
|
|
|
|
void NpcUnit::_notification(int what) {
|
|
if (Engine::get_singleton()->is_editor_hint()) {
|
|
return;
|
|
}
|
|
switch (what) {
|
|
default:
|
|
return;
|
|
case NOTIFICATION_ENTER_TREE:
|
|
enter_tree();
|
|
return;
|
|
}
|
|
}
|
|
|
|
void NpcUnit::set_patrol_path(PatrolPath *path) {
|
|
this->patrol_path = path;
|
|
}
|
|
|
|
PatrolPath *NpcUnit::get_patrol_path() const {
|
|
return this->patrol_path;
|
|
}
|
|
|
|
bool NpcUnit::is_aware_of_player() const {
|
|
return false;
|
|
}
|
|
|
|
void NpcUnit::set_patrol_speed(float speed) {
|
|
this->patrol_speed = speed;
|
|
}
|
|
|
|
float NpcUnit::get_patrol_speed() const {
|
|
return this->patrol_speed;
|
|
}
|