aboutsummaryrefslogtreecommitdiffstats
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/ability.rs70
-rw-r--r--src/shared/champion.rs7
2 files changed, 59 insertions, 18 deletions
diff --git a/src/shared/ability.rs b/src/shared/ability.rs
index d88b63b..f880fac 100644
--- a/src/shared/ability.rs
+++ b/src/shared/ability.rs
@@ -187,6 +187,7 @@ pub enum DirectionalAbility {
#[derive(Copy, Clone, PartialEq, Debug, Deserialize, Serialize)]
pub struct Dash {
pub max_distance: f32,
+ pub damage: f32,
}
#[derive(Copy, Clone, PartialEq, Debug, Deserialize, Serialize)]
@@ -248,7 +249,10 @@ fn dash_activation(dash: Dash) -> DirectionalAbilityActivation {
return;
};
- let dash_end = {
+ let DashCollisionResult {
+ dash_end,
+ dash_collision,
+ } = {
let dash_targets = set.p1();
dash_collision(
source_player,
@@ -264,13 +268,26 @@ fn dash_activation(dash: Dash) -> DirectionalAbilityActivation {
position.0 = dash_end;
}
- commands.spawn(AreaOfEffectBundle::new(AreaOfEffect {
- position: dash_end,
- radius: 1.5 * PLAYER_RADIUS,
- duration: None,
- source_player,
- area_of_effect_type: AreaOfEffectType::Slow,
- }));
+ if let Some(DashCollision {
+ collision_id,
+ collision_position,
+ }) = dash_collision
+ {
+ commands.spawn(AreaOfEffectBundle::new(AreaOfEffect {
+ position: collision_position,
+ radius: 1.5 * PLAYER_RADIUS,
+ duration: None,
+ source_player,
+ area_of_effect_type: AreaOfEffectType::Slow,
+ }));
+ commands.spawn(ProjectileBundle::new(Projectile {
+ type_: ProjectileType::Instant(InstantProjectile {
+ target_player: collision_id,
+ }),
+ source_player,
+ damage: dash.damage,
+ }));
+ }
},
)
});
@@ -278,15 +295,26 @@ fn dash_activation(dash: Dash) -> DirectionalAbilityActivation {
)
}
+pub struct DashCollisionResult {
+ pub dash_end: Vec2,
+ pub dash_collision: Option<DashCollision>,
+}
+
+pub struct DashCollision {
+ pub collision_id: PlayerId,
+ pub collision_position: Vec2,
+}
+
pub fn dash_collision(
source_id: PlayerId,
dash_start: Vec2,
dash_direction: Vec2,
dash_max_distance: f32,
player_positions: &Query<(&PlayerId, &PlayerPosition)>,
-) -> Vec2 {
+) -> DashCollisionResult {
let mut dash_collision = dash_max_distance * dash_direction;
- let mut collision = false;
+ let mut collision_id = None;
+ let mut collision_position = None;
for (player_id, position) in player_positions.iter() {
if *player_id == source_id {
continue;
@@ -304,16 +332,28 @@ pub fn dash_collision(
}
if player_rejection.length() < 2. * PLAYER_RADIUS {
- collision = true;
dash_collision = player_projection;
+ collision_id = Some(*player_id);
+ collision_position = Some(position.0);
}
}
- if collision {
- dash_start
- + (dash_collision.length() - 2. * PLAYER_RADIUS) * dash_collision.normalize_or_zero()
+ if let (Some(collision_id), Some(collision_position)) = (collision_id, collision_position) {
+ let dash_end = dash_start
+ + (dash_collision.length() - 2. * PLAYER_RADIUS) * dash_collision.normalize_or_zero();
+ DashCollisionResult {
+ dash_end,
+ dash_collision: Some(DashCollision {
+ collision_id,
+ collision_position,
+ }),
+ }
} else {
- dash_start + dash_max_distance * dash_direction
+ let dash_end = dash_start + dash_max_distance * dash_direction;
+ DashCollisionResult {
+ dash_end,
+ dash_collision: None,
+ }
}
}
diff --git a/src/shared/champion.rs b/src/shared/champion.rs
index 86bd41e..6e6b01b 100644
--- a/src/shared/champion.rs
+++ b/src/shared/champion.rs
@@ -49,9 +49,10 @@ impl Champion {
pub fn ability(self, ability_slot: AbilitySlot) -> Ability {
match self {
Champion::Meele => match ability_slot {
- AbilitySlot::Q => {
- Ability::Directional(DirectionalAbility::Dash(Dash { max_distance: 60. }))
- }
+ AbilitySlot::Q => Ability::Directional(DirectionalAbility::Dash(Dash {
+ max_distance: 60.,
+ damage: 15.,
+ })),
AbilitySlot::W => {
Ability::Directional(DirectionalAbility::Pull(Pull { max_distance: 60. }))
}