feat: defining map region unit un-/registering behaviour
This commit is contained in:
parent
92c38e54b6
commit
d8ae45df0f
7 changed files with 87 additions and 1 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue