feat: defining map region unit un-/registering behaviour

This commit is contained in:
Sara 2025-08-17 17:55:09 +02:00
parent 92c38e54b6
commit d8ae45df0f
7 changed files with 87 additions and 1 deletions

View file

@ -1,6 +1,7 @@
#include "npc_unit.h"
#include "enemy_body.h"
#include "macros.h"
#include "map_region.h"
#include "patrol_path.h"
#include "player_detector.h"
@ -63,3 +64,18 @@ void NpcUnit::set_patrol_speed(float speed) {
float NpcUnit::get_patrol_speed() const {
return this->patrol_speed;
}
void NpcUnit::set_region(MapRegion *region) {
if (this->region == region) {
return;
}
if (this->region != nullptr) {
this->region->remove_unit(this);
}
this->region = region;
region->register_unit(this);
}
MapRegion *NpcUnit::get_region() const {
return this->region;
}