feat: implemented basics of enemy rifleman

This commit is contained in:
Sara Gerretsen 2026-02-09 12:53:09 +01:00
parent 13daa093d1
commit f1c4fe75f2
8 changed files with 155 additions and 6 deletions

View file

@ -31,6 +31,13 @@ void MapRegion::on_child_entered_tree(Node *node) {
}
}
void MapRegion::set_hunt_phase(bool hunt) {
if (this->hunt_phase != hunt) {
this->hunt_phase = hunt;
emit_signal(sig_phase_changed, hunt);
}
}
void MapRegion::enter_tree() {
connect("child_entered_tree", callable_mp(this, &self_type::on_child_entered_tree));
}
@ -58,12 +65,21 @@ void MapRegion::_notification(int what) {
void MapRegion::register_unit(NpcUnit *unit) {
if (!this->units.has(unit)) {
this->units.insert(unit);
if (this->hunt_phase) {
this->hunt_phase_units++;
}
}
}
void MapRegion::remove_unit(NpcUnit *unit) {
if (this->units.has(unit)) {
this->units.erase(unit);
if (this->hunt_phase) {
this->hunt_phase_units--;
if (this->hunt_phase_units == 0) {
set_hunt_phase(false);
}
}
}
}
@ -77,8 +93,7 @@ void MapRegion::raise_difficulty(double amount) {
if (new_trunc != old_trunc) {
print_line("Hunt Phase Started");
emit_signal(sig_difficulty_increased);
emit_signal(sig_phase_changed, true);
this->hunt_phase = true;
set_hunt_phase(true);
}
}

View file

@ -11,6 +11,7 @@ class MapRegion : public Area3D {
void on_node_entered(Node3D *node);
void on_node_exited(Node3D *node);
void on_child_entered_tree(Node *node);
void set_hunt_phase(bool hunt);
void enter_tree();
void ready();
@ -27,6 +28,7 @@ private:
double difficulty{ 0.f };
bool hunt_phase{ false };
HashSet<NpcUnit *> units{ nullptr };
size_t hunt_phase_units{ 0 };
bool has_player{ false };
public:

View file

@ -2,6 +2,7 @@
#include "core/object/class_db.h"
#include "wave_survival/damage_box.h"
#include "wave_survival/enemies/enemy_rifleman.h"
#include "wave_survival/enemies/enemy_wretched.h"
#include "wave_survival/enemy_body.h"
#include "wave_survival/enemy_spawner.h"
@ -49,6 +50,10 @@ void initialize_wave_survival_module(ModuleInitializationLevel p_level) {
GDREGISTER_CLASS(WretchedPatrolState);
GDREGISTER_CLASS(WretchedChaseState);
GDREGISTER_CLASS(WretchedAttackState);
GDREGISTER_CLASS(EnemyRifleman);
GDREGISTER_CLASS(RiflemanPatrolState);
GDREGISTER_CLASS(RiflemanChaseState);
GDREGISTER_CLASS(RiflemanFireState);
GDREGISTER_CLASS(PlayerDetector);
GDREGISTER_CLASS(Hitbox);
GDREGISTER_CLASS(DamageBox);