mirror of
https://github.com/brmlab/brmlife.git
synced 2025-08-02 18:03:37 +02:00
Make herbs die properly on energy depletion
This commit is contained in:
parent
5435014c1d
commit
343762c3bb
2 changed files with 11 additions and 3 deletions
11
agent.cc
11
agent.cc
|
@ -181,6 +181,14 @@ agent::~agent()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
herb::die(void)
|
||||||
|
{
|
||||||
|
/* No corpse, just clean up tile. */
|
||||||
|
tile->on_agent_leave(*this);
|
||||||
|
tile = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
spawn_herb(class tile &t)
|
spawn_herb(class tile &t)
|
||||||
{
|
{
|
||||||
|
@ -211,8 +219,7 @@ herb::on_tick(void)
|
||||||
spawn_herb(tile->tile_in_dir(0, 1));
|
spawn_herb(tile->tile_in_dir(0, 1));
|
||||||
spawn_herb(tile->tile_in_dir(-1, 0));
|
spawn_herb(tile->tile_in_dir(-1, 0));
|
||||||
spawn_herb(tile->tile_in_dir(0, -1));
|
spawn_herb(tile->tile_in_dir(0, -1));
|
||||||
tile->on_agent_leave(*this);
|
die();
|
||||||
tile = NULL;
|
|
||||||
} else {
|
} else {
|
||||||
smell_herb(tile->tile_in_dir(1, 0));
|
smell_herb(tile->tile_in_dir(1, 0));
|
||||||
smell_herb(tile->tile_in_dir(0, 1));
|
smell_herb(tile->tile_in_dir(0, 1));
|
||||||
|
|
3
agent.h
3
agent.h
|
@ -43,7 +43,7 @@ public:
|
||||||
bool secrete(int id, double intensity);
|
bool secrete(int id, double intensity);
|
||||||
|
|
||||||
void chenergy(int delta);
|
void chenergy(int delta);
|
||||||
void die(void);
|
virtual void die(void);
|
||||||
|
|
||||||
void on_action_takes(void);
|
void on_action_takes(void);
|
||||||
virtual void on_tick(void);
|
virtual void on_tick(void);
|
||||||
|
@ -63,6 +63,7 @@ public:
|
||||||
energy = world::herb_energy;
|
energy = world::herb_energy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void die(void);
|
||||||
void on_tick(void);
|
void on_tick(void);
|
||||||
private:
|
private:
|
||||||
void smell_herb(class tile &);
|
void smell_herb(class tile &);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue