2020-03-14 18:50:07 +00:00
|
|
|
use crate::{
|
2020-03-14 21:33:20 +00:00
|
|
|
comp::{CharacterState, Item, ToolData},
|
2020-03-14 18:50:07 +00:00
|
|
|
states::*,
|
|
|
|
};
|
2020-03-07 18:15:02 +00:00
|
|
|
use specs::{Component, DenseVecStorage, FlaggedStorage, HashMapStorage};
|
2020-03-14 15:40:29 +00:00
|
|
|
use std::time::Duration;
|
2020-01-01 17:16:29 +00:00
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
2020-03-14 15:40:29 +00:00
|
|
|
pub enum CharacterAbility {
|
2020-03-12 14:36:02 +00:00
|
|
|
BasicAttack {
|
2020-03-14 15:40:29 +00:00
|
|
|
buildup_duration: Duration,
|
|
|
|
recover_duration: Duration,
|
2020-03-15 13:34:17 +00:00
|
|
|
base_damage: u32,
|
2020-03-12 14:36:02 +00:00
|
|
|
},
|
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 {
|
2020-03-14 18:50:07 +00:00
|
|
|
buildup_duration: Duration,
|
|
|
|
recover_duration: Duration,
|
2020-03-15 13:34:17 +00:00
|
|
|
base_damage: u32,
|
2020-03-12 14:36:02 +00:00
|
|
|
},
|
2020-01-01 17:16:29 +00:00
|
|
|
}
|
|
|
|
|
2020-03-14 15:40:29 +00:00
|
|
|
impl Component for CharacterAbility {
|
2020-03-07 18:15:02 +00:00
|
|
|
type Storage = DenseVecStorage<Self>;
|
2020-01-01 17:16:29 +00:00
|
|
|
}
|
|
|
|
|
2020-03-14 21:33:20 +00:00
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
|
|
pub struct ItemConfig {
|
|
|
|
pub item: Item,
|
|
|
|
pub primary_ability: Option<CharacterAbility>,
|
|
|
|
pub secondary_ability: Option<CharacterAbility>,
|
|
|
|
pub block_ability: Option<CharacterAbility>,
|
|
|
|
pub dodge_ability: Option<CharacterAbility>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Default, Debug, Serialize, Deserialize)]
|
|
|
|
pub struct Loadout {
|
|
|
|
pub active_item: Option<ItemConfig>,
|
|
|
|
pub second_item: Option<ItemConfig>,
|
2020-02-26 17:04:43 +00:00
|
|
|
|
|
|
|
pub shoulder: Option<Item>,
|
|
|
|
pub chest: Option<Item>,
|
|
|
|
pub belt: Option<Item>,
|
|
|
|
pub hand: Option<Item>,
|
|
|
|
pub pants: Option<Item>,
|
|
|
|
pub foot: Option<Item>,
|
2020-01-01 17:16:29 +00:00
|
|
|
}
|
|
|
|
|
2020-03-14 15:40:29 +00:00
|
|
|
impl From<CharacterAbility> for CharacterState {
|
|
|
|
fn from(ability: CharacterAbility) -> Self {
|
|
|
|
match ability {
|
|
|
|
CharacterAbility::BasicAttack {
|
|
|
|
buildup_duration,
|
|
|
|
recover_duration,
|
2020-03-15 13:34:17 +00:00
|
|
|
base_damage,
|
2020-03-14 21:17:27 +00:00
|
|
|
} => CharacterState::BasicAttack(basic_attack::Data {
|
2020-03-14 15:40:29 +00:00
|
|
|
exhausted: false,
|
|
|
|
buildup_duration,
|
|
|
|
recover_duration,
|
2020-03-15 13:34:17 +00:00
|
|
|
base_damage,
|
2020-03-14 18:50:07 +00:00
|
|
|
}),
|
2020-03-14 21:17:27 +00:00
|
|
|
CharacterAbility::BasicBlock { .. } => CharacterState::BasicBlock,
|
|
|
|
CharacterAbility::Roll { .. } => CharacterState::Roll(roll::Data {
|
2020-03-14 15:40:29 +00:00
|
|
|
remaining_duration: Duration::from_millis(600),
|
2020-03-14 21:17:27 +00:00
|
|
|
}),
|
|
|
|
CharacterAbility::ChargeAttack { .. } => {
|
|
|
|
CharacterState::ChargeAttack(charge_attack::Data {
|
|
|
|
remaining_duration: Duration::from_millis(600),
|
|
|
|
})
|
2020-03-14 15:40:29 +00:00
|
|
|
},
|
2020-03-14 18:50:07 +00:00
|
|
|
CharacterAbility::TimedCombo {
|
|
|
|
buildup_duration,
|
|
|
|
recover_duration,
|
2020-03-15 13:34:17 +00:00
|
|
|
base_damage,
|
2020-03-14 21:17:27 +00:00
|
|
|
} => CharacterState::TimedCombo(timed_combo::Data {
|
2020-03-14 18:50:07 +00:00
|
|
|
buildup_duration,
|
|
|
|
recover_duration,
|
|
|
|
stage: 0,
|
2020-03-14 15:40:29 +00:00
|
|
|
stage_exhausted: false,
|
2020-03-14 18:50:07 +00:00
|
|
|
stage_time_active: Duration::default(),
|
2020-03-15 13:34:17 +00:00
|
|
|
base_damage,
|
2020-03-14 18:50:07 +00:00
|
|
|
}),
|
2020-02-03 10:54:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-14 21:33:20 +00:00
|
|
|
impl Component for Loadout {
|
2020-01-07 15:49:08 +00:00
|
|
|
type Storage = FlaggedStorage<Self, HashMapStorage<Self>>;
|
2020-01-01 17:16:29 +00:00
|
|
|
}
|