mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'xMAC94x/common_seperation_1' into 'master'
Move Systems out of common into `common_sys` See merge request veloren/veloren!1583
This commit is contained in:
commit
6da55b8f2e
20
Cargo.lock
generated
20
Cargo.lock
generated
@ -5341,6 +5341,7 @@ dependencies = [
|
||||
"uvth 3.1.1",
|
||||
"vek 0.12.0",
|
||||
"veloren-common",
|
||||
"veloren_common_sys",
|
||||
"veloren_network",
|
||||
]
|
||||
|
||||
@ -5415,6 +5416,7 @@ dependencies = [
|
||||
"vek 0.12.0",
|
||||
"veloren-common",
|
||||
"veloren-world",
|
||||
"veloren_common_sys",
|
||||
"veloren_network",
|
||||
]
|
||||
|
||||
@ -5496,6 +5498,7 @@ dependencies = [
|
||||
"veloren-server",
|
||||
"veloren-voxygen-anim",
|
||||
"veloren-world",
|
||||
"veloren_common_sys",
|
||||
"window_clipboard",
|
||||
"winit",
|
||||
"winres",
|
||||
@ -5544,6 +5547,23 @@ dependencies = [
|
||||
"veloren-common",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "veloren_common_sys"
|
||||
version = "0.8.0"
|
||||
dependencies = [
|
||||
"hashbrown 0.7.2",
|
||||
"indexmap",
|
||||
"rand 0.7.3",
|
||||
"rayon",
|
||||
"serde",
|
||||
"slab",
|
||||
"specs",
|
||||
"tracing",
|
||||
"tracy-client",
|
||||
"vek 0.12.0",
|
||||
"veloren-common",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "veloren_network"
|
||||
version = "0.2.0"
|
||||
|
@ -3,6 +3,7 @@ cargo-features = ["named-profiles","profile-overrides"]
|
||||
[workspace]
|
||||
members = [
|
||||
"common",
|
||||
"common/sys",
|
||||
"client",
|
||||
"chat-cli",
|
||||
"server",
|
||||
|
@ -11,6 +11,7 @@ default = ["simd"]
|
||||
|
||||
[dependencies]
|
||||
common = { package = "veloren-common", path = "../common", features = ["no-assets"] }
|
||||
common_sys = { package = "veloren_common_sys", path = "../common/sys", default-features = false }
|
||||
network = { package = "veloren_network", path = "../network", features = ["compression"], default-features = false }
|
||||
|
||||
byteorder = "1.3.2"
|
||||
|
@ -33,11 +33,11 @@ use common::{
|
||||
outcome::Outcome,
|
||||
recipe::RecipeBook,
|
||||
span,
|
||||
state::State,
|
||||
sync::{Uid, UidAllocator, WorldSyncExt},
|
||||
terrain::{block::Block, neighbors, BiomeKind, SitesKind, TerrainChunk, TerrainChunkSize},
|
||||
vol::RectVolSize,
|
||||
};
|
||||
use common_sys::state::State;
|
||||
use comp::BuffKind;
|
||||
use futures_executor::block_on;
|
||||
use futures_timer::Delay;
|
||||
|
@ -6,10 +6,10 @@ use crate::{
|
||||
Body, CharacterState, EnergySource, Gravity, LightEmitter, StateUpdate,
|
||||
},
|
||||
states::{
|
||||
behavior::JoinData,
|
||||
utils::{AbilityKey, StageSection},
|
||||
*,
|
||||
},
|
||||
sys::character_behavior::JoinData,
|
||||
Knockback,
|
||||
};
|
||||
use arraygen::Arraygen;
|
||||
|
@ -1,8 +1,7 @@
|
||||
use crate::{
|
||||
comp::{Energy, Ori, Pos, Vel},
|
||||
event::{LocalEvent, ServerEvent},
|
||||
states::*,
|
||||
sys::character_behavior::JoinData,
|
||||
states::{behavior::JoinData, *},
|
||||
Damage, GroupTarget, Knockback,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::state::Time;
|
||||
use crate::resources::Time;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use specs::{Component, FlaggedStorage};
|
||||
use specs_idvs::IdvStorage;
|
||||
|
@ -1,3 +1,6 @@
|
||||
// The limit on distance between the entity and a collectible (squared)
|
||||
pub const MAX_PICKUP_RANGE: f32 = 8.0;
|
||||
pub const MAX_MOUNT_RANGE: f32 = 14.0;
|
||||
|
||||
pub const GRAVITY: f32 = 9.81 * 5.0;
|
||||
pub const FRIC_GROUND: f32 = 0.15;
|
||||
|
@ -40,13 +40,12 @@ pub mod path;
|
||||
pub mod ray;
|
||||
pub mod recipe;
|
||||
pub mod region;
|
||||
pub mod resources;
|
||||
pub mod rtsim;
|
||||
pub mod spiral;
|
||||
pub mod state;
|
||||
pub mod states;
|
||||
pub mod store;
|
||||
pub mod sync;
|
||||
pub mod sys;
|
||||
pub mod terrain;
|
||||
pub mod time;
|
||||
pub mod typed;
|
||||
|
@ -4,7 +4,8 @@ use crate::{
|
||||
comp,
|
||||
outcome::Outcome,
|
||||
recipe::RecipeBook,
|
||||
state, sync,
|
||||
resources::TimeOfDay,
|
||||
sync,
|
||||
sync::Uid,
|
||||
terrain::{Block, TerrainChunk},
|
||||
};
|
||||
@ -49,7 +50,7 @@ pub enum ServerInit {
|
||||
TooManyPlayers,
|
||||
GameSync {
|
||||
entity_package: sync::EntityPackage<EcsCompPacket>,
|
||||
time_of_day: state::TimeOfDay,
|
||||
time_of_day: TimeOfDay,
|
||||
max_group_size: u32,
|
||||
client_timeout: Duration,
|
||||
world_map: crate::msg::world_msg::WorldMapMsg,
|
||||
@ -110,7 +111,7 @@ pub enum ServerGeneral {
|
||||
/// formatting the message and turning it into a speech bubble.
|
||||
ChatMsg(comp::ChatMsg),
|
||||
SetPlayerEntity(Uid),
|
||||
TimeOfDay(state::TimeOfDay),
|
||||
TimeOfDay(TimeOfDay),
|
||||
EntitySync(sync::EntitySyncPackage),
|
||||
CompSync(sync::CompSyncPackage<EcsCompPacket>),
|
||||
CreateEntity(sync::EntityPackage<EcsCompPacket>),
|
||||
|
13
common/src/resources.rs
Normal file
13
common/src/resources.rs
Normal file
@ -0,0 +1,13 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// A resource that stores the time of day.
|
||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize, Default)]
|
||||
pub struct TimeOfDay(pub f64);
|
||||
|
||||
/// A resource that stores the tick (i.e: physics) time.
|
||||
#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize)]
|
||||
pub struct Time(pub f64);
|
||||
|
||||
/// A resource that stores the time since the previous tick.
|
||||
#[derive(Default)]
|
||||
pub struct DeltaTime(pub f32);
|
@ -1,9 +1,11 @@
|
||||
use crate::{
|
||||
comp::{beam, Body, CharacterState, EnergyChange, EnergySource, Ori, Pos, StateUpdate},
|
||||
event::ServerEvent,
|
||||
states::utils::*,
|
||||
states::{
|
||||
behavior::{CharacterBehavior, JoinData},
|
||||
utils::*,
|
||||
},
|
||||
sync::Uid,
|
||||
sys::character_behavior::{CharacterBehavior, JoinData},
|
||||
Damage, DamageSource, GroupTarget,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -1,7 +1,7 @@
|
||||
use super::utils::*;
|
||||
use crate::{
|
||||
comp::StateUpdate,
|
||||
sys::character_behavior::{CharacterBehavior, JoinData},
|
||||
states::behavior::{CharacterBehavior, JoinData},
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
use crate::{
|
||||
comp::{Attacking, CharacterState, EnergyChange, EnergySource, StateUpdate},
|
||||
states::utils::*,
|
||||
sys::character_behavior::{CharacterBehavior, JoinData},
|
||||
states::{
|
||||
behavior::{CharacterBehavior, JoinData},
|
||||
utils::*,
|
||||
},
|
||||
Damage, DamageSource, GroupTarget, Knockback,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -1,8 +1,10 @@
|
||||
use crate::{
|
||||
comp::{Body, CharacterState, Gravity, LightEmitter, ProjectileConstructor, StateUpdate},
|
||||
event::ServerEvent,
|
||||
states::utils::*,
|
||||
sys::character_behavior::{CharacterBehavior, JoinData},
|
||||
states::{
|
||||
behavior::{CharacterBehavior, JoinData},
|
||||
utils::*,
|
||||
},
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::time::Duration;
|
||||
|
109
common/src/states/behavior.rs
Normal file
109
common/src/states/behavior.rs
Normal file
@ -0,0 +1,109 @@
|
||||
use crate::{
|
||||
comp::{
|
||||
Attacking, Beam, Body, CharacterState, ControlAction, Controller, ControllerInputs, Energy,
|
||||
Health, Loadout, Ori, PhysicsState, Pos, StateUpdate, Vel,
|
||||
},
|
||||
resources::DeltaTime,
|
||||
sync::Uid,
|
||||
};
|
||||
use specs::{
|
||||
hibitset,
|
||||
storage::{PairedStorage, SequentialRestriction},
|
||||
Entity, FlaggedStorage, LazyUpdate,
|
||||
};
|
||||
use specs_idvs::IdvStorage;
|
||||
|
||||
pub trait CharacterBehavior {
|
||||
fn behavior(&self, data: &JoinData) -> StateUpdate;
|
||||
// Impl these to provide behavior for these inputs
|
||||
fn swap_loadout(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) }
|
||||
fn wield(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) }
|
||||
fn glide_wield(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) }
|
||||
fn unwield(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) }
|
||||
fn sit(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) }
|
||||
fn dance(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) }
|
||||
fn sneak(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) }
|
||||
fn stand(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) }
|
||||
fn handle_event(&self, data: &JoinData, event: ControlAction) -> StateUpdate {
|
||||
match event {
|
||||
ControlAction::SwapLoadout => self.swap_loadout(data),
|
||||
ControlAction::Wield => self.wield(data),
|
||||
ControlAction::GlideWield => self.glide_wield(data),
|
||||
ControlAction::Unwield => self.unwield(data),
|
||||
ControlAction::Sit => self.sit(data),
|
||||
ControlAction::Dance => self.dance(data),
|
||||
ControlAction::Sneak => self.sneak(data),
|
||||
ControlAction::Stand => self.stand(data),
|
||||
}
|
||||
}
|
||||
// fn init(data: &JoinData) -> CharacterState;
|
||||
}
|
||||
|
||||
/// Read-Only Data sent from Character Behavior System to behavior fn's
|
||||
pub struct JoinData<'a> {
|
||||
pub entity: Entity,
|
||||
pub uid: &'a Uid,
|
||||
pub character: &'a CharacterState,
|
||||
pub pos: &'a Pos,
|
||||
pub vel: &'a Vel,
|
||||
pub ori: &'a Ori,
|
||||
pub dt: &'a DeltaTime,
|
||||
pub controller: &'a Controller,
|
||||
pub inputs: &'a ControllerInputs,
|
||||
pub health: &'a Health,
|
||||
pub energy: &'a Energy,
|
||||
pub loadout: &'a Loadout,
|
||||
pub body: &'a Body,
|
||||
pub physics: &'a PhysicsState,
|
||||
pub attacking: Option<&'a Attacking>,
|
||||
pub updater: &'a LazyUpdate,
|
||||
}
|
||||
|
||||
type RestrictedMut<'a, C> = PairedStorage<
|
||||
'a,
|
||||
'a,
|
||||
C,
|
||||
&'a mut FlaggedStorage<C, IdvStorage<C>>,
|
||||
&'a hibitset::BitSet,
|
||||
SequentialRestriction,
|
||||
>;
|
||||
|
||||
pub type JoinTuple<'a> = (
|
||||
Entity,
|
||||
&'a Uid,
|
||||
RestrictedMut<'a, CharacterState>,
|
||||
&'a mut Pos,
|
||||
&'a mut Vel,
|
||||
&'a mut Ori,
|
||||
RestrictedMut<'a, Energy>,
|
||||
RestrictedMut<'a, Loadout>,
|
||||
&'a mut Controller,
|
||||
&'a Health,
|
||||
&'a Body,
|
||||
&'a PhysicsState,
|
||||
Option<&'a Attacking>,
|
||||
Option<&'a Beam>,
|
||||
);
|
||||
|
||||
impl<'a> JoinData<'a> {
|
||||
pub fn new(j: &'a JoinTuple<'a>, updater: &'a LazyUpdate, dt: &'a DeltaTime) -> Self {
|
||||
Self {
|
||||
entity: j.0,
|
||||
uid: j.1,
|
||||
character: j.2.get_unchecked(),
|
||||
pos: j.3,
|
||||
vel: j.4,
|
||||
ori: j.5,
|
||||
energy: j.6.get_unchecked(),
|
||||
loadout: j.7.get_unchecked(),
|
||||
controller: j.8,
|
||||
inputs: &j.8.inputs,
|
||||
health: j.9,
|
||||
body: j.10,
|
||||
physics: j.11,
|
||||
attacking: j.12,
|
||||
updater,
|
||||
dt,
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,9 @@
|
||||
use crate::{
|
||||
comp::{CharacterState, StateUpdate},
|
||||
states::utils::*,
|
||||
sys::character_behavior::{CharacterBehavior, JoinData},
|
||||
states::{
|
||||
behavior::{CharacterBehavior, JoinData},
|
||||
utils::*,
|
||||
},
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::time::Duration;
|
||||
|
@ -1,7 +1,9 @@
|
||||
use crate::{
|
||||
comp::{Attacking, CharacterState, EnergyChange, EnergySource, StateUpdate},
|
||||
states::utils::{StageSection, *},
|
||||
sys::character_behavior::*,
|
||||
states::{
|
||||
behavior::{CharacterBehavior, JoinData},
|
||||
utils::{StageSection, *},
|
||||
},
|
||||
Damage, DamageSource, GroupTarget, Knockback,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -6,8 +6,10 @@ use crate::{
|
||||
},
|
||||
effect::BuffEffect,
|
||||
event::ServerEvent,
|
||||
states::utils::*,
|
||||
sys::character_behavior::{CharacterBehavior, JoinData},
|
||||
states::{
|
||||
behavior::{CharacterBehavior, JoinData},
|
||||
utils::*,
|
||||
},
|
||||
Damage, DamageSource, GroupTarget, Knockback,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -1,10 +1,8 @@
|
||||
use crate::{
|
||||
comp::{CharacterState, Climb, EnergySource, StateUpdate},
|
||||
consts::GRAVITY,
|
||||
event::LocalEvent,
|
||||
sys::{
|
||||
character_behavior::{CharacterBehavior, JoinData},
|
||||
phys::GRAVITY,
|
||||
},
|
||||
states::behavior::{CharacterBehavior, JoinData},
|
||||
util::Dir,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -1,7 +1,9 @@
|
||||
use crate::{
|
||||
comp::{Attacking, CharacterState, EnergyChange, EnergySource, StateUpdate},
|
||||
states::utils::*,
|
||||
sys::character_behavior::{CharacterBehavior, JoinData},
|
||||
states::{
|
||||
behavior::{CharacterBehavior, JoinData},
|
||||
utils::*,
|
||||
},
|
||||
Damage, DamageSource, GroupTarget, Knockback,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -1,7 +1,7 @@
|
||||
use super::utils::*;
|
||||
use crate::{
|
||||
comp::{CharacterState, StateUpdate},
|
||||
sys::character_behavior::{CharacterBehavior, JoinData},
|
||||
states::behavior::{CharacterBehavior, JoinData},
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
use crate::{
|
||||
comp::{Attacking, CharacterState, EnergyChange, EnergySource, StateUpdate},
|
||||
states::utils::*,
|
||||
sys::character_behavior::{CharacterBehavior, JoinData},
|
||||
states::{
|
||||
behavior::{CharacterBehavior, JoinData},
|
||||
utils::*,
|
||||
},
|
||||
Damage, DamageSource, GroupTarget, Knockback,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -1,7 +1,7 @@
|
||||
use super::utils::*;
|
||||
use crate::{
|
||||
comp::{CharacterState, StateUpdate},
|
||||
sys::character_behavior::{CharacterBehavior, JoinData},
|
||||
states::behavior::{CharacterBehavior, JoinData},
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::time::Duration;
|
||||
|
@ -1,13 +1,13 @@
|
||||
use super::utils::handle_climb;
|
||||
use crate::{
|
||||
comp::{CharacterState, StateUpdate},
|
||||
sys::character_behavior::{CharacterBehavior, JoinData},
|
||||
states::behavior::{CharacterBehavior, JoinData},
|
||||
util::Dir,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use vek::Vec2;
|
||||
// Gravity is 9.81 * 4, so this makes gravity equal to .15
|
||||
const GLIDE_ANTIGRAV: f32 = crate::sys::phys::GRAVITY * 0.90;
|
||||
const GLIDE_ANTIGRAV: f32 = crate::consts::GRAVITY * 0.90;
|
||||
const GLIDE_ACCEL: f32 = 12.0;
|
||||
const GLIDE_SPEED: f32 = 45.0;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
use super::utils::*;
|
||||
use crate::{
|
||||
comp::{CharacterState, StateUpdate},
|
||||
sys::character_behavior::{CharacterBehavior, JoinData},
|
||||
states::behavior::{CharacterBehavior, JoinData},
|
||||
};
|
||||
|
||||
pub struct Data;
|
||||
|
@ -1,7 +1,7 @@
|
||||
use super::utils::*;
|
||||
use crate::{
|
||||
comp::StateUpdate,
|
||||
sys::character_behavior::{CharacterBehavior, JoinData},
|
||||
states::behavior::{CharacterBehavior, JoinData},
|
||||
};
|
||||
|
||||
pub struct Data;
|
||||
|
@ -1,7 +1,9 @@
|
||||
use crate::{
|
||||
comp::{Attacking, CharacterState, StateUpdate},
|
||||
states::utils::{StageSection, *},
|
||||
sys::character_behavior::{CharacterBehavior, JoinData},
|
||||
states::{
|
||||
behavior::{CharacterBehavior, JoinData},
|
||||
utils::{StageSection, *},
|
||||
},
|
||||
Damage, DamageSource, GroupTarget, Knockback,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -2,6 +2,7 @@ pub mod basic_beam;
|
||||
pub mod basic_block;
|
||||
pub mod basic_melee;
|
||||
pub mod basic_ranged;
|
||||
pub mod behavior;
|
||||
pub mod boost;
|
||||
pub mod charged_melee;
|
||||
pub mod charged_ranged;
|
||||
|
@ -1,8 +1,10 @@
|
||||
use crate::{
|
||||
comp::{Body, CharacterState, Gravity, LightEmitter, ProjectileConstructor, StateUpdate},
|
||||
event::ServerEvent,
|
||||
states::utils::{StageSection, *},
|
||||
sys::character_behavior::*,
|
||||
states::{
|
||||
behavior::{CharacterBehavior, JoinData},
|
||||
utils::{StageSection, *},
|
||||
},
|
||||
util::dir::*,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -1,7 +1,9 @@
|
||||
use crate::{
|
||||
comp::{CharacterState, StateUpdate},
|
||||
states::utils::*,
|
||||
sys::character_behavior::{CharacterBehavior, JoinData},
|
||||
states::{
|
||||
behavior::{CharacterBehavior, JoinData},
|
||||
utils::*,
|
||||
},
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::time::Duration;
|
||||
|
@ -1,8 +1,10 @@
|
||||
use crate::{
|
||||
comp::{shockwave, CharacterState, StateUpdate},
|
||||
event::ServerEvent,
|
||||
states::utils::*,
|
||||
sys::character_behavior::{CharacterBehavior, JoinData},
|
||||
states::{
|
||||
behavior::{CharacterBehavior, JoinData},
|
||||
utils::*,
|
||||
},
|
||||
Damage, DamageSource, GroupTarget, Knockback,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -1,7 +1,7 @@
|
||||
use super::utils::*;
|
||||
use crate::{
|
||||
comp::{CharacterState, StateUpdate},
|
||||
sys::character_behavior::{CharacterBehavior, JoinData},
|
||||
states::behavior::{CharacterBehavior, JoinData},
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
use super::utils::*;
|
||||
use crate::{
|
||||
comp::{CharacterState, StateUpdate},
|
||||
sys::character_behavior::{CharacterBehavior, JoinData},
|
||||
states::behavior::{CharacterBehavior, JoinData},
|
||||
};
|
||||
|
||||
pub struct Data;
|
||||
|
@ -1,9 +1,9 @@
|
||||
use crate::{
|
||||
comp::{Attacking, CharacterState, EnergyChange, EnergySource, StateUpdate},
|
||||
states::utils::*,
|
||||
sys::{
|
||||
character_behavior::{CharacterBehavior, JoinData},
|
||||
phys::GRAVITY,
|
||||
consts::GRAVITY,
|
||||
states::{
|
||||
behavior::{CharacterBehavior, JoinData},
|
||||
utils::*,
|
||||
},
|
||||
Damage, DamageSource, GroupTarget, Knockback,
|
||||
};
|
||||
|
@ -3,12 +3,9 @@ use crate::{
|
||||
item::{Hands, ItemKind, Tool},
|
||||
quadruped_low, quadruped_medium, theropod, Body, CharacterState, StateUpdate,
|
||||
},
|
||||
consts::{FRIC_GROUND, GRAVITY},
|
||||
event::LocalEvent,
|
||||
states::*,
|
||||
sys::{
|
||||
character_behavior::JoinData,
|
||||
phys::{FRIC_GROUND, GRAVITY},
|
||||
},
|
||||
states::{behavior::JoinData, *},
|
||||
util::Dir,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -1,7 +1,7 @@
|
||||
use super::utils::*;
|
||||
use crate::{
|
||||
comp::{CharacterState, StateUpdate},
|
||||
sys::character_behavior::{CharacterBehavior, JoinData},
|
||||
states::behavior::{CharacterBehavior, JoinData},
|
||||
};
|
||||
|
||||
pub struct Data;
|
||||
|
36
common/sys/Cargo.toml
Normal file
36
common/sys/Cargo.toml
Normal file
@ -0,0 +1,36 @@
|
||||
[package]
|
||||
authors = ["Marcel Märtens <marcel.cochem@googlemail.com>"]
|
||||
edition = "2018"
|
||||
name = "veloren_common_sys"
|
||||
version = "0.8.0"
|
||||
|
||||
[lib]
|
||||
name = "common_sys"
|
||||
|
||||
[features]
|
||||
tracy = ["tracy-client"]
|
||||
simd = ["vek/platform_intrinsics"]
|
||||
|
||||
default = ["simd"]
|
||||
|
||||
[dependencies]
|
||||
common = {package = "veloren-common", path = "../../common"}
|
||||
|
||||
rand = "0.7"
|
||||
rayon = "1.3.0"
|
||||
tracing = { version = "0.1", default-features = false }
|
||||
vek = { version = "0.12.0", features = ["serde"] }
|
||||
|
||||
# Data structures
|
||||
hashbrown = { version = "0.7.2", features = ["rayon", "serde", "nightly"] }
|
||||
indexmap = "1.3.0"
|
||||
slab = "0.4.2"
|
||||
|
||||
# ECS
|
||||
specs = { git = "https://github.com/amethyst/specs.git", features = ["serde", "storage-event-control"], rev = "7a2e348ab2223818bad487695c66c43db88050a5" }
|
||||
|
||||
# Serde
|
||||
serde = { version = "1.0.110", features = ["derive"] }
|
||||
|
||||
# Tracy
|
||||
tracy-client = { version = "0.9.0", optional = true }
|
@ -1,4 +1,4 @@
|
||||
use crate::{
|
||||
use common::{
|
||||
comp::{
|
||||
self,
|
||||
agent::Activity,
|
||||
@ -15,8 +15,8 @@ use crate::{
|
||||
event::{EventBus, ServerEvent},
|
||||
metrics::SysMetrics,
|
||||
path::{Chaser, TraversalConfig},
|
||||
resources::{DeltaTime, Time, TimeOfDay},
|
||||
span,
|
||||
state::{DeltaTime, Time, TimeOfDay},
|
||||
sync::{Uid, UidAllocator},
|
||||
terrain::{Block, TerrainGrid},
|
||||
time::DayPeriod,
|
@ -1,10 +1,10 @@
|
||||
use crate::{
|
||||
use common::{
|
||||
comp::{
|
||||
group, Beam, BeamSegment, Body, Energy, EnergyChange, EnergySource, Health, HealthChange,
|
||||
HealthSource, Last, Loadout, Ori, Pos, Scale,
|
||||
},
|
||||
event::{EventBus, ServerEvent},
|
||||
state::{DeltaTime, Time},
|
||||
resources::{DeltaTime, Time},
|
||||
sync::{Uid, UidAllocator},
|
||||
GroupTarget,
|
||||
};
|
@ -1,10 +1,10 @@
|
||||
use crate::{
|
||||
use common::{
|
||||
comp::{
|
||||
BuffCategory, BuffChange, BuffEffect, BuffId, BuffSource, Buffs, Health, HealthChange,
|
||||
HealthSource, Loadout, ModifierKind,
|
||||
},
|
||||
event::{EventBus, ServerEvent},
|
||||
state::DeltaTime,
|
||||
resources::DeltaTime,
|
||||
DamageSource,
|
||||
};
|
||||
use specs::{Entities, Join, Read, ReadStorage, System, WriteStorage};
|
@ -1,96 +1,20 @@
|
||||
use crate::{
|
||||
use common::{
|
||||
comp::{
|
||||
Attacking, Beam, Body, CharacterState, ControlAction, Controller, ControllerInputs, Energy,
|
||||
Health, Loadout, Mounting, Ori, PhysicsState, Pos, StateUpdate, Vel,
|
||||
Attacking, Beam, Body, CharacterState, Controller, Energy, Health, Loadout, Mounting, Ori,
|
||||
PhysicsState, Pos, StateUpdate, Vel,
|
||||
},
|
||||
event::{EventBus, LocalEvent, ServerEvent},
|
||||
metrics::SysMetrics,
|
||||
resources::DeltaTime,
|
||||
span,
|
||||
state::DeltaTime,
|
||||
states,
|
||||
states::{
|
||||
self,
|
||||
behavior::{CharacterBehavior, JoinData, JoinTuple},
|
||||
},
|
||||
sync::{Uid, UidAllocator},
|
||||
};
|
||||
|
||||
use specs::{
|
||||
hibitset,
|
||||
storage::{PairedStorage, SequentialRestriction},
|
||||
Entities, Entity, FlaggedStorage, Join, LazyUpdate, Read, ReadExpect, ReadStorage, System,
|
||||
WriteStorage,
|
||||
};
|
||||
use specs_idvs::IdvStorage;
|
||||
|
||||
// use std::collections::VecDeque;
|
||||
|
||||
pub trait CharacterBehavior {
|
||||
fn behavior(&self, data: &JoinData) -> StateUpdate;
|
||||
// Impl these to provide behavior for these inputs
|
||||
fn swap_loadout(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) }
|
||||
fn wield(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) }
|
||||
fn glide_wield(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) }
|
||||
fn unwield(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) }
|
||||
fn sit(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) }
|
||||
fn dance(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) }
|
||||
fn sneak(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) }
|
||||
fn stand(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) }
|
||||
fn handle_event(&self, data: &JoinData, event: ControlAction) -> StateUpdate {
|
||||
match event {
|
||||
ControlAction::SwapLoadout => self.swap_loadout(data),
|
||||
ControlAction::Wield => self.wield(data),
|
||||
ControlAction::GlideWield => self.glide_wield(data),
|
||||
ControlAction::Unwield => self.unwield(data),
|
||||
ControlAction::Sit => self.sit(data),
|
||||
ControlAction::Dance => self.dance(data),
|
||||
ControlAction::Sneak => self.sneak(data),
|
||||
ControlAction::Stand => self.stand(data),
|
||||
}
|
||||
}
|
||||
// fn init(data: &JoinData) -> CharacterState;
|
||||
}
|
||||
|
||||
/// Read-Only Data sent from Character Behavior System to behavior fn's
|
||||
pub struct JoinData<'a> {
|
||||
pub entity: Entity,
|
||||
pub uid: &'a Uid,
|
||||
pub character: &'a CharacterState,
|
||||
pub pos: &'a Pos,
|
||||
pub vel: &'a Vel,
|
||||
pub ori: &'a Ori,
|
||||
pub dt: &'a DeltaTime,
|
||||
pub controller: &'a Controller,
|
||||
pub inputs: &'a ControllerInputs,
|
||||
pub health: &'a Health,
|
||||
pub energy: &'a Energy,
|
||||
pub loadout: &'a Loadout,
|
||||
pub body: &'a Body,
|
||||
pub physics: &'a PhysicsState,
|
||||
pub attacking: Option<&'a Attacking>,
|
||||
pub updater: &'a LazyUpdate,
|
||||
}
|
||||
|
||||
type RestrictedMut<'a, C> = PairedStorage<
|
||||
'a,
|
||||
'a,
|
||||
C,
|
||||
&'a mut FlaggedStorage<C, IdvStorage<C>>,
|
||||
&'a hibitset::BitSet,
|
||||
SequentialRestriction,
|
||||
>;
|
||||
pub type JoinTuple<'a> = (
|
||||
Entity,
|
||||
&'a Uid,
|
||||
RestrictedMut<'a, CharacterState>,
|
||||
&'a mut Pos,
|
||||
&'a mut Vel,
|
||||
&'a mut Ori,
|
||||
RestrictedMut<'a, Energy>,
|
||||
RestrictedMut<'a, Loadout>,
|
||||
&'a mut Controller,
|
||||
&'a Health,
|
||||
&'a Body,
|
||||
&'a PhysicsState,
|
||||
Option<&'a Attacking>,
|
||||
Option<&'a Beam>,
|
||||
);
|
||||
use specs::{Entities, Join, LazyUpdate, Read, ReadExpect, ReadStorage, System, WriteStorage};
|
||||
|
||||
fn incorporate_update(tuple: &mut JoinTuple, state_update: StateUpdate) {
|
||||
// TODO: if checking equality is expensive use optional field in StateUpdate
|
||||
@ -110,29 +34,6 @@ fn incorporate_update(tuple: &mut JoinTuple, state_update: StateUpdate) {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> JoinData<'a> {
|
||||
fn new(j: &'a JoinTuple<'a>, updater: &'a LazyUpdate, dt: &'a DeltaTime) -> Self {
|
||||
Self {
|
||||
entity: j.0,
|
||||
uid: j.1,
|
||||
character: j.2.get_unchecked(),
|
||||
pos: j.3,
|
||||
vel: j.4,
|
||||
ori: j.5,
|
||||
energy: j.6.get_unchecked(),
|
||||
loadout: j.7.get_unchecked(),
|
||||
controller: j.8,
|
||||
inputs: &j.8.inputs,
|
||||
health: j.9,
|
||||
body: j.10,
|
||||
physics: j.11,
|
||||
attacking: j.12,
|
||||
updater,
|
||||
dt,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// ## Character Behavior System
|
||||
/// Passes `JoinData` to `CharacterState`'s `behavior` handler fn's. Receives a
|
||||
/// `StateUpdate` in return and performs updates to ECS Components from that.
|
@ -1,12 +1,12 @@
|
||||
use crate::{
|
||||
use common::{
|
||||
comp::{
|
||||
slot::{EquipSlot, Slot},
|
||||
BuffChange, CharacterState, ControlEvent, Controller, InventoryManip,
|
||||
},
|
||||
event::{EventBus, LocalEvent, ServerEvent},
|
||||
metrics::SysMetrics,
|
||||
resources::DeltaTime,
|
||||
span,
|
||||
state::DeltaTime,
|
||||
sync::{Uid, UidAllocator},
|
||||
};
|
||||
use specs::{
|
@ -1,3 +1,5 @@
|
||||
#![feature(label_break_value, bool_to_option)]
|
||||
|
||||
pub mod agent;
|
||||
mod beam;
|
||||
mod buff;
|
||||
@ -8,6 +10,7 @@ mod mount;
|
||||
pub mod phys;
|
||||
mod projectile;
|
||||
mod shockwave;
|
||||
pub mod state;
|
||||
mod stats;
|
||||
|
||||
// External
|
@ -1,4 +1,4 @@
|
||||
use crate::{
|
||||
use common::{
|
||||
comp::{buff, group, Attacking, Body, CharacterState, Health, Loadout, Ori, Pos, Scale},
|
||||
event::{EventBus, LocalEvent, ServerEvent},
|
||||
metrics::SysMetrics,
|
@ -1,4 +1,4 @@
|
||||
use crate::{
|
||||
use common::{
|
||||
comp::{Controller, MountState, Mounting, Ori, Pos, Vel},
|
||||
metrics::SysMetrics,
|
||||
span,
|
||||
@ -66,12 +66,12 @@ impl<'a> System<'a> for Sys {
|
||||
let _ = orientations.insert(mounter, ori);
|
||||
let _ = velocities.insert(mounter, vel);
|
||||
}
|
||||
controllers.get_mut(entity).map(|controller| {
|
||||
if let Some(controller) = controllers.get_mut(entity) {
|
||||
*controller = Controller {
|
||||
inputs,
|
||||
..Default::default()
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
*(mount_states.get_mut_unchecked()) = MountState::Unmounted;
|
||||
}
|
@ -1,12 +1,13 @@
|
||||
use crate::{
|
||||
use common::{
|
||||
comp::{
|
||||
BeamSegment, CharacterState, Collider, Gravity, Mass, Mounting, Ori, PhysicsState, Pos,
|
||||
PreviousVelDtCache, Projectile, Scale, Shockwave, Sticky, Vel,
|
||||
},
|
||||
consts::{FRIC_GROUND, GRAVITY},
|
||||
event::{EventBus, ServerEvent},
|
||||
metrics::{PhysicsMetrics, SysMetrics},
|
||||
resources::DeltaTime,
|
||||
span,
|
||||
state::DeltaTime,
|
||||
sync::Uid,
|
||||
terrain::{Block, TerrainGrid},
|
||||
vol::ReadVol,
|
||||
@ -18,7 +19,6 @@ use specs::{
|
||||
use std::ops::Range;
|
||||
use vek::*;
|
||||
|
||||
pub const GRAVITY: f32 = 9.81 * 5.0;
|
||||
pub const BOUYANCY: f32 = 1.0;
|
||||
// Friction values used for linear damping. They are unitless quantities. The
|
||||
// value of these quantities must be between zero and one. They represent the
|
||||
@ -26,7 +26,6 @@ pub const BOUYANCY: f32 = 1.0;
|
||||
// friction is 0.01, and the speed is 1.0, then after 1/60th of a second the
|
||||
// speed will be 0.99. after 1 second the speed will be 0.54, which is 0.99 ^
|
||||
// 60.
|
||||
pub const FRIC_GROUND: f32 = 0.15;
|
||||
pub const FRIC_AIR: f32 = 0.0125;
|
||||
pub const FRIC_FLUID: f32 = 0.4;
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::{
|
||||
use common::{
|
||||
comp::{
|
||||
buff::{Buff, BuffChange, BuffSource},
|
||||
projectile, EnergyChange, EnergySource, Group, HealthSource, Loadout, Ori, PhysicsState,
|
||||
@ -6,8 +6,8 @@ use crate::{
|
||||
},
|
||||
event::{EventBus, ServerEvent},
|
||||
metrics::SysMetrics,
|
||||
resources::DeltaTime,
|
||||
span,
|
||||
state::DeltaTime,
|
||||
sync::UidAllocator,
|
||||
GroupTarget,
|
||||
};
|
@ -1,10 +1,10 @@
|
||||
use crate::{
|
||||
use common::{
|
||||
comp::{
|
||||
group, Body, Health, HealthSource, Last, Loadout, Ori, PhysicsState, Pos, Scale, Shockwave,
|
||||
ShockwaveHitEntities,
|
||||
},
|
||||
event::{EventBus, LocalEvent, ServerEvent},
|
||||
state::{DeltaTime, Time},
|
||||
resources::{DeltaTime, Time},
|
||||
sync::{Uid, UidAllocator},
|
||||
util::Dir,
|
||||
GroupTarget,
|
@ -1,18 +1,17 @@
|
||||
use crate::{
|
||||
use common::{
|
||||
comp,
|
||||
event::{EventBus, LocalEvent, ServerEvent},
|
||||
metrics::{PhysicsMetrics, SysMetrics},
|
||||
region::RegionMap,
|
||||
resources::{DeltaTime, Time, TimeOfDay},
|
||||
span,
|
||||
sync::WorldSyncExt,
|
||||
sys,
|
||||
terrain::{Block, TerrainChunk, TerrainGrid},
|
||||
time::DayPeriod,
|
||||
vol::{ReadVol, WriteVol},
|
||||
};
|
||||
use hashbrown::{HashMap, HashSet};
|
||||
use rayon::{ThreadPool, ThreadPoolBuilder};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use specs::{
|
||||
shred::{Fetch, FetchMut},
|
||||
storage::{MaskedStorage as EcsMaskedStorage, Storage as EcsStorage},
|
||||
@ -25,18 +24,6 @@ use vek::*;
|
||||
// TODO: Don't hard-code this.
|
||||
const DAY_CYCLE_FACTOR: f64 = 24.0 * 2.0;
|
||||
|
||||
/// A resource that stores the time of day.
|
||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize, Default)]
|
||||
pub struct TimeOfDay(pub f64);
|
||||
|
||||
/// A resource that stores the tick (i.e: physics) time.
|
||||
#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize)]
|
||||
pub struct Time(pub f64);
|
||||
|
||||
/// A resource that stores the time since the previous tick.
|
||||
#[derive(Default)]
|
||||
pub struct DeltaTime(pub f32);
|
||||
|
||||
/// At what point should we stop speeding up physics to compensate for lag? If
|
||||
/// we speed physics up too fast, we'd skip important physics events like
|
||||
/// collisions. This constant determines the upper limit. If delta time exceeds
|
||||
@ -380,7 +367,7 @@ impl State {
|
||||
// Create and run a dispatcher for ecs systems.
|
||||
let mut dispatch_builder =
|
||||
DispatcherBuilder::new().with_pool(Arc::clone(&self.thread_pool));
|
||||
sys::add_local_systems(&mut dispatch_builder);
|
||||
crate::add_local_systems(&mut dispatch_builder);
|
||||
// TODO: Consider alternative ways to do this
|
||||
add_foreign_systems(&mut dispatch_builder);
|
||||
// This dispatches all the systems in parallel.
|
@ -1,9 +1,9 @@
|
||||
use crate::{
|
||||
use common::{
|
||||
comp::{CharacterState, Energy, EnergyChange, EnergySource, Health, HealthSource, Stats},
|
||||
event::{EventBus, ServerEvent},
|
||||
metrics::SysMetrics,
|
||||
resources::DeltaTime,
|
||||
span,
|
||||
state::DeltaTime,
|
||||
};
|
||||
use specs::{Entities, Join, Read, ReadExpect, ReadStorage, System, WriteStorage};
|
||||
|
@ -12,6 +12,7 @@ default = ["worldgen", "simd"]
|
||||
|
||||
[dependencies]
|
||||
common = { package = "veloren-common", path = "../common" }
|
||||
common_sys = { package = "veloren_common_sys", path = "../common/sys" }
|
||||
world = { package = "veloren-world", path = "../world" }
|
||||
network = { package = "veloren_network", path = "../network", features = ["metrics", "compression"], default-features = false }
|
||||
|
||||
|
@ -14,7 +14,7 @@ use common::{
|
||||
event::{EventBus, ServerEvent},
|
||||
msg::{DisconnectReason, Notification, PlayerListUpdate, ServerGeneral},
|
||||
npc::{self, get_npc_name},
|
||||
state::TimeOfDay,
|
||||
resources::TimeOfDay,
|
||||
sync::{Uid, WorldSyncExt},
|
||||
terrain::{Block, BlockKind, SpriteKind, TerrainChunkSize},
|
||||
util::Dir,
|
||||
@ -374,7 +374,10 @@ fn handle_home(
|
||||
.is_some()
|
||||
{
|
||||
let home_pos = server.state.ecs().read_resource::<SpawnPoint>().0;
|
||||
let time = *server.state.ecs().read_resource::<common::state::Time>();
|
||||
let time = *server
|
||||
.state
|
||||
.ecs()
|
||||
.read_resource::<common::resources::Time>();
|
||||
|
||||
server.state.write_component(target, comp::Pos(home_pos));
|
||||
server
|
||||
|
@ -17,12 +17,12 @@ use common::{
|
||||
msg::{PlayerListUpdate, ServerGeneral},
|
||||
outcome::Outcome,
|
||||
rtsim::RtSimEntity,
|
||||
state::BlockChange,
|
||||
sync::{Uid, UidAllocator, WorldSyncExt},
|
||||
terrain::{Block, TerrainGrid},
|
||||
vol::ReadVol,
|
||||
Damage, DamageSource, Explosion, GroupTarget, RadiusEffect,
|
||||
};
|
||||
use common_sys::state::BlockChange;
|
||||
use comp::item::Reagent;
|
||||
use rand::prelude::*;
|
||||
use specs::{join::Join, saveload::MarkerAllocator, Entity as EcsEntity, WorldExt};
|
||||
|
@ -11,6 +11,7 @@ use common::{
|
||||
util::find_dist::{self, FindDist},
|
||||
vol::ReadVol,
|
||||
};
|
||||
use common_sys::state::State;
|
||||
use comp::LightEmitter;
|
||||
use rand::Rng;
|
||||
use specs::{join::Join, world::WorldExt, Builder, Entity as EcsEntity, WriteStorage};
|
||||
@ -39,7 +40,7 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv
|
||||
let mut dropped_items = Vec::new();
|
||||
let mut thrown_items = Vec::new();
|
||||
|
||||
let get_cylinder = |state: &common::state::State, entity| {
|
||||
let get_cylinder = |state: &State, entity| {
|
||||
let ecs = state.ecs();
|
||||
let positions = ecs.read_storage::<comp::Pos>();
|
||||
let scales = ecs.read_storage::<comp::Scale>();
|
||||
|
@ -8,9 +8,9 @@ use common::{
|
||||
comp::{group, Player},
|
||||
msg::{PlayerListUpdate, PresenceKind, ServerGeneral},
|
||||
span,
|
||||
state::State,
|
||||
sync::{Uid, UidAllocator},
|
||||
};
|
||||
use common_sys::state::State;
|
||||
use futures_executor::block_on;
|
||||
use specs::{saveload::MarkerAllocator, Builder, Entity as EcsEntity, WorldExt};
|
||||
use tracing::{debug, error, trace, warn};
|
||||
|
@ -56,12 +56,13 @@ use common::{
|
||||
},
|
||||
outcome::Outcome,
|
||||
recipe::default_recipe_book,
|
||||
resources::TimeOfDay,
|
||||
rtsim::RtSimEntity,
|
||||
state::{State, TimeOfDay},
|
||||
sync::WorldSyncExt,
|
||||
terrain::TerrainChunkSize,
|
||||
vol::{ReadVol, RectVolSize},
|
||||
};
|
||||
use common_sys::state::State;
|
||||
use futures_executor::block_on;
|
||||
use metrics::{PhysicsMetrics, ServerMetrics, StateTickMetrics, TickMetrics};
|
||||
use network::{Network, Pid, ProtocolAddr};
|
||||
@ -806,40 +807,39 @@ impl Server {
|
||||
let projectile_ns = res.projectile_ns.load(Ordering::Relaxed);
|
||||
let melee_ns = res.melee_ns.load(Ordering::Relaxed);
|
||||
|
||||
c.with_label_values(&[common::sys::AGENT_SYS])
|
||||
c.with_label_values(&[common_sys::AGENT_SYS])
|
||||
.inc_by(agent_ns);
|
||||
c.with_label_values(&[common::sys::MOUNT_SYS])
|
||||
c.with_label_values(&[common_sys::MOUNT_SYS])
|
||||
.inc_by(mount_ns);
|
||||
c.with_label_values(&[common::sys::CONTROLLER_SYS])
|
||||
c.with_label_values(&[common_sys::CONTROLLER_SYS])
|
||||
.inc_by(controller_ns);
|
||||
c.with_label_values(&[common::sys::CHARACTER_BEHAVIOR_SYS])
|
||||
c.with_label_values(&[common_sys::CHARACTER_BEHAVIOR_SYS])
|
||||
.inc_by(character_behavior_ns);
|
||||
c.with_label_values(&[common::sys::STATS_SYS])
|
||||
c.with_label_values(&[common_sys::STATS_SYS])
|
||||
.inc_by(stats_ns);
|
||||
c.with_label_values(&[common::sys::PHYS_SYS])
|
||||
.inc_by(phys_ns);
|
||||
c.with_label_values(&[common::sys::PROJECTILE_SYS])
|
||||
c.with_label_values(&[common_sys::PHYS_SYS]).inc_by(phys_ns);
|
||||
c.with_label_values(&[common_sys::PROJECTILE_SYS])
|
||||
.inc_by(projectile_ns);
|
||||
c.with_label_values(&[common::sys::MELEE_SYS])
|
||||
c.with_label_values(&[common_sys::MELEE_SYS])
|
||||
.inc_by(melee_ns);
|
||||
|
||||
const NANOSEC_PER_SEC: f64 = Duration::from_secs(1).as_nanos() as f64;
|
||||
let h = &self.state_tick_metrics.state_tick_time_hist;
|
||||
h.with_label_values(&[common::sys::AGENT_SYS])
|
||||
h.with_label_values(&[common_sys::AGENT_SYS])
|
||||
.observe(agent_ns as f64 / NANOSEC_PER_SEC);
|
||||
h.with_label_values(&[common::sys::MOUNT_SYS])
|
||||
h.with_label_values(&[common_sys::MOUNT_SYS])
|
||||
.observe(mount_ns as f64 / NANOSEC_PER_SEC);
|
||||
h.with_label_values(&[common::sys::CONTROLLER_SYS])
|
||||
h.with_label_values(&[common_sys::CONTROLLER_SYS])
|
||||
.observe(controller_ns as f64 / NANOSEC_PER_SEC);
|
||||
h.with_label_values(&[common::sys::CHARACTER_BEHAVIOR_SYS])
|
||||
h.with_label_values(&[common_sys::CHARACTER_BEHAVIOR_SYS])
|
||||
.observe(character_behavior_ns as f64 / NANOSEC_PER_SEC);
|
||||
h.with_label_values(&[common::sys::STATS_SYS])
|
||||
h.with_label_values(&[common_sys::STATS_SYS])
|
||||
.observe(stats_ns as f64 / NANOSEC_PER_SEC);
|
||||
h.with_label_values(&[common::sys::PHYS_SYS])
|
||||
h.with_label_values(&[common_sys::PHYS_SYS])
|
||||
.observe(phys_ns as f64 / NANOSEC_PER_SEC);
|
||||
h.with_label_values(&[common::sys::PROJECTILE_SYS])
|
||||
h.with_label_values(&[common_sys::PROJECTILE_SYS])
|
||||
.observe(projectile_ns as f64 / NANOSEC_PER_SEC);
|
||||
h.with_label_values(&[common::sys::MELEE_SYS])
|
||||
h.with_label_values(&[common_sys::MELEE_SYS])
|
||||
.observe(melee_ns as f64 / NANOSEC_PER_SEC);
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ use common::{
|
||||
character::CharacterId,
|
||||
comp::{item::tool::AbilityMap, Body as CompBody, Waypoint, *},
|
||||
loadout_builder,
|
||||
state::Time,
|
||||
resources::Time,
|
||||
};
|
||||
use core::{convert::TryFrom, num::NonZeroU64};
|
||||
use itertools::{Either, Itertools};
|
||||
|
@ -10,10 +10,10 @@ use self::{chunks::Chunks, entity::Entity};
|
||||
use common::{
|
||||
comp,
|
||||
rtsim::{RtSimController, RtSimEntity, RtSimId},
|
||||
state::State,
|
||||
terrain::TerrainChunk,
|
||||
vol::RectRasterableVol,
|
||||
};
|
||||
use common_sys::state::State;
|
||||
use rand::prelude::*;
|
||||
use slab::Slab;
|
||||
use specs::{DispatcherBuilder, WorldExt};
|
||||
|
@ -4,7 +4,7 @@ use super::*;
|
||||
use common::{
|
||||
comp,
|
||||
event::{EventBus, ServerEvent},
|
||||
state::DeltaTime,
|
||||
resources::DeltaTime,
|
||||
terrain::TerrainGrid,
|
||||
};
|
||||
use specs::{Join, Read, ReadExpect, ReadStorage, System, WriteExpect, WriteStorage};
|
||||
|
@ -7,10 +7,10 @@ use common::{
|
||||
comp,
|
||||
effect::Effect,
|
||||
msg::{CharacterInfo, PlayerListUpdate, PresenceKind, ServerGeneral},
|
||||
state::State,
|
||||
sync::{Uid, UidAllocator, WorldSyncExt},
|
||||
util::Dir,
|
||||
};
|
||||
use common_sys::state::State;
|
||||
use rand::prelude::*;
|
||||
use specs::{
|
||||
saveload::MarkerAllocator, Builder, Entity as EcsEntity, EntityBuilder as EcsEntityBuilder,
|
||||
|
@ -12,8 +12,8 @@ use common::{
|
||||
msg::ServerGeneral,
|
||||
outcome::Outcome,
|
||||
region::{Event as RegionEvent, RegionMap},
|
||||
resources::TimeOfDay,
|
||||
span,
|
||||
state::TimeOfDay,
|
||||
sync::{CompSyncPackage, Uid},
|
||||
terrain::TerrainChunkSize,
|
||||
vol::RectVolSize,
|
||||
|
@ -4,8 +4,8 @@ use common::{
|
||||
comp::{ChatMode, Player, UnresolvedChatMsg},
|
||||
event::{EventBus, ServerEvent},
|
||||
msg::{validate_chat_msg, ChatMsgValidationError, ClientGeneral, MAX_BYTES_CHAT_MSG},
|
||||
resources::Time,
|
||||
span,
|
||||
state::Time,
|
||||
sync::Uid,
|
||||
};
|
||||
use specs::{Entities, Join, Read, ReadExpect, ReadStorage, System, Write};
|
||||
|
@ -5,10 +5,10 @@ use common::{
|
||||
event::{EventBus, ServerEvent},
|
||||
msg::{ClientGeneral, PresenceKind, ServerGeneral},
|
||||
span,
|
||||
state::BlockChange,
|
||||
terrain::{TerrainChunkSize, TerrainGrid},
|
||||
vol::{ReadVol, RectVolSize},
|
||||
};
|
||||
use common_sys::state::BlockChange;
|
||||
use specs::{Entities, Join, Read, ReadExpect, ReadStorage, System, Write, WriteStorage};
|
||||
use tracing::{debug, trace};
|
||||
|
||||
|
@ -3,8 +3,8 @@ use crate::{client::Client, metrics::PlayerMetrics, Settings};
|
||||
use common::{
|
||||
event::{EventBus, ServerEvent},
|
||||
msg::PingMsg,
|
||||
resources::Time,
|
||||
span,
|
||||
state::Time,
|
||||
};
|
||||
use specs::{Entities, Join, Read, ReadExpect, ReadStorage, System, Write};
|
||||
use std::sync::atomic::Ordering;
|
||||
|
@ -2,9 +2,8 @@ use common::{
|
||||
comp::{HealthSource, Object, PhysicsState, Pos, Vel},
|
||||
effect::Effect,
|
||||
event::{EventBus, ServerEvent},
|
||||
span,
|
||||
state::DeltaTime,
|
||||
Damage, DamageSource, Explosion, RadiusEffect,
|
||||
resources::DeltaTime,
|
||||
span, Damage, DamageSource, Explosion, RadiusEffect,
|
||||
};
|
||||
use specs::{Entities, Join, Read, ReadStorage, System, WriteStorage};
|
||||
|
||||
|
@ -9,10 +9,10 @@ use common::{
|
||||
msg::ServerGeneral,
|
||||
npc::NPC_NAMES,
|
||||
span,
|
||||
state::TerrainChanges,
|
||||
terrain::TerrainGrid,
|
||||
LoadoutBuilder,
|
||||
};
|
||||
use common_sys::state::TerrainChanges;
|
||||
use rand::Rng;
|
||||
use specs::{Join, Read, ReadExpect, ReadStorage, System, Write, WriteExpect};
|
||||
use std::sync::Arc;
|
||||
|
@ -1,6 +1,7 @@
|
||||
use super::SysTimer;
|
||||
use crate::{client::Client, presence::Presence};
|
||||
use common::{comp::Pos, msg::ServerGeneral, span, state::TerrainChanges, terrain::TerrainGrid};
|
||||
use common::{comp::Pos, msg::ServerGeneral, span, terrain::TerrainGrid};
|
||||
use common_sys::state::TerrainChanges;
|
||||
use specs::{Join, Read, ReadExpect, ReadStorage, System, Write};
|
||||
|
||||
/// This systems sends new chunks to clients as well as changes to existing
|
||||
|
@ -3,8 +3,8 @@ use crate::client::Client;
|
||||
use common::{
|
||||
comp::{Player, Pos, Waypoint, WaypointArea},
|
||||
msg::{Notification, ServerGeneral},
|
||||
resources::Time,
|
||||
span,
|
||||
state::Time,
|
||||
};
|
||||
use specs::{Entities, Join, Read, ReadStorage, System, Write, WriteStorage};
|
||||
|
||||
|
@ -21,6 +21,7 @@ default = ["gl", "singleplayer", "native-dialog", "simd"]
|
||||
[dependencies]
|
||||
client = {package = "veloren-client", path = "../client"}
|
||||
common = {package = "veloren-common", path = "../common"}
|
||||
common_sys = {package = "veloren_common_sys", path = "../common/sys"}
|
||||
|
||||
anim = {package = "veloren-voxygen-anim", path = "src/anim", default-features = false}
|
||||
|
||||
|
@ -4,7 +4,8 @@ use crate::{
|
||||
scene::Camera,
|
||||
};
|
||||
use client::Client;
|
||||
use common::{assets, state::State, vol::ReadVol};
|
||||
use common::{assets, vol::ReadVol};
|
||||
use common_sys::state::State;
|
||||
use serde::Deserialize;
|
||||
use std::time::Instant;
|
||||
use tracing::warn;
|
||||
|
@ -46,9 +46,9 @@ use crate::audio::{AudioFrontend, MusicChannelTag};
|
||||
use client::Client;
|
||||
use common::{
|
||||
assets,
|
||||
state::State,
|
||||
terrain::{BiomeKind, SitesKind},
|
||||
};
|
||||
use common_sys::state::State;
|
||||
use rand::{prelude::SliceRandom, thread_rng, Rng};
|
||||
use serde::Deserialize;
|
||||
use std::time::Instant;
|
||||
|
@ -11,10 +11,10 @@ use client::Client;
|
||||
use common::{
|
||||
comp::Pos,
|
||||
spiral::Spiral2d,
|
||||
state::State,
|
||||
terrain::TerrainChunk,
|
||||
vol::{ReadVol, RectRasterableVol},
|
||||
};
|
||||
use common_sys::state::State;
|
||||
use hashbrown::HashMap;
|
||||
use rand::{thread_rng, Rng};
|
||||
use std::time::Instant;
|
||||
|
@ -10,10 +10,10 @@ use super::EventMapper;
|
||||
use client::Client;
|
||||
use common::{
|
||||
comp::{object, Body, Pos},
|
||||
state::State,
|
||||
terrain::TerrainChunk,
|
||||
vol::ReadVol,
|
||||
};
|
||||
use common_sys::state::State;
|
||||
use hashbrown::HashMap;
|
||||
use specs::{Entity as EcsEntity, Join, WorldExt};
|
||||
use std::time::{Duration, Instant};
|
||||
|
@ -11,10 +11,10 @@ use super::EventMapper;
|
||||
use client::Client;
|
||||
use common::{
|
||||
comp::{item::ItemKind, CharacterAbilityType, CharacterState, Loadout, Pos},
|
||||
state::State,
|
||||
terrain::TerrainChunk,
|
||||
vol::ReadVol,
|
||||
};
|
||||
use common_sys::state::State;
|
||||
use hashbrown::HashMap;
|
||||
use specs::{Entity as EcsEntity, Join, WorldExt};
|
||||
use std::time::{Duration, Instant};
|
||||
|
@ -4,7 +4,8 @@ mod combat;
|
||||
mod movement;
|
||||
|
||||
use client::Client;
|
||||
use common::{state::State, terrain::TerrainChunk};
|
||||
use common::terrain::TerrainChunk;
|
||||
use common_sys::state::State;
|
||||
|
||||
use block::BlockEventMapper;
|
||||
use campfire::CampfireEventMapper;
|
||||
|
@ -10,10 +10,10 @@ use crate::{
|
||||
use client::Client;
|
||||
use common::{
|
||||
comp::{Body, CharacterState, PhysicsState, Pos, Vel},
|
||||
state::State,
|
||||
terrain::{BlockKind, TerrainChunk},
|
||||
vol::ReadVol,
|
||||
};
|
||||
use common_sys::state::State;
|
||||
use hashbrown::HashMap;
|
||||
use specs::{Entity as EcsEntity, Join, WorldExt};
|
||||
use std::time::{Duration, Instant};
|
||||
|
@ -95,9 +95,9 @@ use common::{
|
||||
object, Body, CharacterAbilityType, InventoryUpdateEvent,
|
||||
},
|
||||
outcome::Outcome,
|
||||
state::State,
|
||||
terrain::TerrainChunk,
|
||||
};
|
||||
use common_sys::state::State;
|
||||
use event_mapper::SfxEventMapper;
|
||||
use hashbrown::HashMap;
|
||||
use rand::prelude::*;
|
||||
|
@ -9,7 +9,7 @@ const INTERPOLATION_SYS: &str = "interpolation_voxygen_sys";
|
||||
|
||||
pub fn add_local_systems(dispatch_builder: &mut DispatcherBuilder) {
|
||||
dispatch_builder.add(interpolation::Sys, INTERPOLATION_SYS, &[
|
||||
common::sys::PHYS_SYS,
|
||||
common_sys::PHYS_SYS,
|
||||
]);
|
||||
dispatch_builder.add(floater::Sys, FLOATER_SYS, &[INTERPOLATION_SYS]);
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ use crate::ecs::{
|
||||
};
|
||||
use common::{
|
||||
comp::{Health, HealthSource, Pos, Stats},
|
||||
state::DeltaTime,
|
||||
resources::DeltaTime,
|
||||
sync::Uid,
|
||||
};
|
||||
use specs::{Entities, Join, Read, ReadExpect, ReadStorage, System, Write, WriteStorage};
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::ecs::comp::Interpolated;
|
||||
use common::{
|
||||
comp::{Ori, Pos, Vel},
|
||||
state::DeltaTime,
|
||||
resources::DeltaTime,
|
||||
util::Dir,
|
||||
};
|
||||
use specs::{Entities, Join, Read, ReadStorage, System, WriteStorage};
|
||||
|
@ -10,7 +10,7 @@ use crate::{
|
||||
Direction, GlobalState, PlayState, PlayStateResult,
|
||||
};
|
||||
use client::{self, Client};
|
||||
use common::{assets::Asset, comp, span, state::DeltaTime};
|
||||
use common::{assets::Asset, comp, resources::DeltaTime, span};
|
||||
use specs::WorldExt;
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
use tracing::error;
|
||||
|
@ -31,12 +31,13 @@ use common::{
|
||||
Body, CharacterState, Health, Item, Last, LightAnimation, LightEmitter, Loadout, Ori,
|
||||
PhysicsState, Pos, Scale, Vel,
|
||||
},
|
||||
resources::DeltaTime,
|
||||
span,
|
||||
state::{DeltaTime, State},
|
||||
states::utils::StageSection,
|
||||
terrain::TerrainChunk,
|
||||
vol::RectRasterableVol,
|
||||
};
|
||||
use common_sys::state::State;
|
||||
use core::{
|
||||
borrow::Borrow,
|
||||
convert::TryFrom,
|
||||
|
@ -27,11 +27,12 @@ use client::Client;
|
||||
use common::{
|
||||
comp,
|
||||
outcome::Outcome,
|
||||
resources::DeltaTime,
|
||||
span,
|
||||
state::{DeltaTime, State},
|
||||
terrain::{BlockKind, TerrainChunk},
|
||||
vol::ReadVol,
|
||||
};
|
||||
use common_sys::state::State;
|
||||
use comp::item::Reagent;
|
||||
use num::traits::{Float, FloatConst};
|
||||
use specs::{Entity as EcsEntity, Join, WorldExt};
|
||||
|
@ -11,9 +11,9 @@ use common::{
|
||||
comp::{item::Reagent, object, Body, CharacterState, Ori, Pos, Shockwave},
|
||||
figure::Segment,
|
||||
outcome::Outcome,
|
||||
resources::DeltaTime,
|
||||
span,
|
||||
spiral::Spiral2d,
|
||||
state::DeltaTime,
|
||||
states::utils::StageSection,
|
||||
terrain::TerrainChunk,
|
||||
vol::{RectRasterableVol, SizedVol},
|
||||
|
Loading…
Reference in New Issue
Block a user