feat: enemies now queue_delete when they die
This commit is contained in:
parent
8ec255449c
commit
6806832e1d
|
@ -10,6 +10,8 @@ namespace godot {
|
|||
void Enemy::_bind_methods() {
|
||||
#define CLASSNAME Enemy
|
||||
GDFUNCTION_ARGS(body_entered_vision_area, "body");
|
||||
GDFUNCTION_ARGS(on_death, "damage");
|
||||
GDFUNCTION_ARGS(on_damage, "damage", "remaining");
|
||||
}
|
||||
|
||||
void Enemy::_ready() { GDGAMEONLY();
|
||||
|
@ -18,6 +20,8 @@ void Enemy::_ready() { GDGAMEONLY();
|
|||
this->vision_area = this->get_node<Area3D>("VisionArea");
|
||||
this->vision_area->connect("body_entered", Callable(this, "body_entered_vision_area"));
|
||||
this->update_navigation_target();
|
||||
this->health->connect("death", Callable(this, "on_death"));
|
||||
this->health->connect("damage", Callable(this, "on_damage"));
|
||||
}
|
||||
|
||||
void Enemy::_process(double delta_time) { GDGAMEONLY();
|
||||
|
@ -57,6 +61,13 @@ void Enemy::update_navigation_target() {
|
|||
this->nav_agent->set_target_position(this->target_player->get_global_position());
|
||||
}
|
||||
|
||||
void Enemy::on_damage(int delta, int health_left) {
|
||||
}
|
||||
|
||||
void Enemy::on_death(int delta) {
|
||||
this->queue_free();
|
||||
}
|
||||
|
||||
Health *Enemy::get_health() {
|
||||
return this->health;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,9 @@ public:
|
|||
|
||||
void update_navigation_target();
|
||||
|
||||
void on_damage(int delta, int health_left);
|
||||
void on_death(int damage);
|
||||
|
||||
virtual Health *get_health() override;
|
||||
virtual Health const *get_health() const override;
|
||||
|
||||
|
|
|
@ -8,10 +8,10 @@ namespace godot {
|
|||
void Health::_bind_methods() {
|
||||
#define CLASSNAME Health
|
||||
GDPROPERTY(max_health, Variant::INT);
|
||||
ClassDB::add_signal("Health", MethodInfo("damage", PropertyInfo(Variant::INT, "delta"), PropertyInfo(Variant::INT, "remaining")));
|
||||
ClassDB::add_signal("Health", MethodInfo("heal", PropertyInfo(Variant::INT, "delta"), PropertyInfo(Variant::INT, "remaining")));
|
||||
ClassDB::add_signal("Health", MethodInfo("health_changed", PropertyInfo(Variant::INT, "delta"), PropertyInfo(Variant::INT, "remaining")));
|
||||
ClassDB::add_signal("Health", MethodInfo("death", PropertyInfo(Variant::INT, "delta")));
|
||||
GDSIGNAL("damage", PropertyInfo(Variant::INT, "delta"), PropertyInfo(Variant::INT, "remaining"));
|
||||
GDSIGNAL("heal", PropertyInfo(Variant::INT, "delta"), PropertyInfo(Variant::INT, "remaining"));
|
||||
GDSIGNAL("health_changed", PropertyInfo(Variant::INT, "delta"), PropertyInfo(Variant::INT, "remaining"));
|
||||
GDSIGNAL("death", PropertyInfo(Variant::INT, "delta"));
|
||||
}
|
||||
|
||||
void Health::_enter_tree() {
|
||||
|
|
Loading…
Reference in a new issue