aboutsummaryrefslogtreecommitdiffstats
path: root/src/client.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/client.rs')
-rw-r--r--src/client.rs50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/client.rs b/src/client.rs
index a1aa250..12f12c0 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -14,6 +14,7 @@ use crate::shared::player::*;
use crate::shared::projectile::*;
use crate::shared::shape::*;
use crate::shared::stats::*;
+use crate::shared::tower::*;
use bevy::input::keyboard::*;
use bevy::input::mouse::MouseButton;
use bevy::prelude::*;
@@ -86,6 +87,8 @@ impl Plugin for ClientPlugin {
render_area_of_effects,
render_health,
render_buffs,
+ render_tower_target,
+ render_tower_range,
),
)
.add_systems(
@@ -581,6 +584,18 @@ fn player_position(
None
}
+fn other_player_position(
+ player_id: PlayerId,
+ players: &Query<(&PlayerId, &PlayerPosition)>,
+) -> Option<PlayerPosition> {
+ for (id, position) in players.iter() {
+ if *id == player_id {
+ return Some(*position);
+ }
+ }
+ None
+}
+
fn player_effective_stats(
client_id: &Res<ClientId>,
players: &Query<(&PlayerId, &EffectiveStats)>,
@@ -659,6 +674,41 @@ fn render_buffs(players: Query<(&Buffs, &PlayerPosition, &Shape)>, mut gizmos: G
}
}
+fn render_tower_range(
+ towers: Query<(&PlayerPosition, &EffectiveStats, &Faction), With<Tower>>,
+ mut gizmos: Gizmos,
+) {
+ for (player_position, effective_stats, faction) in towers.iter() {
+ gizmos.circle_2d(
+ player_position.0,
+ effective_stats.0.attack_range,
+ faction.to_color(),
+ );
+ }
+}
+
+fn render_tower_target(
+ towers: Query<(&Tower, &PlayerPosition, &Faction)>,
+ player_positions: Query<(&PlayerId, &PlayerPosition)>,
+ mut gizmos: Gizmos,
+) {
+ for (tower, player_position, faction) in towers.iter() {
+ let Some(last_target) = tower.last_target else {
+ continue;
+ };
+ let Some(target_player_position) =
+ other_player_position(last_target.player_id, &player_positions)
+ else {
+ continue;
+ };
+ gizmos.line_2d(
+ player_position.0,
+ target_player_position.0,
+ faction.to_color(),
+ );
+ }
+}
+
fn hotbar_cooldown(
client_id: Res<ClientId>,
cooldowns: Query<(&PlayerId, &Cooldown)>,