diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2018-04-21 16:45:40 +0200 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2018-04-21 16:45:40 +0200 |
commit | f43f52903f29d010a72183de24ae8f56ab6702bb (patch) | |
tree | 3e4ef5c81644086891ad9fb78fce0cb7e5c1858e /src/game/unit_repl.cpp | |
parent | b84b39f099e8a1f66fb95d371b60b1546fb3142a (diff) |
Add the scientist.
Diffstat (limited to 'src/game/unit_repl.cpp')
-rw-r--r-- | src/game/unit_repl.cpp | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/src/game/unit_repl.cpp b/src/game/unit_repl.cpp index 08a43d2..bad5ab0 100644 --- a/src/game/unit_repl.cpp +++ b/src/game/unit_repl.cpp @@ -43,7 +43,7 @@ void unit_repl_t::on_damage(unit_t *attacker) void unit_repl_t::on_death(void) { game->explosion(x); - delete this; + game->deletion_list.insert(this); } void unit_repl_t::render_to(render::state_t *render) @@ -52,19 +52,31 @@ void unit_repl_t::render_to(render::state_t *render) unit_t::render_to(render); } -void unit_repl_t::activate(void) +void unit_repl_t::activate(unit_t::type_t type) { - unit_soldier_t *soldier; world::cmodel_t cmodel; - - soldier = new unit_soldier_t(game); - soldier->place(&game->world, x); - - for (world::entity_t *ent : game->world.get_entities(soldier->cmodel.bounds, soldier->move.cflags)) + world::entity_t *spawned; + + if (type == UNIT_SOLDIER) { + unit_soldier_t *soldier; + + soldier = new unit_soldier_t(game); + soldier->place(&game->world, x); + spawned = soldier; + } else if (type == UNIT_SCIENTIST) { + unit_scientist_t *scientist; + + scientist = new unit_scientist_t(game); + scientist->place(&game->world, x); + spawned = scientist; + } else + abort(); + + for (world::entity_t *ent : game->world.get_entities(spawned->cmodel.bounds, CF_BODY|CF_BODY_SMALL)) { unit_t *unit; - if (ent == soldier) + if (ent == spawned) continue; if (ent->type != ET_UNIT) |