diff options
Diffstat (limited to 'src/server.rs')
-rw-r--r-- | src/server.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/server.rs b/src/server.rs index f6cbac3..7d50d9f 100644 --- a/src/server.rs +++ b/src/server.rs @@ -3,6 +3,7 @@ use crate::server::network::*; use crate::shared::champion::*; use crate::shared::cooldown::*; use crate::shared::health::*; +use crate::shared::health_event::*; use crate::shared::imperative::*; use crate::shared::projectile::*; use crate::shared::*; @@ -350,10 +351,11 @@ fn projectile_move( fn projectile_despawn( entity_map: Res<EntityMap>, mut commands: Commands, + mut connection_manager: ResMut<ServerConnectionManager>, mut healths: Query<&mut Health>, player_positions: Query<&PlayerPosition>, - projectile_targets: Query<(&PlayerId, &PlayerPosition)>, projectiles: Query<(Entity, &mut Projectile)>, + projectile_targets: Query<(&PlayerId, &PlayerPosition)>, ) { for (entity, projectile) in projectiles.iter() { let (despawn, maybe_target_player): (bool, Option<PlayerId>) = (|| match &projectile.type_ { @@ -414,6 +416,14 @@ fn projectile_despawn( if let Some(target_player) = maybe_target_player { if let Some(target_entity) = entity_map.0.get(&target_player.0) { if let Ok(mut health) = healths.get_mut(*target_entity) { + let _ = connection_manager + .send_message_to_target::<Channel1, HealthChanged>( + HealthChanged(HealthEvent { + target_player, + health_gained: -projectile.damage, + }), + NetworkTarget::All, + ); health.0 = (health.0 - projectile.damage).max(0.); } } |