2020-11-09 03:09:33 +00:00
|
|
|
use crate::{effect::BuffEffect, sync::Uid, Damage, Explosion, GroupTarget, Knockback};
|
2020-07-06 14:23:08 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
2019-09-26 16:48:37 +00:00
|
|
|
use specs::{Component, FlaggedStorage};
|
2020-07-06 05:56:02 +00:00
|
|
|
use specs_idvs::IdvStorage;
|
2019-10-06 17:30:06 +00:00
|
|
|
use std::time::Duration;
|
2019-09-17 12:43:19 +00:00
|
|
|
|
2020-03-16 11:32:57 +00:00
|
|
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
2019-09-17 12:43:19 +00:00
|
|
|
pub enum Effect {
|
2020-11-04 02:01:12 +00:00
|
|
|
Damage(Option<GroupTarget>, Damage),
|
2020-10-18 18:21:58 +00:00
|
|
|
Knockback(Knockback),
|
2020-03-27 16:07:19 +00:00
|
|
|
RewardEnergy(u32),
|
2020-10-06 02:19:41 +00:00
|
|
|
Explode(Explosion),
|
2019-09-17 12:43:19 +00:00
|
|
|
Vanish,
|
2019-09-28 19:35:28 +00:00
|
|
|
Stick,
|
2019-10-11 23:30:05 +00:00
|
|
|
Possess,
|
2020-11-09 03:09:33 +00:00
|
|
|
Buff {
|
|
|
|
buff: BuffEffect,
|
|
|
|
chance: Option<f32>,
|
|
|
|
},
|
2019-09-17 12:43:19 +00:00
|
|
|
}
|
|
|
|
|
2020-03-16 11:32:57 +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>,
|
2019-10-06 17:30:06 +00:00
|
|
|
/// Time left until the projectile will despawn
|
|
|
|
pub time_left: Duration,
|
2020-03-16 11:32:57 +00:00
|
|
|
pub owner: Option<Uid>,
|
2020-09-19 08:47:40 +00:00
|
|
|
/// 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 {
|
2020-07-06 05:56:02 +00:00
|
|
|
type Storage = FlaggedStorage<Self, IdvStorage<Self>>;
|
2019-09-17 12:43:19 +00:00
|
|
|
}
|