mirror of
https://github.com/brmlab/brmlife.git
synced 2025-08-03 02:13:35 +02:00
agent::move_dir(): If moving at dead agent, remove it from map and acquire its energy
This commit is contained in:
parent
e27a9fe2aa
commit
4f13d0dd6f
1 changed files with 12 additions and 0 deletions
12
agent.cc
12
agent.cc
|
@ -25,6 +25,18 @@ agent::move_dir(int dir_x, int dir_y)
|
||||||
energy -= world::move_cost;
|
energy -= world::move_cost;
|
||||||
|
|
||||||
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->dead) {
|
||||||
|
class agent *a = t2->agent;
|
||||||
|
t2->on_agent_leave(*a);
|
||||||
|
/* Nom. */
|
||||||
|
energy += a->energy;
|
||||||
|
a->energy = 0;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!t2->on_agent_enter(*this))
|
if (!t2->on_agent_enter(*this))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue