mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Move agent system to server
This commit is contained in:
parent
2ebe0915f4
commit
1d8496ea21
10
Cargo.lock
generated
10
Cargo.lock
generated
@ -4105,9 +4105,9 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "portpicker"
|
name = "portpicker"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/xMAC94x/portpicker-rs#9d6df36c53c94684080a64a7212dd6bfc3617ee4"
|
source = "git+https://github.com/xMAC94x/portpicker-rs?rev=df6b37872f3586ac3b21d08b56c8ec7cd92fb172#df6b37872f3586ac3b21d08b56c8ec7cd92fb172"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rand 0.7.3",
|
"rand 0.8.3",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -5030,11 +5030,12 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "slotmap"
|
name = "slotmap"
|
||||||
version = "0.4.0"
|
version = "1.0.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c46a3482db8f247956e464d783693ece164ca056e6e67563ee5505bdb86452cd"
|
checksum = "ab3003725ae562cf995f3dc82bb99e70926e09000396816765bb6d7adbe740b1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
|
"version_check 0.9.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -6177,6 +6178,7 @@ dependencies = [
|
|||||||
"portpicker",
|
"portpicker",
|
||||||
"prometheus",
|
"prometheus",
|
||||||
"rand 0.8.3",
|
"rand 0.8.3",
|
||||||
|
"rayon",
|
||||||
"ron",
|
"ron",
|
||||||
"scan_fmt",
|
"scan_fmt",
|
||||||
"serde",
|
"serde",
|
||||||
|
@ -11,7 +11,7 @@ DashMelee(
|
|||||||
energy_drain: 0,
|
energy_drain: 0,
|
||||||
forward_speed: 2.0,
|
forward_speed: 2.0,
|
||||||
buildup_duration: 0.5,
|
buildup_duration: 0.5,
|
||||||
charge_duration: 0.3,
|
charge_duration: 0.4,
|
||||||
swing_duration: 0.1,
|
swing_duration: 0.1,
|
||||||
recover_duration: 0.5,
|
recover_duration: 0.5,
|
||||||
infinite_charge: true,
|
infinite_charge: true,
|
||||||
|
@ -9,9 +9,9 @@ DashMelee(
|
|||||||
range: 2.0,
|
range: 2.0,
|
||||||
angle: 45.0,
|
angle: 45.0,
|
||||||
energy_drain: 0,
|
energy_drain: 0,
|
||||||
forward_speed: 2.0,
|
forward_speed: 2.5,
|
||||||
buildup_duration: 1.2,
|
buildup_duration: 1.2,
|
||||||
charge_duration: 0.3,
|
charge_duration: 0.5,
|
||||||
swing_duration: 0.1,
|
swing_duration: 0.1,
|
||||||
recover_duration: 0.5,
|
recover_duration: 0.5,
|
||||||
infinite_charge: true,
|
infinite_charge: true,
|
||||||
|
@ -37,7 +37,7 @@ image = { version = "0.23.12", default-features = false, features = ["png"] }
|
|||||||
|
|
||||||
# Data structures
|
# Data structures
|
||||||
hashbrown = { version = "0.9", features = ["rayon", "serde", "nightly"] }
|
hashbrown = { version = "0.9", features = ["rayon", "serde", "nightly"] }
|
||||||
slotmap = { version = "0.4.0", features = ["serde", "unstable"] }
|
slotmap = { version = "1.0", features = ["serde"] }
|
||||||
indexmap = "1.3.0"
|
indexmap = "1.3.0"
|
||||||
slab = "0.4.2"
|
slab = "0.4.2"
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#![feature(label_break_value, bool_to_option, option_unwrap_none)]
|
#![feature(label_break_value, bool_to_option, option_unwrap_none)]
|
||||||
|
|
||||||
pub mod agent;
|
|
||||||
mod aura;
|
mod aura;
|
||||||
mod beam;
|
mod beam;
|
||||||
mod buff;
|
mod buff;
|
||||||
@ -21,7 +20,6 @@ use specs::DispatcherBuilder;
|
|||||||
// System names
|
// System names
|
||||||
pub const CHARACTER_BEHAVIOR_SYS: &str = "character_behavior_sys";
|
pub const CHARACTER_BEHAVIOR_SYS: &str = "character_behavior_sys";
|
||||||
pub const MELEE_SYS: &str = "melee_sys";
|
pub const MELEE_SYS: &str = "melee_sys";
|
||||||
pub const AGENT_SYS: &str = "agent_sys";
|
|
||||||
pub const BEAM_SYS: &str = "beam_sys";
|
pub const BEAM_SYS: &str = "beam_sys";
|
||||||
pub const CONTROLLER_SYS: &str = "controller_sys";
|
pub const CONTROLLER_SYS: &str = "controller_sys";
|
||||||
pub const MOUNT_SYS: &str = "mount_sys";
|
pub const MOUNT_SYS: &str = "mount_sys";
|
||||||
@ -33,9 +31,8 @@ pub const BUFFS_SYS: &str = "buffs_sys";
|
|||||||
pub const AURAS_SYS: &str = "auras_sys";
|
pub const AURAS_SYS: &str = "auras_sys";
|
||||||
|
|
||||||
pub fn add_local_systems(dispatch_builder: &mut DispatcherBuilder) {
|
pub fn add_local_systems(dispatch_builder: &mut DispatcherBuilder) {
|
||||||
dispatch_builder.add(agent::Sys, AGENT_SYS, &[]);
|
dispatch_builder.add(mount::Sys, MOUNT_SYS, &[]);
|
||||||
dispatch_builder.add(mount::Sys, MOUNT_SYS, &[AGENT_SYS]);
|
dispatch_builder.add(controller::Sys, CONTROLLER_SYS, &[MOUNT_SYS]);
|
||||||
dispatch_builder.add(controller::Sys, CONTROLLER_SYS, &[AGENT_SYS, MOUNT_SYS]);
|
|
||||||
dispatch_builder.add(character_behavior::Sys, CHARACTER_BEHAVIOR_SYS, &[
|
dispatch_builder.add(character_behavior::Sys, CHARACTER_BEHAVIOR_SYS, &[
|
||||||
CONTROLLER_SYS,
|
CONTROLLER_SYS,
|
||||||
]);
|
]);
|
||||||
|
@ -38,10 +38,11 @@ serde_json = "1.0.50"
|
|||||||
rand = { version = "0.8", features = ["small_rng"] }
|
rand = { version = "0.8", features = ["small_rng"] }
|
||||||
chrono = "0.4.9"
|
chrono = "0.4.9"
|
||||||
hashbrown = { version = "0.9", features = ["rayon", "serde", "nightly"] }
|
hashbrown = { version = "0.9", features = ["rayon", "serde", "nightly"] }
|
||||||
|
rayon = "1.5"
|
||||||
crossbeam-channel = "0.5"
|
crossbeam-channel = "0.5"
|
||||||
prometheus = { version = "0.11", default-features = false}
|
prometheus = { version = "0.11", default-features = false}
|
||||||
tiny_http = "0.7.0"
|
tiny_http = "0.7.0"
|
||||||
portpicker = { git = "https://github.com/xMAC94x/portpicker-rs" }
|
portpicker = { git = "https://github.com/xMAC94x/portpicker-rs", rev = "df6b37872f3586ac3b21d08b56c8ec7cd92fb172" }
|
||||||
authc = { git = "https://gitlab.com/veloren/auth.git", rev = "bffb5181a35c19ddfd33ee0b4aedba741aafb68d" }
|
authc = { git = "https://gitlab.com/veloren/auth.git", rev = "bffb5181a35c19ddfd33ee0b4aedba741aafb68d" }
|
||||||
libsqlite3-sys = { version = "0.18", features = ["bundled"] }
|
libsqlite3-sys = { version = "0.18", features = ["bundled"] }
|
||||||
diesel = { version = "1.4.3", features = ["sqlite"] }
|
diesel = { version = "1.4.3", features = ["sqlite"] }
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
#![deny(unsafe_code)]
|
#![deny(unsafe_code)]
|
||||||
#![allow(clippy::option_map_unit_fn)]
|
#![allow(clippy::option_map_unit_fn)]
|
||||||
#![deny(clippy::clone_on_ref_ptr)]
|
#![deny(clippy::clone_on_ref_ptr)]
|
||||||
#![feature(bool_to_option, drain_filter, option_unwrap_none, option_zip)]
|
#![feature(
|
||||||
|
label_break_value,
|
||||||
|
bool_to_option,
|
||||||
|
drain_filter,
|
||||||
|
option_unwrap_none,
|
||||||
|
option_zip
|
||||||
|
)]
|
||||||
#![cfg_attr(not(feature = "worldgen"), feature(const_panic))]
|
#![cfg_attr(not(feature = "worldgen"), feature(const_panic))]
|
||||||
|
|
||||||
pub mod alias_validator;
|
pub mod alias_validator;
|
||||||
@ -195,6 +201,7 @@ impl Server {
|
|||||||
state.ecs_mut().insert(sys::WaypointTimer::default());
|
state.ecs_mut().insert(sys::WaypointTimer::default());
|
||||||
state.ecs_mut().insert(sys::InviteTimeoutTimer::default());
|
state.ecs_mut().insert(sys::InviteTimeoutTimer::default());
|
||||||
state.ecs_mut().insert(sys::PersistenceTimer::default());
|
state.ecs_mut().insert(sys::PersistenceTimer::default());
|
||||||
|
state.ecs_mut().insert(sys::AgentTimer::default());
|
||||||
|
|
||||||
// System schedulers to control execution of systems
|
// System schedulers to control execution of systems
|
||||||
state
|
state
|
||||||
@ -500,6 +507,7 @@ impl Server {
|
|||||||
sys::msg::character_screen::Sys.run_now(&self.state.ecs());
|
sys::msg::character_screen::Sys.run_now(&self.state.ecs());
|
||||||
sys::msg::in_game::Sys.run_now(&self.state.ecs());
|
sys::msg::in_game::Sys.run_now(&self.state.ecs());
|
||||||
sys::msg::ping::Sys.run_now(&self.state.ecs());
|
sys::msg::ping::Sys.run_now(&self.state.ecs());
|
||||||
|
sys::agent::Sys.run_now(&self.state.ecs());
|
||||||
|
|
||||||
let before_state_tick = Instant::now();
|
let before_state_tick = Instant::now();
|
||||||
|
|
||||||
@ -689,6 +697,7 @@ impl Server {
|
|||||||
|
|
||||||
// 8) Update Metrics
|
// 8) Update Metrics
|
||||||
// Get system timing info
|
// Get system timing info
|
||||||
|
let agent_nanos = self.state.ecs().read_resource::<sys::AgentTimer>().nanos as i64;
|
||||||
let entity_sync_nanos = self
|
let entity_sync_nanos = self
|
||||||
.state
|
.state
|
||||||
.ecs()
|
.ecs()
|
||||||
@ -726,7 +735,7 @@ impl Server {
|
|||||||
.read_resource::<sys::PersistenceTimer>()
|
.read_resource::<sys::PersistenceTimer>()
|
||||||
.nanos as i64;
|
.nanos as i64;
|
||||||
let total_sys_ran_in_dispatcher_nanos =
|
let total_sys_ran_in_dispatcher_nanos =
|
||||||
terrain_nanos + waypoint_nanos + invite_timeout_nanos;
|
terrain_nanos + waypoint_nanos + invite_timeout_nanos + stats_persistence_nanos;
|
||||||
|
|
||||||
// Report timing info
|
// Report timing info
|
||||||
self.tick_metrics
|
self.tick_metrics
|
||||||
@ -796,6 +805,10 @@ impl Server {
|
|||||||
.tick_time
|
.tick_time
|
||||||
.with_label_values(&["persistence:stats"])
|
.with_label_values(&["persistence:stats"])
|
||||||
.set(stats_persistence_nanos);
|
.set(stats_persistence_nanos);
|
||||||
|
self.tick_metrics
|
||||||
|
.tick_time
|
||||||
|
.with_label_values(&["agent"])
|
||||||
|
.set(agent_nanos);
|
||||||
|
|
||||||
//detailed state metrics
|
//detailed state metrics
|
||||||
{
|
{
|
||||||
@ -813,8 +826,7 @@ impl Server {
|
|||||||
let projectile_ns = res.projectile_ns.load(Ordering::Relaxed);
|
let projectile_ns = res.projectile_ns.load(Ordering::Relaxed);
|
||||||
let melee_ns = res.melee_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(&[sys::AGENT_SYS]).inc_by(agent_ns);
|
||||||
.inc_by(agent_ns);
|
|
||||||
c.with_label_values(&[common_sys::MOUNT_SYS])
|
c.with_label_values(&[common_sys::MOUNT_SYS])
|
||||||
.inc_by(mount_ns);
|
.inc_by(mount_ns);
|
||||||
c.with_label_values(&[common_sys::CONTROLLER_SYS])
|
c.with_label_values(&[common_sys::CONTROLLER_SYS])
|
||||||
@ -831,7 +843,7 @@ impl Server {
|
|||||||
|
|
||||||
const NANOSEC_PER_SEC: f64 = Duration::from_secs(1).as_nanos() as f64;
|
const NANOSEC_PER_SEC: f64 = Duration::from_secs(1).as_nanos() as f64;
|
||||||
let h = &self.state_tick_metrics.state_tick_time_hist;
|
let h = &self.state_tick_metrics.state_tick_time_hist;
|
||||||
h.with_label_values(&[common_sys::AGENT_SYS])
|
h.with_label_values(&[sys::AGENT_SYS])
|
||||||
.observe(agent_ns as f64 / NANOSEC_PER_SEC);
|
.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);
|
.observe(mount_ns as f64 / NANOSEC_PER_SEC);
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use super::SysTimer;
|
||||||
use common::{
|
use common::{
|
||||||
comp::{
|
comp::{
|
||||||
self,
|
self,
|
||||||
@ -48,6 +49,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
Read<'a, Time>,
|
Read<'a, Time>,
|
||||||
Read<'a, DeltaTime>,
|
Read<'a, DeltaTime>,
|
||||||
Read<'a, group::GroupManager>,
|
Read<'a, group::GroupManager>,
|
||||||
|
Write<'a, SysTimer<Self>>,
|
||||||
),
|
),
|
||||||
ReadExpect<'a, SysMetrics>,
|
ReadExpect<'a, SysMetrics>,
|
||||||
Write<'a, EventBus<ServerEvent>>,
|
Write<'a, EventBus<ServerEvent>>,
|
||||||
@ -79,7 +81,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
fn run(
|
fn run(
|
||||||
&mut self,
|
&mut self,
|
||||||
(
|
(
|
||||||
(uid_allocator, time, dt, group_manager),
|
(uid_allocator, time, dt, group_manager, mut sys_timer),
|
||||||
sys_metrics,
|
sys_metrics,
|
||||||
event_bus,
|
event_bus,
|
||||||
entities,
|
entities,
|
||||||
@ -108,6 +110,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
) {
|
) {
|
||||||
let start_time = std::time::Instant::now();
|
let start_time = std::time::Instant::now();
|
||||||
span!(_guard, "run", "agent::Sys::run");
|
span!(_guard, "run", "agent::Sys::run");
|
||||||
|
sys_timer.start();
|
||||||
|
|
||||||
(
|
(
|
||||||
&entities,
|
&entities,
|
||||||
@ -1595,6 +1598,8 @@ impl<'a> System<'a> for Sys {
|
|||||||
start_time.elapsed().as_nanos() as u64,
|
start_time.elapsed().as_nanos() as u64,
|
||||||
std::sync::atomic::Ordering::Relaxed,
|
std::sync::atomic::Ordering::Relaxed,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
sys_timer.end();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,3 +1,4 @@
|
|||||||
|
pub mod agent;
|
||||||
pub mod entity_sync;
|
pub mod entity_sync;
|
||||||
pub mod invite_timeout;
|
pub mod invite_timeout;
|
||||||
pub mod msg;
|
pub mod msg;
|
||||||
@ -29,6 +30,7 @@ pub type WaypointTimer = SysTimer<waypoint::Sys>;
|
|||||||
pub type InviteTimeoutTimer = SysTimer<invite_timeout::Sys>;
|
pub type InviteTimeoutTimer = SysTimer<invite_timeout::Sys>;
|
||||||
pub type PersistenceTimer = SysTimer<persistence::Sys>;
|
pub type PersistenceTimer = SysTimer<persistence::Sys>;
|
||||||
pub type PersistenceScheduler = SysScheduler<persistence::Sys>;
|
pub type PersistenceScheduler = SysScheduler<persistence::Sys>;
|
||||||
|
pub type AgentTimer = SysTimer<agent::Sys>;
|
||||||
|
|
||||||
// System names
|
// System names
|
||||||
// Note: commented names may be useful in the future
|
// Note: commented names may be useful in the future
|
||||||
@ -41,6 +43,7 @@ const WAYPOINT_SYS: &str = "server_waypoint_sys";
|
|||||||
const INVITE_TIMEOUT_SYS: &str = "server_invite_timeout_sys";
|
const INVITE_TIMEOUT_SYS: &str = "server_invite_timeout_sys";
|
||||||
const PERSISTENCE_SYS: &str = "server_persistence_sys";
|
const PERSISTENCE_SYS: &str = "server_persistence_sys";
|
||||||
const OBJECT_SYS: &str = "server_object_sys";
|
const OBJECT_SYS: &str = "server_object_sys";
|
||||||
|
pub const AGENT_SYS: &str = "agent_sys";
|
||||||
|
|
||||||
pub fn add_server_systems(dispatch_builder: &mut DispatcherBuilder) {
|
pub fn add_server_systems(dispatch_builder: &mut DispatcherBuilder) {
|
||||||
dispatch_builder.add(terrain::Sys, TERRAIN_SYS, &[]);
|
dispatch_builder.add(terrain::Sys, TERRAIN_SYS, &[]);
|
||||||
|
Loading…
Reference in New Issue
Block a user