mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Update mod imports
This commit is contained in:
parent
8cdf06e3e2
commit
5527d83a0e
@ -38,20 +38,20 @@ pub struct StateUpdate {
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
||||
pub enum MoveState {
|
||||
Stand(Option<StandState>),
|
||||
Run(Option<RunState>),
|
||||
Sit(Option<SitState>),
|
||||
Jump(Option<JumpState>),
|
||||
Fall(Option<FallState>),
|
||||
Glide(Option<GlideState>),
|
||||
Swim(Option<SwimState>),
|
||||
Climb(Option<ClimbState>),
|
||||
Stand(Option<stand::State>),
|
||||
Run(Option<run::State>),
|
||||
Sit(Option<sit::State>),
|
||||
Jump(Option<jump::State>),
|
||||
Fall(Option<fall::State>),
|
||||
Glide(Option<glide::State>),
|
||||
Swim(Option<swim::State>),
|
||||
Climb(Option<climb::State>),
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
||||
pub enum ActionState {
|
||||
Idle(Option<IdleState>),
|
||||
Wield(Option<WieldState>),
|
||||
Idle(Option<idle::State>),
|
||||
Wield(Option<wield::State>),
|
||||
Attack(AttackKind),
|
||||
Block(BlockKind),
|
||||
Dodge(DodgeKind),
|
||||
@ -60,24 +60,24 @@ pub enum ActionState {
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
||||
pub enum AttackKind {
|
||||
BasicAttack(Option<BasicAttackState>),
|
||||
Charge(Option<ChargeAttackState>),
|
||||
BasicAttack(Option<basic_attack::State>),
|
||||
Charge(Option<charge_attack::State>),
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
||||
pub enum BlockKind {
|
||||
BasicBlock(Option<BasicBlockState>),
|
||||
BasicBlock(Option<basic_block::State>),
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
||||
pub enum DodgeKind {
|
||||
Roll(Option<RollState>),
|
||||
Roll(Option<roll::State>),
|
||||
}
|
||||
|
||||
impl ActionState {
|
||||
pub fn is_equip_finished(&self) -> bool {
|
||||
match self {
|
||||
Wield(Some(WieldState { equip_delay })) => *equip_delay == Duration::default(),
|
||||
Wield(Some(wield::State { equip_delay })) => *equip_delay == Duration::default(),
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
@ -85,7 +85,7 @@ impl ActionState {
|
||||
/// Returns the current `equip_delay` if in `WieldState`, otherwise `Duration::default()`
|
||||
pub fn get_delay(&self) -> Duration {
|
||||
match self {
|
||||
Wield(Some(WieldState { equip_delay })) => *equip_delay,
|
||||
Wield(Some(wield::State { equip_delay })) => *equip_delay,
|
||||
_ => Duration::default(),
|
||||
}
|
||||
}
|
||||
@ -164,8 +164,8 @@ impl CharacterState {
|
||||
impl Default for CharacterState {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
move_state: MoveState::Fall(Some(FallState)),
|
||||
action_state: ActionState::Idle(Some(IdleState)),
|
||||
move_state: MoveState::Fall(None),
|
||||
action_state: ActionState::Idle(None),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,12 +6,12 @@ use crate::util::state_utils::*;
|
||||
use std::time::Duration;
|
||||
|
||||
#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
||||
pub struct BasicAttackState {
|
||||
pub struct State {
|
||||
/// How long the state has until exitting
|
||||
pub remaining_duration: Duration,
|
||||
}
|
||||
|
||||
impl StateHandler for BasicAttackState {
|
||||
impl StateHandler for State {
|
||||
fn new(ecs_data: &EcsStateData) -> Self {
|
||||
let tool_data =
|
||||
if let Some(Tool(data)) = ecs_data.stats.equipment.main.as_ref().map(|i| i.kind) {
|
||||
@ -40,7 +40,7 @@ impl StateHandler for BasicAttackState {
|
||||
}
|
||||
|
||||
// Otherwise, tick down remaining_duration, and keep rolling
|
||||
update.character.action_state = Attack(BasicAttack(Some(BasicAttackState {
|
||||
update.character.action_state = Attack(BasicAttack(Some(State {
|
||||
remaining_duration: self
|
||||
.remaining_duration
|
||||
.checked_sub(Duration::from_secs_f32(ecs_data.dt.0))
|
||||
|
@ -7,12 +7,12 @@ const BLOCK_ACCEL: f32 = 30.0;
|
||||
const BLOCK_SPEED: f32 = 75.0;
|
||||
|
||||
#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
||||
pub struct BasicBlockState {
|
||||
pub struct State {
|
||||
/// How long the blocking state has been active
|
||||
pub active_duration: Duration,
|
||||
}
|
||||
|
||||
impl StateHandler for BasicBlockState {
|
||||
impl StateHandler for State {
|
||||
fn new(_ecs_data: &EcsStateData) -> Self {
|
||||
Self {
|
||||
active_duration: Duration::default(),
|
||||
|
@ -10,12 +10,12 @@ use vek::Vec3;
|
||||
const CHARGE_SPEED: f32 = 20.0;
|
||||
|
||||
#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
||||
pub struct ChargeAttackState {
|
||||
pub struct State {
|
||||
/// How long the state has until exitting
|
||||
pub remaining_duration: Duration,
|
||||
}
|
||||
|
||||
impl StateHandler for ChargeAttackState {
|
||||
impl StateHandler for State {
|
||||
fn new(ecs_data: &EcsStateData) -> Self {
|
||||
let tool_data =
|
||||
if let Some(Tool(data)) = ecs_data.stats.equipment.main.as_ref().map(|i| i.kind) {
|
||||
@ -76,7 +76,7 @@ impl StateHandler for ChargeAttackState {
|
||||
}
|
||||
|
||||
// Tick remaining-duration and keep charging
|
||||
update.character.action_state = Attack(Charge(Some(ChargeAttackState {
|
||||
update.character.action_state = Attack(Charge(Some(State {
|
||||
remaining_duration: self
|
||||
.remaining_duration
|
||||
.checked_sub(Duration::from_secs_f32(ecs_data.dt.0))
|
||||
|
@ -7,9 +7,9 @@ const HUMANOID_CLIMB_ACCEL: f32 = 5.0;
|
||||
const CLIMB_SPEED: f32 = 5.0;
|
||||
|
||||
#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
||||
pub struct ClimbState;
|
||||
pub struct State;
|
||||
|
||||
impl StateHandler for ClimbState {
|
||||
impl StateHandler for State {
|
||||
fn new(_ecs_data: &EcsStateData) -> Self {
|
||||
Self {}
|
||||
}
|
||||
|
@ -7,9 +7,9 @@ const HUMANOID_AIR_ACCEL: f32 = 10.0;
|
||||
const HUMANOID_AIR_SPEED: f32 = 100.0;
|
||||
|
||||
#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
||||
pub struct FallState;
|
||||
pub struct State;
|
||||
|
||||
impl StateHandler for FallState {
|
||||
impl StateHandler for State {
|
||||
fn new(_ecs_data: &EcsStateData) -> Self {
|
||||
Self {}
|
||||
}
|
||||
|
@ -7,9 +7,9 @@ const GLIDE_ACCEL: f32 = 15.0;
|
||||
const GLIDE_SPEED: f32 = 45.0;
|
||||
|
||||
#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
||||
pub struct GlideState;
|
||||
pub struct State;
|
||||
|
||||
impl StateHandler for GlideState {
|
||||
impl StateHandler for State {
|
||||
fn new(_ecs_data: &EcsStateData) -> Self {
|
||||
Self {}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
use crate::comp::{ActionState::Wield, EcsStateData, ItemKind::Tool, StateHandler, StateUpdate};
|
||||
|
||||
#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
||||
pub struct IdleState;
|
||||
pub struct State;
|
||||
|
||||
impl StateHandler for IdleState {
|
||||
impl StateHandler for State {
|
||||
fn new(_ecs_data: &EcsStateData) -> Self {
|
||||
Self {}
|
||||
}
|
||||
|
@ -2,9 +2,9 @@ use super::{EcsStateData, MoveState::*, StateHandler, StateUpdate};
|
||||
use crate::event::LocalEvent;
|
||||
|
||||
#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
||||
pub struct JumpState;
|
||||
pub struct State;
|
||||
|
||||
impl StateHandler for JumpState {
|
||||
impl StateHandler for State {
|
||||
fn new(_ecs_data: &EcsStateData) -> Self {
|
||||
Self {}
|
||||
}
|
||||
|
@ -1,34 +1,18 @@
|
||||
// Module declarations
|
||||
mod basic_attack;
|
||||
mod basic_block;
|
||||
mod charge_attack;
|
||||
mod climb;
|
||||
mod fall;
|
||||
mod glide;
|
||||
mod idle;
|
||||
mod jump;
|
||||
mod roll;
|
||||
mod run;
|
||||
mod sit;
|
||||
mod stand;
|
||||
mod swim;
|
||||
mod wield;
|
||||
|
||||
// Reexports
|
||||
pub use basic_attack::*;
|
||||
pub use basic_block::*;
|
||||
pub use charge_attack::*;
|
||||
pub use climb::*;
|
||||
pub use fall::*;
|
||||
pub use glide::*;
|
||||
pub use idle::*;
|
||||
pub use jump::*;
|
||||
pub use roll::*;
|
||||
pub use run::*;
|
||||
pub use sit::*;
|
||||
pub use stand::*;
|
||||
pub use swim::*;
|
||||
pub use wield::*;
|
||||
pub mod basic_attack;
|
||||
pub mod basic_block;
|
||||
pub mod charge_attack;
|
||||
pub mod climb;
|
||||
pub mod fall;
|
||||
pub mod glide;
|
||||
pub mod idle;
|
||||
pub mod jump;
|
||||
pub mod roll;
|
||||
pub mod run;
|
||||
pub mod sit;
|
||||
pub mod stand;
|
||||
pub mod swim;
|
||||
pub mod wield;
|
||||
|
||||
use super::{
|
||||
ActionState, ActionState::*, AttackKind::*, BlockKind::*, DodgeKind::*, EcsStateData,
|
||||
@ -112,28 +96,28 @@ impl ActionState {
|
||||
Attack(kind) => match kind {
|
||||
BasicAttack(opt_state) => opt_state
|
||||
// If data hasn't been initialized, initialize a new one
|
||||
.unwrap_or_else(|| BasicAttackState::new(ecs_data))
|
||||
.unwrap_or_else(|| basic_attack::State::new(ecs_data))
|
||||
// Call handler
|
||||
.handle(ecs_data),
|
||||
Charge(opt_state) => opt_state
|
||||
.unwrap_or_else(|| ChargeAttackState::new(ecs_data))
|
||||
.unwrap_or_else(|| charge_attack::State::new(ecs_data))
|
||||
.handle(ecs_data),
|
||||
},
|
||||
Block(kind) => match kind {
|
||||
BasicBlock(opt_state) => opt_state
|
||||
.unwrap_or_else(|| BasicBlockState::new(ecs_data))
|
||||
.unwrap_or_else(|| basic_block::State::new(ecs_data))
|
||||
.handle(ecs_data),
|
||||
},
|
||||
Dodge(kind) => match kind {
|
||||
Roll(opt_state) => opt_state
|
||||
.unwrap_or_else(|| RollState::new(ecs_data))
|
||||
.unwrap_or_else(|| roll::State::new(ecs_data))
|
||||
.handle(ecs_data),
|
||||
},
|
||||
Wield(opt_state) => opt_state
|
||||
.unwrap_or_else(|| WieldState::new(ecs_data))
|
||||
.unwrap_or_else(|| wield::State::new(ecs_data))
|
||||
.handle(ecs_data),
|
||||
Idle(opt_state) => opt_state
|
||||
.unwrap_or_else(|| IdleState::new(ecs_data))
|
||||
.unwrap_or_else(|| idle::State::new(ecs_data))
|
||||
.handle(ecs_data),
|
||||
// All states should be explicitly handled
|
||||
// Do not use default match: _ => {},
|
||||
@ -188,29 +172,29 @@ impl MoveState {
|
||||
match self {
|
||||
Stand(opt_state) => opt_state
|
||||
// If data hasn't been initialized, initialize a new one
|
||||
.unwrap_or_else(|| StandState::new(ecs_data))
|
||||
.unwrap_or_else(|| stand::State::new(ecs_data))
|
||||
// Call handler
|
||||
.handle(ecs_data),
|
||||
Run(opt_state) => opt_state
|
||||
.unwrap_or_else(|| RunState::new(ecs_data))
|
||||
.unwrap_or_else(|| run::State::new(ecs_data))
|
||||
.handle(ecs_data),
|
||||
Jump(opt_state) => opt_state
|
||||
.unwrap_or_else(|| JumpState::new(ecs_data))
|
||||
.unwrap_or_else(|| jump::State::new(ecs_data))
|
||||
.handle(ecs_data),
|
||||
Climb(opt_state) => opt_state
|
||||
.unwrap_or_else(|| ClimbState::new(ecs_data))
|
||||
.unwrap_or_else(|| climb::State::new(ecs_data))
|
||||
.handle(ecs_data),
|
||||
Glide(opt_state) => opt_state
|
||||
.unwrap_or_else(|| GlideState::new(ecs_data))
|
||||
.unwrap_or_else(|| glide::State::new(ecs_data))
|
||||
.handle(ecs_data),
|
||||
Swim(opt_state) => opt_state
|
||||
.unwrap_or_else(|| SwimState::new(ecs_data))
|
||||
.unwrap_or_else(|| swim::State::new(ecs_data))
|
||||
.handle(ecs_data),
|
||||
Fall(opt_state) => opt_state
|
||||
.unwrap_or_else(|| FallState::new(ecs_data))
|
||||
.unwrap_or_else(|| fall::State::new(ecs_data))
|
||||
.handle(ecs_data),
|
||||
Sit(opt_state) => opt_state
|
||||
.unwrap_or_else(|| SitState::new(ecs_data))
|
||||
.unwrap_or_else(|| sit::State::new(ecs_data))
|
||||
.handle(ecs_data),
|
||||
// All states should be explicitly handled
|
||||
// Do not use default match: _ => {},
|
||||
|
@ -8,12 +8,12 @@ use vek::Vec3;
|
||||
const ROLL_SPEED: f32 = 17.0;
|
||||
|
||||
#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
||||
pub struct RollState {
|
||||
pub struct State {
|
||||
/// How long the state has until exitting
|
||||
remaining_duration: Duration,
|
||||
}
|
||||
|
||||
impl StateHandler for RollState {
|
||||
impl StateHandler for State {
|
||||
fn new(ecs_data: &EcsStateData) -> Self {
|
||||
let tool_data =
|
||||
if let Some(Tool(data)) = ecs_data.stats.equipment.main.as_ref().map(|i| i.kind) {
|
||||
@ -55,7 +55,7 @@ impl StateHandler for RollState {
|
||||
}
|
||||
|
||||
// Otherwise, tick down remaining_duration
|
||||
update.character.action_state = Dodge(Roll(Some(RollState {
|
||||
update.character.action_state = Dodge(Roll(Some(State {
|
||||
remaining_duration: self
|
||||
.remaining_duration
|
||||
.checked_sub(Duration::from_secs_f32(ecs_data.dt.0))
|
||||
|
@ -6,9 +6,9 @@ const HUMANOID_ACCEL: f32 = 50.0;
|
||||
const HUMANOID_SPEED: f32 = 120.0;
|
||||
|
||||
#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
||||
pub struct RunState;
|
||||
pub struct State;
|
||||
|
||||
impl StateHandler for RunState {
|
||||
impl StateHandler for State {
|
||||
fn new(_ecs_data: &EcsStateData) -> Self {
|
||||
Self {}
|
||||
}
|
||||
|
@ -2,9 +2,9 @@ use crate::comp::{ActionState::*, EcsStateData, MoveState::*, StateHandler, Stat
|
||||
use crate::util::state_utils::*;
|
||||
|
||||
#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
||||
pub struct SitState;
|
||||
pub struct State;
|
||||
|
||||
impl StateHandler for SitState {
|
||||
impl StateHandler for State {
|
||||
fn new(_ecs_data: &EcsStateData) -> Self {
|
||||
Self {}
|
||||
}
|
||||
|
@ -2,9 +2,9 @@ use crate::comp::{EcsStateData, MoveState::*, StateHandler, StateUpdate};
|
||||
use crate::util::state_utils::*;
|
||||
|
||||
#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
||||
pub struct StandState;
|
||||
pub struct State;
|
||||
|
||||
impl StateHandler for StandState {
|
||||
impl StateHandler for State {
|
||||
fn new(_ecs_data: &EcsStateData) -> Self {
|
||||
Self {}
|
||||
}
|
||||
|
@ -4,12 +4,12 @@ use std::time::Duration;
|
||||
use vek::{Vec2, Vec3};
|
||||
|
||||
#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
||||
pub struct SwimState;
|
||||
pub struct State;
|
||||
|
||||
const HUMANOID_WATER_ACCEL: f32 = 70.0;
|
||||
const HUMANOID_WATER_SPEED: f32 = 120.0;
|
||||
|
||||
impl StateHandler for SwimState {
|
||||
impl StateHandler for State {
|
||||
fn new(_ecs_data: &EcsStateData) -> Self {
|
||||
Self {}
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
use crate::comp::{
|
||||
ActionState::*, EcsStateData, IdleState, ItemKind::Tool, StateHandler, StateUpdate, ToolData,
|
||||
ActionState::*, EcsStateData, ItemKind::Tool, StateHandler, StateUpdate, ToolData,
|
||||
};
|
||||
use std::time::Duration;
|
||||
|
||||
#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
||||
pub struct WieldState {
|
||||
pub struct State {
|
||||
/// How long before a new action can be performed
|
||||
/// after equipping
|
||||
pub equip_delay: Duration,
|
||||
}
|
||||
|
||||
impl StateHandler for WieldState {
|
||||
impl StateHandler for State {
|
||||
fn new(ecs_data: &EcsStateData) -> Self {
|
||||
let tool_data =
|
||||
if let Some(Tool(data)) = ecs_data.stats.equipment.main.as_ref().map(|i| i.kind) {
|
||||
@ -37,7 +37,7 @@ impl StateHandler for WieldState {
|
||||
if ecs_data.inputs.toggle_wield.is_just_pressed()
|
||||
&& ecs_data.character.action_state.is_equip_finished()
|
||||
{
|
||||
update.character.action_state = Idle(Some(IdleState));
|
||||
update.character.action_state = Idle(None);
|
||||
return update;
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ impl StateHandler for WieldState {
|
||||
} else {
|
||||
// Equip delay hasn't expired yet
|
||||
// Update wield delay
|
||||
update.character.action_state = Wield(Some(WieldState {
|
||||
update.character.action_state = Wield(Some(State {
|
||||
equip_delay: self
|
||||
.equip_delay
|
||||
.checked_sub(Duration::from_secs_f32(ecs_data.dt.0))
|
||||
|
@ -1,6 +1,5 @@
|
||||
use crate::comp::{
|
||||
Agent, CharacterState, Controller, ControllerInputs, GlideState, MountState, MoveState::Glide,
|
||||
Pos, Stats,
|
||||
Agent, CharacterState, Controller, ControllerInputs, MountState, MoveState::Glide, Pos, Stats,
|
||||
};
|
||||
use crate::pathfinding::WorldPath;
|
||||
use crate::terrain::TerrainGrid;
|
||||
@ -163,7 +162,7 @@ impl<'a> System<'a> for Sys {
|
||||
inputs.roll.set_state(true);
|
||||
}
|
||||
|
||||
if target_character.move_state == Glide(Some(GlideState))
|
||||
if target_character.move_state == Glide(None)
|
||||
&& target_pos.0.z > pos.0.z + 5.0
|
||||
{
|
||||
inputs.glide.set_state(true);
|
||||
|
Loading…
Reference in New Issue
Block a user