veloren_common/comp/
shockwave.rs1use crate::{
2 combat::{Attack, AttackSource},
3 uid::Uid,
4};
5use serde::{Deserialize, Serialize};
6use specs::{Component, DerefFlaggedStorage};
7use std::time::Duration;
8
9use super::ability::Dodgeable;
10
11#[derive(Clone, Debug, Serialize, Deserialize)]
12pub struct Properties {
13 pub angle: f32,
14 pub vertical_angle: f32,
15 pub speed: f32,
16 pub attack: Attack,
17 pub dodgeable: Dodgeable,
18 pub duration: Duration,
19 pub owner: Option<Uid>,
20 pub specifier: FrontendSpecifier,
21}
22
23#[derive(Clone, Debug, Serialize, Deserialize)]
24pub struct Shockwave {
25 pub properties: Properties,
26 #[serde(skip)]
27 pub creation: Option<f64>,
31}
32
33impl Component for Shockwave {
34 type Storage = DerefFlaggedStorage<Self, specs::DenseVecStorage<Self>>;
35}
36
37impl std::ops::Deref for Shockwave {
38 type Target = Properties;
39
40 fn deref(&self) -> &Properties { &self.properties }
41}
42
43#[derive(Clone, Debug, PartialEq, Eq)]
44pub struct ShockwaveHitEntities {
45 pub hit_entities: Vec<Uid>,
46}
47
48impl Component for ShockwaveHitEntities {
49 type Storage = specs::DenseVecStorage<Self>;
50}
51
52#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
53pub enum FrontendSpecifier {
54 Ground,
55 Fire,
56 Water,
57 Ice,
58 IceSpikes,
59 Steam,
60 Poison,
61 AcidCloud,
62 Ink,
63 Lightning,
64}
65
66impl Dodgeable {
67 pub fn shockwave_attack_source(&self) -> AttackSource {
68 match self {
69 Self::Roll => AttackSource::AirShockwave,
70 Self::Jump => AttackSource::GroundShockwave,
71 Self::No => AttackSource::UndodgeableShockwave,
72 }
73 }
74}