2021-01-29 01:37:33 +00:00
|
|
|
use crate::{combat::Attack, uid::Uid};
|
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;
|
|
|
|
|
2021-01-29 01:37:33 +00:00
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
2020-09-05 16:27:36 +00:00
|
|
|
pub struct Properties {
|
2021-01-29 01:37:33 +00:00
|
|
|
pub attack: Attack,
|
2020-09-05 16:27:36 +00:00
|
|
|
pub angle: f32,
|
|
|
|
pub speed: f32,
|
|
|
|
pub duration: Duration,
|
|
|
|
pub owner: Option<Uid>,
|
2021-03-03 04:56:09 +00:00
|
|
|
pub specifier: FrontendSpecifier,
|
2020-09-05 16:27:36 +00:00
|
|
|
}
|
|
|
|
|
2021-01-29 01:37:33 +00:00
|
|
|
// TODO: Separate components out for cheaper network syncing
|
|
|
|
#[derive(Clone, Debug, 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
|
|
|
}
|
2021-03-03 04:56:09 +00:00
|
|
|
|
|
|
|
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)]
|
|
|
|
pub enum FrontendSpecifier {
|
|
|
|
Flamethrower,
|
|
|
|
LifestealBeam,
|
|
|
|
HealingBeam,
|
2021-03-20 17:29:57 +00:00
|
|
|
Cultist,
|
2021-03-03 04:56:09 +00:00
|
|
|
}
|