mirror of
https://github.com/brmlab/brmlife.git
synced 2025-08-03 10:23:38 +02:00
Allow moving onto a herb, eating it
This commit is contained in:
parent
be64c92077
commit
de392f4c7a
1 changed files with 8 additions and 4 deletions
12
agent.cc
12
agent.cc
|
@ -37,11 +37,15 @@ agent::move_dir(int dir_x, int dir_y)
|
||||||
|
|
||||||
class tile *t2 = &tile->tile_in_dir(dir_x, dir_y);
|
class tile *t2 = &tile->tile_in_dir(dir_x, dir_y);
|
||||||
if (t2->agent) {
|
if (t2->agent) {
|
||||||
if (t2->agent->dead) {
|
if (t2->herb_here()) {
|
||||||
class agent *a = t2->agent;
|
class agent *a = t2->agent;
|
||||||
t2->on_agent_leave(*a);
|
t2->on_agent_leave(*a);
|
||||||
/* Nom. */
|
chenergy(a->energy); /* Nom. */
|
||||||
chenergy(a->energy);
|
a->die();
|
||||||
|
} else if (t2->agent->dead) {
|
||||||
|
class agent *a = t2->agent;
|
||||||
|
t2->on_agent_leave(*a);
|
||||||
|
chenergy(a->energy); /* Nom. */
|
||||||
a->energy = 0;
|
a->energy = 0;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -137,7 +141,7 @@ agent::on_senses_update(void)
|
||||||
|
|
||||||
agent::~agent()
|
agent::~agent()
|
||||||
{
|
{
|
||||||
if (tile)
|
if (tile && tile->agent == this)
|
||||||
tile->on_agent_leave(*this);
|
tile->on_agent_leave(*this);
|
||||||
if (conn) {
|
if (conn) {
|
||||||
conn->cancel();
|
conn->cancel();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue