From d04e1b48bd934f8d9d91aab13e9e51393fd7b6ba Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Wed, 25 Apr 2018 18:51:04 +0200 Subject: Rename repl/replicator to teleporter. --- src/game/assets.cpp | 16 +++--- src/game/game.cpp | 58 ++++++++++----------- src/game/game.hpp | 12 ++--- src/game/interface.cpp | 4 +- src/game/unit_builder.cpp | 6 +-- src/game/unit_repl.cpp | 118 ------------------------------------------- src/game/unit_teleporter.cpp | 118 +++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 166 insertions(+), 166 deletions(-) delete mode 100644 src/game/unit_repl.cpp create mode 100644 src/game/unit_teleporter.cpp (limited to 'src') diff --git a/src/game/assets.cpp b/src/game/assets.cpp index 22cd88f..35e9880 100644 --- a/src/game/assets.cpp +++ b/src/game/assets.cpp @@ -24,7 +24,7 @@ scientist_assets_t scientist; builder_assets_t builder; spider_assets_t spider; nest_assets_t nest; -repl_assets_t repl; +teleporter_assets_t teleporter; fx_assets_t fx; deco_assets_t deco; audio::ambient_t ambients[AMBIENT_COUNT]; @@ -95,13 +95,13 @@ void load(void) nest.pain.load("assets/units/nest/pain.ogg"); nest.death.load("assets/units/nest/death.ogg"); - repl.idle.load("assets/units/repl/idle_", 4); - repl.unfinished.load("assets/units/repl/unfinished_", 1); - repl.avatar.load("assets/units/repl/avatar_", 1); - repl.sound.load("assets/units/repl/sound.ogg"); - repl.damage.load("assets/units/repl/damage1.ogg"); - repl.damage.load("assets/units/repl/damage2.ogg"); - repl.damage.load("assets/units/repl/damage3.ogg"); + teleporter.idle.load("assets/units/teleporter/idle_", 4); + teleporter.unfinished.load("assets/units/teleporter/unfinished_", 1); + teleporter.avatar.load("assets/units/teleporter/avatar_", 1); + teleporter.sound.load("assets/units/teleporter/sound.ogg"); + teleporter.damage.load("assets/units/teleporter/damage1.ogg"); + teleporter.damage.load("assets/units/teleporter/damage2.ogg"); + teleporter.damage.load("assets/units/teleporter/damage3.ogg"); fx.blood.load("assets/units/blood_", 4); fx.flash.load("assets/units/flash_", 1); diff --git a/src/game/game.cpp b/src/game/game.cpp index 2ad7f05..2e15024 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -80,16 +80,16 @@ void entity_t::sleep(void) void state_t::start(void) { - unit_repl_t *repl; + unit_teleporter_t *teleporter; world.generator = worldgen; world.generator_data = (void*)this; - 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); + teleporter = new unit_teleporter_t(this); + teleporter->place(&world, v2f_t(5.3, 4.2)); + teleporter->constructed = true; + teleporter->health = teleporter->max_health; + select_unit(teleporter, SELECT_NEW); resume(); } @@ -183,19 +183,19 @@ enum { COMMAND_THROW_GRENADE, COMMAND_STOP, - COMMAND_REPL_SOLDIER, - COMMAND_REPL_SCIENTIST, - COMMAND_REPL_BUILDER, + COMMAND_HIRE_SOLDIER, + COMMAND_HIRE_SCIENTIST, + COMMAND_HIRE_BUILDER, COMMAND_GATHER, COMMAND_REPAIR, - COMMAND_BUILD_REPL + COMMAND_BUILD_TELEPORTER }; bool state_t::populate_pie_menu(std::vector &items) { - bool soldiers = false, repls = false, grenades = false, + bool soldiers = false, teleporters = false, grenades = false, scientists = false, builders = false; items.clear(); @@ -222,8 +222,8 @@ bool state_t::populate_pie_menu(std::vector &items) builders = true; break; - case unit_t::UNIT_REPL: - repls = true; + case unit_t::UNIT_TELEPORTER: + teleporters = true; break; default:; @@ -246,13 +246,13 @@ bool state_t::populate_pie_menu(std::vector &items) 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}); + items.push_back((interface::pie_item_t){"Build a teleporter", COMMAND_BUILD_TELEPORTER}); } - if (repls) { - 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}); - items.push_back((interface::pie_item_t){"Spawn a builder", COMMAND_REPL_BUILDER}); + if (teleporters) { + items.push_back((interface::pie_item_t){"Hire a soldier", COMMAND_HIRE_SOLDIER}); + items.push_back((interface::pie_item_t){"Hire a scientist", COMMAND_HIRE_SCIENTIST}); + items.push_back((interface::pie_item_t){"Hire a builder", COMMAND_HIRE_BUILDER}); } return true; @@ -336,25 +336,25 @@ static void command_builder(unit_builder_t *builder, v2f_t x, int number) builder->command_repair(x); break; - case COMMAND_BUILD_REPL: - builder->command_build(x, unit_t::UNIT_REPL); + case COMMAND_BUILD_TELEPORTER: + builder->command_build(x, unit_t::UNIT_TELEPORTER); break; } } -static void command_repl(unit_repl_t *repl, v2f_t x, int number) +static void command_teleporter(unit_teleporter_t *teleporter, v2f_t x, int number) { switch (number) { - case COMMAND_REPL_SOLDIER: - repl->activate(unit_t::UNIT_SOLDIER); + case COMMAND_HIRE_SOLDIER: + teleporter->activate(unit_t::UNIT_SOLDIER); break; - case COMMAND_REPL_SCIENTIST: - repl->activate(unit_t::UNIT_SCIENTIST); + case COMMAND_HIRE_SCIENTIST: + teleporter->activate(unit_t::UNIT_SCIENTIST); break; - case COMMAND_REPL_BUILDER: - repl->activate(unit_t::UNIT_BUILDER); + case COMMAND_HIRE_BUILDER: + teleporter->activate(unit_t::UNIT_BUILDER); break; } } @@ -392,8 +392,8 @@ void state_t::command(v2f_t x, int number) x, number); break; - case unit_t::UNIT_REPL: - command_repl(dynamic_cast(unit), + case unit_t::UNIT_TELEPORTER: + command_teleporter(dynamic_cast(unit), x, number); break; diff --git a/src/game/game.hpp b/src/game/game.hpp index 19fda52..f630c54 100644 --- a/src/game/game.hpp +++ b/src/game/game.hpp @@ -236,7 +236,7 @@ namespace game { typedef struct { render::animated_texture_t idle, unfinished, avatar; audio::sound_t sound, damage; - } repl_assets_t; + } teleporter_assets_t; typedef struct { render::animated_texture_t blood, flash, explosion, ricochet, water_splash; @@ -264,7 +264,7 @@ namespace game { extern builder_assets_t builder; extern spider_assets_t spider; extern nest_assets_t nest; - extern repl_assets_t repl; + extern teleporter_assets_t teleporter; extern fx_assets_t fx; extern deco_assets_t deco; extern audio::ambient_t ambients[AMBIENT_COUNT]; @@ -324,7 +324,7 @@ namespace game { UNIT_BUILDER, UNIT_SPIDER, UNIT_NEST, - UNIT_REPL + UNIT_TELEPORTER } type_t; game::state_t *game; @@ -502,10 +502,10 @@ namespace game { void on_death(void); }; - class unit_repl_t : public unit_t { + class unit_teleporter_t : public unit_t { public: - unit_repl_t(game::state_t *game_); - ~unit_repl_t(void) {}; + unit_teleporter_t(game::state_t *game_); + ~unit_teleporter_t(void) {}; void render_to(render::state_t *render); void render_late_to(render::state_t *render) {}; diff --git a/src/game/interface.cpp b/src/game/interface.cpp index 1c2d7b5..6375a3c 100644 --- a/src/game/interface.cpp +++ b/src/game/interface.cpp @@ -389,8 +389,8 @@ static void render_avatar(render::state_t *render, game::unit_t *unit, v2f_t at, image = &assets::builder.avatar; break; - case game::unit_t::UNIT_REPL: - image = &assets::repl.avatar; + case game::unit_t::UNIT_TELEPORTER: + image = &assets::teleporter.avatar; break; default: diff --git a/src/game/unit_builder.cpp b/src/game/unit_builder.cpp index d35a1fc..0deae3c 100644 --- a/src/game/unit_builder.cpp +++ b/src/game/unit_builder.cpp @@ -90,8 +90,8 @@ void unit_builder_t::command_build(v2f_t where, type_t what) } switch (what) { - case UNIT_REPL: - built = new unit_repl_t(game); + case UNIT_TELEPORTER: + built = new unit_teleporter_t(game); price = 250; break; @@ -147,7 +147,7 @@ void unit_builder_t::repair(void) } unit = dynamic_cast(trace.ent); - if (unit->type != UNIT_REPL || unit->health >= unit->max_health) { + if (unit->type != UNIT_TELEPORTER || unit->health >= unit->max_health) { repairing = false; return; } diff --git a/src/game/unit_repl.cpp b/src/game/unit_repl.cpp deleted file mode 100644 index 2e0c3fd..0000000 --- a/src/game/unit_repl.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* -This file is part of Minitrem. - -Minitrem is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 2 of the License, or -(at your option) any later version. - -Minitrem is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Minitrem. If not, see . -*/ - -#include "game.hpp" - -namespace game { - -unit_repl_t::unit_repl_t(game::state_t *game_) : unit_t(game_, UNIT_REPL) -{ - size[0] = {-0.4f, -0.2f}; - size[1] = {+0.4f, +0.4f}; - render_size = size; - render_layer = render::LAYER_FLAT; - cmodel.cflags = CF_SURFACE2; - - name = "Replicator"; - ignore_waking = false; - max_health = 35; - health = 5; - - friendly = true; - controllable = true; - constructed = false; -} - -void unit_repl_t::on_damage(unit_t *attacker) -{ - assets::repl.damage.play_3d(x); -} - -void unit_repl_t::on_death(void) -{ - game->explosion(x); - game->deletion_list.insert(this); -} - -void unit_repl_t::render_to(render::state_t *render) -{ - if (constructed) - render->render(game->now, &assets::repl.idle, render_bounds); - else - render->render(game->now, &assets::repl.unfinished, render_bounds); - - unit_t::render_to(render); -} - -void unit_repl_t::activate(unit_t::type_t type) -{ - size_t price; - world::cmodel_t cmodel; - unit_t *unit; - - switch (type) { - case UNIT_SOLDIER: price = 40; break; - case UNIT_SCIENTIST: price = 95; break; - case UNIT_BUILDER: price = 70; break; - default: - abort(); - } - - if (game->crystals < price) { - game->interface.print("Insufficient crystals; " + std::to_string(price - game->crystals) + " more needed."); - return; - } - - game->crystals -= price; - - switch (type) { - case UNIT_SOLDIER: - unit = new unit_soldier_t(game); - break; - - case UNIT_SCIENTIST: - unit = new unit_scientist_t(game); - break; - - case UNIT_BUILDER: - unit = new unit_builder_t(game); - break; - - default: - abort(); - } - - unit->place(world, x); - - for (world::entity_t *ent : game->world.get_entities(unit->cmodel.bounds, CF_BODY|CF_BODY_SMALL)) - { - unit_t *other; - - if (ent == unit) - continue; - - if (ent->type != ET_UNIT) - continue; - - other = dynamic_cast(ent); - other->damage(200, NULL); - } - - assets::repl.sound.play_3d(x); -} - -} diff --git a/src/game/unit_teleporter.cpp b/src/game/unit_teleporter.cpp new file mode 100644 index 0000000..fd73ab6 --- /dev/null +++ b/src/game/unit_teleporter.cpp @@ -0,0 +1,118 @@ +/* +This file is part of Minitrem. + +Minitrem is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +Minitrem is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Minitrem. If not, see . +*/ + +#include "game.hpp" + +namespace game { + +unit_teleporter_t::unit_teleporter_t(game::state_t *game_) : unit_t(game_, UNIT_TELEPORTER) +{ + size[0] = {-0.4f, -0.2f}; + size[1] = {+0.4f, +0.4f}; + render_size = size; + render_layer = render::LAYER_FLAT; + cmodel.cflags = CF_SURFACE2; + + name = "Teleporter"; + ignore_waking = false; + max_health = 35; + health = 5; + + friendly = true; + controllable = true; + constructed = false; +} + +void unit_teleporter_t::on_damage(unit_t *attacker) +{ + assets::teleporter.damage.play_3d(x); +} + +void unit_teleporter_t::on_death(void) +{ + game->explosion(x); + game->deletion_list.insert(this); +} + +void unit_teleporter_t::render_to(render::state_t *render) +{ + if (constructed) + render->render(game->now, &assets::teleporter.idle, render_bounds); + else + render->render(game->now, &assets::teleporter.unfinished, render_bounds); + + unit_t::render_to(render); +} + +void unit_teleporter_t::activate(unit_t::type_t type) +{ + size_t price; + world::cmodel_t cmodel; + unit_t *unit; + + switch (type) { + case UNIT_SOLDIER: price = 40; break; + case UNIT_SCIENTIST: price = 95; break; + case UNIT_BUILDER: price = 70; break; + default: + abort(); + } + + if (game->crystals < price) { + game->interface.print("Insufficient crystals; " + std::to_string(price - game->crystals) + " more needed."); + return; + } + + game->crystals -= price; + + switch (type) { + case UNIT_SOLDIER: + unit = new unit_soldier_t(game); + break; + + case UNIT_SCIENTIST: + unit = new unit_scientist_t(game); + break; + + case UNIT_BUILDER: + unit = new unit_builder_t(game); + break; + + default: + abort(); + } + + unit->place(world, x); + + for (world::entity_t *ent : game->world.get_entities(unit->cmodel.bounds, CF_BODY|CF_BODY_SMALL)) + { + unit_t *other; + + if (ent == unit) + continue; + + if (ent->type != ET_UNIT) + continue; + + other = dynamic_cast(ent); + other->damage(200, NULL); + } + + assets::teleporter.sound.play_3d(x); +} + +} -- cgit