summaryrefslogtreecommitdiff
path: root/src/game/game.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/game.cpp')
-rw-r--r--src/game/game.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/game/game.cpp b/src/game/game.cpp
index a19eecc..f6fa420 100644
--- a/src/game/game.cpp
+++ b/src/game/game.cpp
@@ -35,7 +35,9 @@ entity_t::entity_t(game::state_t *game_, int type_) : world::entity_t(type_)
entity_t::~entity_t(void)
{
sleep();
- unlink();
+
+ if (world)
+ unlink();
}
void entity_t::place(world::world_t *world_)
@@ -85,6 +87,8 @@ void state_t::start(void)
repl = new unit_repl_t(this);
repl->place(&world, v2f_t(5.3, 4.2));
+ repl->constructed = true;
+ repl->health = repl->max_health;
select_unit(repl, SELECT_NEW);
resume();
@@ -185,7 +189,8 @@ enum {
COMMAND_GATHER,
- COMMAND_REPAIR
+ COMMAND_REPAIR,
+ COMMAND_BUILD_REPL
};
bool state_t::populate_pie_menu(std::vector<interface::pie_item_t> &items)
@@ -199,7 +204,7 @@ bool state_t::populate_pie_menu(std::vector<interface::pie_item_t> &items)
return false;
for (unit_t *unit : selected_units) {
- if (unit->dead || !unit->controllable)
+ if (unit->dead || !unit->controllable || !unit->constructed)
continue;
switch (unit->type) {
@@ -239,8 +244,10 @@ bool state_t::populate_pie_menu(std::vector<interface::pie_item_t> &items)
if (scientists)
items.push_back((interface::pie_item_t){"Gather", COMMAND_GATHER});
- if (builders)
+ if (builders) {
items.push_back((interface::pie_item_t){"Repair", COMMAND_REPAIR});
+ items.push_back((interface::pie_item_t){"Build a replicator", COMMAND_BUILD_REPL});
+ }
if (repls) {
items.push_back((interface::pie_item_t){"Spawn a soldier", COMMAND_REPL_SOLDIER});
@@ -335,16 +342,15 @@ static void command_builder(unit_builder_t *builder, v2f_t x, int number)
break;
case COMMAND_STOP:
- builder->stop_moving();
- builder->say("Stop.", false);
- builder->repair_marker.reset();
+ builder->command_stop();
break;
case COMMAND_REPAIR:
- builder->repairing = true;
- builder->repairing_at = x;
- builder->repair_marker = std::make_unique<fx_aim_marker_t>(builder->game, x);
- builder->say("Idę naprawiać.", false);
+ builder->command_repair(x);
+ break;
+
+ case COMMAND_BUILD_REPL:
+ builder->command_build(x, unit_t::UNIT_REPL);
break;
}
}