From f43f52903f29d010a72183de24ae8f56ab6702bb Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Sat, 21 Apr 2018 16:45:40 +0200 Subject: Add the scientist. --- src/game/unit_repl.cpp | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'src/game/unit_repl.cpp') 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) -- cgit