veloren/common/src/comp/projectile.rs

34 lines
880 B
Rust
Raw Normal View History

use crate::{sync::Uid, Explosion};
use serde::{Deserialize, Serialize};
2019-09-26 16:48:37 +00:00
use specs::{Component, FlaggedStorage};
use specs_idvs::IdvStorage;
use std::time::Duration;
2019-09-17 12:43:19 +00:00
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2019-09-17 12:43:19 +00:00
pub enum Effect {
2020-07-25 23:57:04 +00:00
Damage(i32),
Knockback(f32),
2020-03-27 16:07:19 +00:00
RewardEnergy(u32),
Explode(Explosion),
2019-09-17 12:43:19 +00:00
Vanish,
2019-09-28 19:35:28 +00:00
Stick,
Possess,
2019-09-17 12:43:19 +00:00
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
2019-09-17 12:43:19 +00:00
pub struct Projectile {
2019-11-04 00:57:36 +00:00
// TODO: use SmallVec for these effects
2020-04-26 15:16:35 +00:00
pub hit_solid: Vec<Effect>,
2019-09-17 12:43:19 +00:00
pub hit_entity: Vec<Effect>,
/// Time left until the projectile will despawn
pub time_left: Duration,
pub owner: Option<Uid>,
/// Whether projectile collides with entities in the same group as its
/// owner
pub ignore_group: bool,
2019-09-17 12:43:19 +00:00
}
impl Component for Projectile {
type Storage = FlaggedStorage<Self, IdvStorage<Self>>;
2019-09-17 12:43:19 +00:00
}