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 FireLow,
57 Water,
58 Ice,
59 IceSpikes,
60 Steam,
61 Poison,
62 AcidCloud,
63 Ink,
64 Lightning,
65}
66
67impl Dodgeable {
68 pub fn shockwave_attack_source(&self) -> AttackSource {
69 match self {
70 Self::Roll => AttackSource::AirShockwave,
71 Self::Jump => AttackSource::GroundShockwave,
72 Self::No => AttackSource::UndodgeableShockwave,
73 }
74 }
75
76 pub fn shockwave_attack_source_slice(&self) -> &[AttackSource] {
77 match self {
78 Self::Roll => &[AttackSource::AirShockwave],
79 Self::Jump => &[AttackSource::GroundShockwave],
80 Self::No => &[AttackSource::UndodgeableShockwave],
81 }
82 }
83
84 pub fn explosion_shockwave_attack_source_slice(&self) -> &[AttackSource] {
85 match self {
86 Self::Roll => &[AttackSource::Explosion, AttackSource::AirShockwave],
87 Self::Jump => &[AttackSource::Explosion, AttackSource::GroundShockwave],
88 Self::No => &[AttackSource::Explosion, AttackSource::UndodgeableShockwave],
89 }
90 }
91}