veloren_common/comp/
beam.rs

1use crate::{combat::Attack, comp::ability::Dodgeable, resources::Secs};
2use hashbrown::HashMap;
3use serde::{Deserialize, Serialize};
4use specs::{Component, DerefFlaggedStorage, Entity as EcsEntity};
5use vek::*;
6
7#[derive(Clone, Debug, Serialize, Deserialize)]
8pub struct Beam {
9    pub attack: Attack,
10    pub dodgeable: Dodgeable,
11    pub start_radius: f32,
12    pub end_radius: f32,
13    pub range: f32,
14    pub duration: Secs,
15    pub tick_dur: Secs,
16    pub specifier: FrontendSpecifier,
17    pub bezier: QuadraticBezier3<f32>,
18    #[serde(skip)]
19    pub hit_entities: Vec<EcsEntity>,
20    #[serde(skip)]
21    pub hit_durations: HashMap<EcsEntity, u32>,
22}
23
24impl Beam {
25    pub fn hit_entities_and_durations(
26        &mut self,
27    ) -> (&Vec<EcsEntity>, &mut HashMap<EcsEntity, u32>) {
28        (&self.hit_entities, &mut self.hit_durations)
29    }
30}
31
32impl Component for Beam {
33    type Storage = DerefFlaggedStorage<Self, specs::DenseVecStorage<Self>>;
34}
35
36#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, strum::EnumString)]
37pub enum FrontendSpecifier {
38    Flamethrower,
39    LifestealBeam,
40    Cultist,
41    Gravewarden,
42    Bubbles,
43    Steam,
44    Frost,
45    WebStrand,
46    Poison,
47    Ink,
48    Lightning,
49    PhoenixLaser,
50    FireGigasOverheat,
51    FirePillar,
52    FlameWallPillar,
53}