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.cpp57
1 files changed, 49 insertions, 8 deletions
diff --git a/src/game/game.cpp b/src/game/game.cpp
index 361fa83..084ac38 100644
--- a/src/game/game.cpp
+++ b/src/game/game.cpp
@@ -167,12 +167,13 @@ enum {
COMMAND_FIRE_ROCKET,
COMMAND_STOP,
- COMMAND_REPL,
+ COMMAND_REPL_SOLDIER,
+ COMMAND_REPL_SCIENTIST
};
bool state_t::populate_pie_menu(std::vector<interface::pie_item_t> &items)
{
- bool soldiers = false, repls = false, rockets = false;
+ bool can_move = false, soldiers = false, repls = false, rockets = false;
items.clear();
@@ -185,10 +186,16 @@ bool state_t::populate_pie_menu(std::vector<interface::pie_item_t> &items)
switch (unit->type) {
case unit_t::UNIT_SOLDIER:
+ can_move = true;
soldiers = true;
if (!dynamic_cast<unit_soldier_t*>(unit)->rocket_fired)
rockets = true;
break;
+
+ case unit_t::UNIT_SCIENTIST:
+ can_move = true;
+ break;
+
case unit_t::UNIT_REPL:
repls = true;
break;
@@ -197,16 +204,20 @@ bool state_t::populate_pie_menu(std::vector<interface::pie_item_t> &items)
}
}
- if (soldiers) {
+ if (can_move) {
items.push_back((interface::pie_item_t){"Move", COMMAND_MOVE});
+ items.push_back((interface::pie_item_t){"Stop", COMMAND_STOP});
+ }
+
+ if (soldiers) {
items.push_back((interface::pie_item_t){"Fire", COMMAND_FIRE});
if (rockets)
items.push_back((interface::pie_item_t){"Fire a rocket", COMMAND_FIRE_ROCKET});
- items.push_back((interface::pie_item_t){"Stop", COMMAND_STOP});
}
if (repls) {
- items.push_back((interface::pie_item_t){"Replicate", COMMAND_REPL});
+ items.push_back((interface::pie_item_t){"Spawn a soldier", COMMAND_REPL_SOLDIER});
+ items.push_back((interface::pie_item_t){"Spawn a scientist", COMMAND_REPL_SCIENTIST});
}
return true;
@@ -256,11 +267,35 @@ static void command_soldier(unit_soldier_t *soldier, v2f_t x, int number)
}
}
+static void command_scientist(unit_scientist_t *scientist, v2f_t x, int number)
+{
+ switch (number) {
+ case COMMAND_MOVE:
+ if (!scientist->start_moving(x))
+ scientist->say(text::get(text::SAY_NO_PATH), false);
+ else {
+ scientist->move_marker = std::make_unique<fx_move_marker_t>(scientist->game, scientist->move.path.back());
+ scientist->say(text::get(text::SAY_MOVING), false);
+ }
+ break;
+
+ case COMMAND_STOP:
+ scientist->stop_moving();
+ scientist->say(text::get(text::SAY_STOPPING), false);
+ scientist->aim_marker.reset();
+ break;
+ }
+}
+
static void command_repl(unit_repl_t *repl, v2f_t x, int number)
{
switch (number) {
- case COMMAND_REPL:
- repl->activate();
+ case COMMAND_REPL_SOLDIER:
+ repl->activate(unit_t::UNIT_SOLDIER);
+ break;
+
+ case COMMAND_REPL_SCIENTIST:
+ repl->activate(unit_t::UNIT_SCIENTIST);
break;
}
}
@@ -277,7 +312,8 @@ void state_t::command(v2f_t x, int number)
for (unit_t *unit : selected_units)
unit->cmodel.ignore = true;
- for (unit_t *unit : selected_units) {
+ auto copy = selected_units;
+ for (unit_t *unit : copy) {
if (unit->dead || !unit->controllable)
continue;
@@ -287,6 +323,11 @@ void state_t::command(v2f_t x, int number)
x, number);
break;
+ case unit_t::UNIT_SCIENTIST:
+ command_scientist(dynamic_cast<unit_scientist_t*>(unit),
+ x, number);
+ break;
+
case unit_t::UNIT_REPL:
command_repl(dynamic_cast<unit_repl_t*>(unit),
x, number);