diff options
Diffstat (limited to 'src/game/game.cpp')
-rw-r--r-- | src/game/game.cpp | 58 |
1 files changed, 56 insertions, 2 deletions
diff --git a/src/game/game.cpp b/src/game/game.cpp index 2e15024..b10bc08 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -182,6 +182,8 @@ enum { COMMAND_FIRE, COMMAND_THROW_GRENADE, COMMAND_STOP, + COMMAND_RESTOCK_SHELLS, + COMMAND_RESTOCK_GRENADES, COMMAND_HIRE_SOLDIER, COMMAND_HIRE_SCIENTIST, @@ -190,13 +192,18 @@ enum { COMMAND_GATHER, COMMAND_REPAIR, - COMMAND_BUILD_TELEPORTER + COMMAND_BUILD_TELEPORTER, + COMMAND_BUILD_REPLICATOR, + + COMMAND_REPLICATE_SHELLS, + COMMAND_REPLICATE_GRENADES, }; bool state_t::populate_pie_menu(std::vector<interface::pie_item_t> &items) { bool soldiers = false, teleporters = false, grenades = false, - scientists = false, builders = false; + scientists = false, builders = false, replicators = false, + restock_shells = false, restock_grenades = false; items.clear(); @@ -212,6 +219,10 @@ bool state_t::populate_pie_menu(std::vector<interface::pie_item_t> &items) soldiers = true; if (unit->storage.grenades) grenades = true; + if (unit->storage.shells < unit->storage.max_shells) + restock_shells = true; + if (unit->storage.grenades < unit->storage.max_grenades) + restock_grenades = true; break; case unit_t::UNIT_SCIENTIST: @@ -226,6 +237,10 @@ bool state_t::populate_pie_menu(std::vector<interface::pie_item_t> &items) teleporters = true; break; + case unit_t::UNIT_REPLICATOR: + replicators = true; + break; + default:; } } @@ -239,6 +254,10 @@ bool state_t::populate_pie_menu(std::vector<interface::pie_item_t> &items) items.push_back((interface::pie_item_t){"Fire", COMMAND_FIRE}); if (grenades) items.push_back((interface::pie_item_t){"Throw a grenade", COMMAND_THROW_GRENADE}); + if (restock_shells) + items.push_back((interface::pie_item_t){"Restock shells", COMMAND_RESTOCK_SHELLS}); + if (restock_grenades) + items.push_back((interface::pie_item_t){"Restock grenades", COMMAND_RESTOCK_GRENADES}); } if (scientists) @@ -247,6 +266,7 @@ bool state_t::populate_pie_menu(std::vector<interface::pie_item_t> &items) if (builders) { items.push_back((interface::pie_item_t){"Repair", COMMAND_REPAIR}); items.push_back((interface::pie_item_t){"Build a teleporter", COMMAND_BUILD_TELEPORTER}); + items.push_back((interface::pie_item_t){"Build a replicator", COMMAND_BUILD_REPLICATOR}); } if (teleporters) { @@ -255,6 +275,11 @@ bool state_t::populate_pie_menu(std::vector<interface::pie_item_t> &items) items.push_back((interface::pie_item_t){"Hire a builder", COMMAND_HIRE_BUILDER}); } + if (replicators) { + items.push_back((interface::pie_item_t){"Replicate shells", COMMAND_REPLICATE_SHELLS}); + items.push_back((interface::pie_item_t){"Replicate grenades", COMMAND_REPLICATE_GRENADES}); + } + return true; } @@ -286,6 +311,14 @@ static void command_soldier(unit_soldier_t *soldier, v2f_t x, int number) case COMMAND_THROW_GRENADE: soldier->command_throw_grenade(x); break; + + case COMMAND_RESTOCK_SHELLS: + soldier->command_restock(false); + break; + + case COMMAND_RESTOCK_GRENADES: + soldier->command_restock(true); + break; } } @@ -339,6 +372,10 @@ static void command_builder(unit_builder_t *builder, v2f_t x, int number) case COMMAND_BUILD_TELEPORTER: builder->command_build(x, unit_t::UNIT_TELEPORTER); break; + + case COMMAND_BUILD_REPLICATOR: + builder->command_build(x, unit_t::UNIT_REPLICATOR); + break; } } @@ -359,6 +396,19 @@ static void command_teleporter(unit_teleporter_t *teleporter, v2f_t x, int numbe } } +static void command_replicator(unit_replicator_t *replicator, v2f_t x, int number) +{ + switch (number) { + case COMMAND_REPLICATE_SHELLS: + replicator->activate(false); + break; + + case COMMAND_REPLICATE_GRENADES: + replicator->activate(true); + break; + } +} + void state_t::command(v2f_t x, int number) { bool unlink; @@ -397,6 +447,10 @@ void state_t::command(v2f_t x, int number) x, number); break; + case unit_t::UNIT_REPLICATOR: + command_replicator(dynamic_cast<unit_replicator_t*>(unit), + x, number); + default:; } } |