summaryrefslogtreecommitdiff
path: root/src/game/units.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/units.cpp')
-rw-r--r--src/game/units.cpp36
1 files changed, 23 insertions, 13 deletions
diff --git a/src/game/units.cpp b/src/game/units.cpp
index e7f5e81..214861b 100644
--- a/src/game/units.cpp
+++ b/src/game/units.cpp
@@ -7,12 +7,6 @@ unit_t::unit_t(game::state_t *game_, unit_t::type_t type_) : game::entity_t(game
type = type_;
}
-void unit_t::render_to_pre(render::state_t *render)
-{
- if (!dead && selected == selection_cookie)
- render->render(0.0, &assets::unit_selected, cmodel.bounds);
-}
-
void unit_t::render_to(render::state_t *render)
{
if (!dead && health < max_health)
@@ -440,8 +434,6 @@ void unit_soldier_t::on_think(void)
void unit_soldier_t::on_death(void)
{
- game->selected_units.erase(this);
-
render_size[0] = v2f_t(-0.75f, -0.5f);
render_size[1] = v2f_t(+0.75f, +0.5f);
render_layer = -1;
@@ -451,7 +443,23 @@ void unit_soldier_t::on_death(void)
void unit_soldier_t::render_to(render::state_t *render)
{
- unit_t::render_to_pre(render);
+ sf::Color selection_color;
+
+ if (selected == selection_cookie) {
+ if (health == max_health)
+ selection_color = sf::Color::Green;
+ else if (health >= max_health / 2)
+ selection_color = sf::Color::Yellow;
+ else if (dead)
+ selection_color = sf::Color::Black;
+ else
+ selection_color = sf::Color::Red;
+
+ if (panic && (game->now - floor(game->now) > 0.5))
+ selection_color = sf::Color::Blue;
+
+ render->render(0.0, &assets::unit_selected, cmodel.bounds, selection_color);
+ }
if (!dead) {
render::oriented_sprite_t *legs, *body;
@@ -489,6 +497,12 @@ void unit_soldier_t::render_to(render::state_t *render)
unit_t::render_to(render);
}
+void unit_soldier_t::render_late_to(render::state_t *render)
+{
+ if (selected == selection_cookie)
+ render->render(0.0, &assets::unit_selected_halo, cmodel.bounds, selection_color);
+}
+
unit_spider_t::unit_spider_t(game::state_t *game) : unit_t(game, UNIT_SPIDER)
{
size[0] = v2f_t(-0.2f, +0.0f);
@@ -561,8 +575,6 @@ void unit_spider_t::render_to(render::state_t *render)
{
bool moving;
- unit_t::render_to_pre(render);
-
moving = move.moving && !move.blocked;
if (!dead)
@@ -640,8 +652,6 @@ void unit_nest_t::on_death(void)
void unit_nest_t::render_to(render::state_t *render)
{
- unit_t::render_to_pre(render);
-
if (!dead)
render->render(game->now, &assets::nest.idle, render_bounds);
else