diff options
Diffstat (limited to 'src/server.rs')
-rw-r--r-- | src/server.rs | 28 |
1 files changed, 4 insertions, 24 deletions
diff --git a/src/server.rs b/src/server.rs index b2f22b3..f6cbac3 100644 --- a/src/server.rs +++ b/src/server.rs @@ -246,7 +246,7 @@ fn imperative_attack_attack( ) { for (id, mut imperative) in players.iter_mut() { match *imperative { - Imperative::AttackTarget(_, target_player) => { + Imperative::AttackTarget(ability, target_player) => { let Some(entity) = entity_map.0.get(&id.0) else { *imperative = Imperative::Idle; return; @@ -273,26 +273,14 @@ fn imperative_attack_attack( }; if cooldown.a_cooldown.is_zero() { cooldown.a_cooldown = Duration::from_secs_f32(1.5); - let projectile_type = if *champion == Champion::Meele { - ProjectileType::Instant(InstantProjectile { target_player }) - } else { - ProjectileType::Targeted(TargetedProjectile { - target_player, - position: position.0, - }) - }; commands.spawn(ProjectileBundle { - projectile: Projectile { - source_player: *id, - damage: 4., - type_: projectile_type, - }, + projectile: ability.to_projectile(*id, position.0, target_player), replicate: Replicate::default(), }); } } } - Imperative::AttackDirection(_, direction) => { + Imperative::AttackDirection(ability, direction) => { let Some(entity) = entity_map.0.get(&id.0) else { *imperative = Imperative::Idle; return; @@ -308,15 +296,7 @@ fn imperative_attack_attack( if cooldown.a_cooldown.is_zero() { cooldown.a_cooldown = Duration::from_secs_f32(1.5); commands.spawn(ProjectileBundle { - projectile: Projectile { - source_player: *id, - damage: 4., - type_: ProjectileType::Free(FreeProjectile { - position: position.0, - direction, - starting_position: position.0, - }), - }, + projectile: ability.to_projectile(*id, position.0, direction), replicate: Replicate::default(), }); } |