aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/server.rs27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/server.rs b/src/server.rs
index 413c7fd..d9eccb6 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -101,7 +101,8 @@ impl Plugin for ServerPlugin {
(tower_ai, (minion_ai_attack, minion_ai_walk).chain())
.before(imperative_attack_approach),
)
- .add_systems(FixedUpdate, minion_despawn)
+ .add_systems(FixedUpdate, despawn)
+ .add_systems(FixedUpdate, player_respawn)
.add_systems(FixedUpdate, (nexus_tick, nexus_spawn_minions))
.add_systems(
FixedUpdate,
@@ -834,15 +835,27 @@ fn minion_ai_attack(
}
}
-fn minion_despawn(
- minions: Query<(Entity, &PlayerId, &Health), With<Minion>>,
+fn despawn(
+ minions: Query<(Entity, &PlayerId, &Health), Without<Player>>,
mut commands: Commands,
mut entity_map: ResMut<EntityMap>,
) {
- for (minion_entity, minion_player_id, minion_health) in minions.iter() {
- if minion_health.health <= 0. {
- commands.entity(minion_entity).despawn();
- entity_map.0.remove(&minion_player_id.0);
+ for (entity, player_id, health) in minions.iter() {
+ if health.health <= 0. {
+ commands.entity(entity).despawn();
+ entity_map.0.remove(&player_id.0);
+ }
+ }
+}
+
+fn player_respawn(
+ mut players: Query<(&mut Health, &mut PlayerPosition, &EffectiveStats), With<Player>>,
+) {
+ for (mut health, mut player_position, effective_stats) in players.iter_mut() {
+ if health.health <= 0. {
+ health.health = effective_stats.0.max_health;
+ health.shield = 0.;
+ player_position.0 = Vec2::ZERO;
}
}
}