veloren/common/src/comp/ability.rs

48 lines
1.2 KiB
Rust
Raw Normal View History

2020-03-07 18:15:02 +00:00
use specs::{Component, DenseVecStorage, FlaggedStorage, HashMapStorage};
2020-01-01 17:16:29 +00:00
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
2020-03-07 18:15:02 +00:00
pub enum AbilityState {
2020-03-12 14:36:02 +00:00
BasicAttack {
/// Amount of energy required to use ability
cost: i32,
},
2020-03-07 18:15:02 +00:00
BasicBlock,
Roll,
2020-03-08 17:04:26 +00:00
ChargeAttack,
2020-03-12 14:36:02 +00:00
TimedCombo {
/// Amount of energy required to use ability
cost: i32,
},
2020-01-01 17:16:29 +00:00
}
2020-03-07 18:15:02 +00:00
impl Default for AbilityState {
2020-03-12 14:36:02 +00:00
fn default() -> Self { Self::BasicAttack { cost: -100 } }
2020-01-01 17:16:29 +00:00
}
2020-03-07 18:15:02 +00:00
impl Component for AbilityState {
type Storage = DenseVecStorage<Self>;
2020-01-01 17:16:29 +00:00
}
2020-02-03 10:54:50 +00:00
#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
2020-01-01 17:16:29 +00:00
pub struct AbilityPool {
2020-03-07 18:15:02 +00:00
pub primary: Option<AbilityState>,
pub secondary: Option<AbilityState>,
pub block: Option<AbilityState>,
pub dodge: Option<AbilityState>,
2020-01-01 17:16:29 +00:00
}
2020-02-03 10:54:50 +00:00
impl Default for AbilityPool {
fn default() -> Self {
Self {
2020-03-12 14:36:02 +00:00
primary: Some(AbilityState::default()),
// primary: Some(AbilityState::TimedCombo),
2020-03-08 19:37:17 +00:00
secondary: Some(AbilityState::BasicBlock),
2020-02-03 10:54:50 +00:00
block: None,
2020-03-07 18:15:02 +00:00
dodge: Some(AbilityState::Roll),
2020-02-03 10:54:50 +00:00
}
}
}
2020-01-01 17:16:29 +00:00
impl Component for AbilityPool {
2020-01-07 15:49:08 +00:00
type Storage = FlaggedStorage<Self, HashMapStorage<Self>>;
2020-01-01 17:16:29 +00:00
}