From 1816d4b8052818d7d7c9c865a0e30ad0296a32ba Mon Sep 17 00:00:00 2001 From: AdamWhitehurst Date: Sun, 12 Jan 2020 15:06:52 -0800 Subject: [PATCH] Move states/ to common/src/ --- common/src/comp/character_state.rs | 2 +- common/src/comp/mod.rs | 2 -- common/src/lib.rs | 1 + common/src/{comp => }/states/basic_attack.rs | 6 ++++-- common/src/{comp => }/states/basic_block.rs | 3 ++- common/src/{comp => }/states/charge_attack.rs | 3 ++- common/src/{comp => }/states/climb.rs | 0 common/src/{comp => }/states/fall.rs | 3 ++- common/src/{comp => }/states/glide.rs | 3 ++- common/src/{comp => }/states/idle.rs | 3 ++- common/src/{comp => }/states/jump.rs | 0 common/src/{comp => }/states/mod.rs | 2 +- common/src/{comp => }/states/roll.rs | 4 ++-- common/src/{comp => }/states/run.rs | 3 ++- common/src/{comp => }/states/sit.rs | 3 ++- common/src/{comp => }/states/stand.rs | 3 ++- common/src/{comp => }/states/swim.rs | 3 ++- common/src/{comp => }/states/utils.rs | 0 common/src/{comp => }/states/wield.rs | 3 ++- common/src/sys/ability.rs | 2 +- 20 files changed, 30 insertions(+), 19 deletions(-) rename common/src/{comp => }/states/basic_attack.rs (95%) rename common/src/{comp => }/states/basic_block.rs (94%) rename common/src/{comp => }/states/charge_attack.rs (96%) rename common/src/{comp => }/states/climb.rs (100%) rename common/src/{comp => }/states/fall.rs (95%) rename common/src/{comp => }/states/glide.rs (96%) rename common/src/{comp => }/states/idle.rs (95%) rename common/src/{comp => }/states/jump.rs (100%) rename common/src/{comp => }/states/mod.rs (99%) rename common/src/{comp => }/states/roll.rs (97%) rename common/src/{comp => }/states/run.rs (96%) rename common/src/{comp => }/states/sit.rs (93%) rename common/src/{comp => }/states/stand.rs (94%) rename common/src/{comp => }/states/swim.rs (96%) rename common/src/{comp => }/states/utils.rs (100%) rename common/src/{comp => }/states/wield.rs (97%) diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 1c0091decd..9f4c342139 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -1,5 +1,5 @@ use self::ActionState::*; -use super::states::*; +use crate::states::*; use crate::{ comp::{Body, ControllerInputs, Ori, PhysicsState, Pos, Stats, Vel}, event::{EventBus, LocalEvent, ServerEvent}, diff --git a/common/src/comp/mod.rs b/common/src/comp/mod.rs index 26a02bdef6..32f61832b5 100644 --- a/common/src/comp/mod.rs +++ b/common/src/comp/mod.rs @@ -11,7 +11,6 @@ mod location; mod phys; mod player; pub mod projectile; -pub mod states; mod stats; mod visual; @@ -40,6 +39,5 @@ pub use location::Waypoint; pub use phys::{ForceUpdate, Gravity, Mass, Ori, PhysicsState, Pos, Scale, Sticky, Vel}; pub use player::Player; pub use projectile::Projectile; -pub use states::*; pub use stats::{Equipment, Exp, HealthChange, HealthSource, Level, Stats}; pub use visual::LightEmitter; diff --git a/common/src/lib.rs b/common/src/lib.rs index eab693848d..230448ef3c 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -20,6 +20,7 @@ pub mod pathfinding; pub mod ray; pub mod region; pub mod state; +pub mod states; pub mod sys; pub mod terrain; pub mod util; diff --git a/common/src/comp/states/basic_attack.rs b/common/src/states/basic_attack.rs similarity index 95% rename from common/src/comp/states/basic_attack.rs rename to common/src/states/basic_attack.rs index eae687b2ad..7ff7f1f4be 100644 --- a/common/src/comp/states/basic_attack.rs +++ b/common/src/states/basic_attack.rs @@ -1,8 +1,10 @@ use super::utils::*; use crate::comp::{ - ActionState::Attack, AttackKind::BasicAttack, EcsStateData, ItemKind::Tool, StateHandler, - StateUpdate, ToolData, + ActionState::Attack, AttackKind::BasicAttack, EcsStateData, ItemKind::Tool, StateUpdate, + ToolData, }; +use crate::states::StateHandler; + use std::time::Duration; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] diff --git a/common/src/comp/states/basic_block.rs b/common/src/states/basic_block.rs similarity index 94% rename from common/src/comp/states/basic_block.rs rename to common/src/states/basic_block.rs index 0c395a005e..a71e0cb078 100644 --- a/common/src/comp/states/basic_block.rs +++ b/common/src/states/basic_block.rs @@ -1,5 +1,6 @@ use super::utils::*; -use crate::comp::{EcsStateData, StateHandler, StateUpdate}; +use crate::comp::{EcsStateData, StateUpdate}; +use crate::states::StateHandler; use std::time::Duration; use vek::Vec2; diff --git a/common/src/comp/states/charge_attack.rs b/common/src/states/charge_attack.rs similarity index 96% rename from common/src/comp/states/charge_attack.rs rename to common/src/states/charge_attack.rs index e437709f4f..bbe20d082d 100644 --- a/common/src/comp/states/charge_attack.rs +++ b/common/src/states/charge_attack.rs @@ -1,9 +1,10 @@ use super::utils::*; use crate::comp::{ ActionState::Attack, AttackKind::Charge, EcsStateData, HealthChange, HealthSource, - ItemKind::Tool, MoveState::Run, StateHandler, StateUpdate, ToolData, + ItemKind::Tool, MoveState::Run, StateUpdate, ToolData, }; use crate::event::ServerEvent; +use crate::states::StateHandler; use std::time::Duration; use vek::Vec3; diff --git a/common/src/comp/states/climb.rs b/common/src/states/climb.rs similarity index 100% rename from common/src/comp/states/climb.rs rename to common/src/states/climb.rs diff --git a/common/src/comp/states/fall.rs b/common/src/states/fall.rs similarity index 95% rename from common/src/comp/states/fall.rs rename to common/src/states/fall.rs index debabb5585..35f3870823 100644 --- a/common/src/comp/states/fall.rs +++ b/common/src/states/fall.rs @@ -1,6 +1,7 @@ -use crate::comp::{ActionState, EcsStateData, MoveState, StateHandler, StateUpdate}; +use crate::comp::{ActionState, EcsStateData, MoveState, StateUpdate}; use super::utils::*; +use crate::states::StateHandler; use vek::{Vec2, Vec3}; const HUMANOID_AIR_ACCEL: f32 = 10.0; diff --git a/common/src/comp/states/glide.rs b/common/src/states/glide.rs similarity index 96% rename from common/src/comp/states/glide.rs rename to common/src/states/glide.rs index f436fddca4..8058ddaa8c 100644 --- a/common/src/comp/states/glide.rs +++ b/common/src/states/glide.rs @@ -1,4 +1,5 @@ -use crate::comp::{ActionState, EcsStateData, MoveState, StateHandler, StateUpdate}; +use crate::comp::{ActionState, EcsStateData, MoveState, StateUpdate}; +use crate::states::StateHandler; use vek::{Vec2, Vec3}; // Gravity is 9.81 * 4, so this makes gravity equal to .15 diff --git a/common/src/comp/states/idle.rs b/common/src/states/idle.rs similarity index 95% rename from common/src/comp/states/idle.rs rename to common/src/states/idle.rs index 46af0a47fb..b64795c67e 100644 --- a/common/src/comp/states/idle.rs +++ b/common/src/states/idle.rs @@ -1,5 +1,6 @@ -use crate::comp::{ActionState, EcsStateData, ItemKind::Tool, StateHandler, StateUpdate}; +use crate::comp::{ActionState, EcsStateData, ItemKind::Tool, StateUpdate}; +use crate::states::StateHandler; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct State; diff --git a/common/src/comp/states/jump.rs b/common/src/states/jump.rs similarity index 100% rename from common/src/comp/states/jump.rs rename to common/src/states/jump.rs diff --git a/common/src/comp/states/mod.rs b/common/src/states/mod.rs similarity index 99% rename from common/src/comp/states/mod.rs rename to common/src/states/mod.rs index 35dc2cca21..78d650f9b3 100644 --- a/common/src/comp/states/mod.rs +++ b/common/src/states/mod.rs @@ -15,7 +15,7 @@ pub mod swim; pub mod utils; pub mod wield; -use super::{ +use crate::comp::{ ActionState, ActionState::*, AttackKind::*, BlockKind::*, DodgeKind::*, EcsStateData, MoveState, MoveState::*, StateUpdate, }; diff --git a/common/src/comp/states/roll.rs b/common/src/states/roll.rs similarity index 97% rename from common/src/comp/states/roll.rs rename to common/src/states/roll.rs index e081b0b98e..1600e009d1 100644 --- a/common/src/comp/states/roll.rs +++ b/common/src/states/roll.rs @@ -1,8 +1,8 @@ use super::utils::*; use crate::comp::{ - ActionState::Dodge, DodgeKind::Roll, EcsStateData, ItemKind::Tool, StateHandler, StateUpdate, - ToolData, + ActionState::Dodge, DodgeKind::Roll, EcsStateData, ItemKind::Tool, StateUpdate, ToolData, }; +use crate::states::StateHandler; use std::time::Duration; use vek::Vec3; diff --git a/common/src/comp/states/run.rs b/common/src/states/run.rs similarity index 96% rename from common/src/comp/states/run.rs rename to common/src/states/run.rs index e863ea8c80..5b2f880738 100644 --- a/common/src/comp/states/run.rs +++ b/common/src/states/run.rs @@ -1,5 +1,6 @@ use super::utils::*; -use crate::comp::{ActionState, EcsStateData, MoveState, StateHandler, StateUpdate}; +use crate::comp::{ActionState, EcsStateData, MoveState, StateUpdate}; +use crate::states::StateHandler; use vek::vec::{Vec2, Vec3}; const HUMANOID_ACCEL: f32 = 50.0; diff --git a/common/src/comp/states/sit.rs b/common/src/states/sit.rs similarity index 93% rename from common/src/comp/states/sit.rs rename to common/src/states/sit.rs index 24a2b11f48..e92f35a2e0 100644 --- a/common/src/comp/states/sit.rs +++ b/common/src/states/sit.rs @@ -1,5 +1,6 @@ use super::utils::*; -use crate::comp::{ActionState, EcsStateData, MoveState, StateHandler, StateUpdate}; +use crate::comp::{ActionState, EcsStateData, MoveState, StateUpdate}; +use crate::states::StateHandler; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct State; diff --git a/common/src/comp/states/stand.rs b/common/src/states/stand.rs similarity index 94% rename from common/src/comp/states/stand.rs rename to common/src/states/stand.rs index fd0dce5bb3..e772c560d0 100644 --- a/common/src/comp/states/stand.rs +++ b/common/src/states/stand.rs @@ -1,5 +1,6 @@ use super::utils::*; -use crate::comp::{EcsStateData, MoveState, StateHandler, StateUpdate}; +use crate::comp::{EcsStateData, MoveState, StateUpdate}; +use crate::states::StateHandler; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] pub struct State; diff --git a/common/src/comp/states/swim.rs b/common/src/states/swim.rs similarity index 96% rename from common/src/comp/states/swim.rs rename to common/src/states/swim.rs index 1b48b0f02f..16b0e1406b 100644 --- a/common/src/comp/states/swim.rs +++ b/common/src/states/swim.rs @@ -1,4 +1,5 @@ -use crate::comp::{ActionState, EcsStateData, MoveState, StateHandler, StateUpdate}; +use crate::comp::{ActionState, EcsStateData, MoveState, StateUpdate}; +use crate::states::StateHandler; use crate::sys::phys::GRAVITY; use std::time::Duration; use vek::{Vec2, Vec3}; diff --git a/common/src/comp/states/utils.rs b/common/src/states/utils.rs similarity index 100% rename from common/src/comp/states/utils.rs rename to common/src/states/utils.rs diff --git a/common/src/comp/states/wield.rs b/common/src/states/wield.rs similarity index 97% rename from common/src/comp/states/wield.rs rename to common/src/states/wield.rs index 651736c8f9..7d91706b3f 100644 --- a/common/src/comp/states/wield.rs +++ b/common/src/states/wield.rs @@ -1,4 +1,5 @@ -use crate::comp::{ActionState, EcsStateData, ItemKind::Tool, StateHandler, StateUpdate, ToolData}; +use crate::comp::{ActionState, EcsStateData, ItemKind::Tool, StateUpdate, ToolData}; +use crate::states::StateHandler; use std::time::Duration; #[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] diff --git a/common/src/sys/ability.rs b/common/src/sys/ability.rs index 99b173c89d..f4569f0b0b 100644 --- a/common/src/sys/ability.rs +++ b/common/src/sys/ability.rs @@ -2,8 +2,8 @@ #![allow(dead_code)] use crate::comp::{ AbilityAction, AbilityActionKind, AbilityPool, ActionState::*, AttackKind, CharacterState, - StateHandler, }; +use crate::states::StateHandler; use specs::{Entities, Join, LazyUpdate, Read, ReadStorage, System, WriteStorage};