2020-12-06 02:29:46 +00:00
|
|
|
use crate::{
|
|
|
|
comp::{PoiseChange, PoiseSource},
|
|
|
|
uid::Uid,
|
|
|
|
Damage, GroupTarget,
|
|
|
|
};
|
2020-09-05 16:27:36 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
2021-01-07 20:25:12 +00:00
|
|
|
use specs::{Component, DerefFlaggedStorage};
|
2020-09-05 16:27:36 +00:00
|
|
|
use specs_idvs::IdvStorage;
|
|
|
|
use std::time::Duration;
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
|
|
|
pub struct Properties {
|
|
|
|
pub angle: f32,
|
|
|
|
pub speed: f32,
|
2020-12-06 02:29:46 +00:00
|
|
|
pub effects: Vec<(Option<GroupTarget>, Damage, PoiseChange)>,
|
2020-09-05 16:27:36 +00:00
|
|
|
pub lifesteal_eff: f32,
|
2020-09-06 21:01:56 +00:00
|
|
|
pub energy_regen: u32,
|
2020-10-07 02:32:57 +00:00
|
|
|
pub energy_cost: u32,
|
2020-09-05 16:27:36 +00:00
|
|
|
pub duration: Duration,
|
|
|
|
pub owner: Option<Uid>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
2020-09-24 02:02:30 +00:00
|
|
|
pub struct BeamSegment {
|
2020-09-05 16:27:36 +00:00
|
|
|
pub properties: Properties,
|
|
|
|
#[serde(skip)]
|
|
|
|
/// Time that the beam segment was created at
|
|
|
|
/// Used to calculate beam propagation
|
|
|
|
/// Deserialized from the network as `None`
|
|
|
|
pub creation: Option<f64>,
|
|
|
|
}
|
|
|
|
|
2020-09-24 02:02:30 +00:00
|
|
|
impl Component for BeamSegment {
|
2021-01-07 20:25:12 +00:00
|
|
|
type Storage = DerefFlaggedStorage<Self, IdvStorage<Self>>;
|
2020-09-05 16:27:36 +00:00
|
|
|
}
|
|
|
|
|
2020-09-24 02:02:30 +00:00
|
|
|
impl std::ops::Deref for BeamSegment {
|
2020-09-05 16:27:36 +00:00
|
|
|
type Target = Properties;
|
|
|
|
|
|
|
|
fn deref(&self) -> &Properties { &self.properties }
|
|
|
|
}
|
2020-09-24 02:02:30 +00:00
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
|
|
|
pub struct Beam {
|
|
|
|
pub hit_entities: Vec<Uid>,
|
|
|
|
pub tick_dur: Duration,
|
|
|
|
pub timer: Duration,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Component for Beam {
|
2020-09-30 00:47:11 +00:00
|
|
|
type Storage = IdvStorage<Self>;
|
2020-09-24 02:02:30 +00:00
|
|
|
}
|