change Name from VSystem to System

This commit is contained in:
Marcel Märtens 2021-03-08 12:13:59 +01:00
parent 989d130692
commit f353f14703
39 changed files with 118 additions and 121 deletions

View File

@ -61,6 +61,7 @@ pub mod spiral;
#[cfg(not(target_arch = "wasm32"))]
pub mod states;
#[cfg(not(target_arch = "wasm32"))] pub mod store;
pub mod system;
#[cfg(not(target_arch = "wasm32"))]
pub mod terrain;
#[cfg(not(target_arch = "wasm32"))] pub mod time;
@ -71,7 +72,6 @@ pub mod uid;
#[cfg(not(target_arch = "wasm32"))] pub mod vol;
#[cfg(not(target_arch = "wasm32"))]
pub mod volumes;
pub mod vsystem;
pub use combat::DamageSource;
#[cfg(not(target_arch = "wasm32"))]

View File

@ -1,4 +1,4 @@
use crate::vsystem::CpuTimeline;
use crate::system::CpuTimeline;
use std::{collections::HashMap, sync::Mutex};
#[derive(Default)]

View File

@ -1,5 +1,5 @@
use crate::metrics::SysMetrics;
use specs::{ReadExpect, RunNow, System};
use specs::{ReadExpect, RunNow};
use std::{collections::HashMap, time::Instant};
/// measuring the level of threads a unit of code ran on. Use Rayon when it ran
@ -32,7 +32,7 @@ pub enum Origin {
#[derive(Default, Debug, Clone)]
pub struct CpuTimeline {
///
/// measurements for a System
/// - The first entry will always be ParMode::Single, as when the
/// System::run is executed, we run
/// single threaded until we start a Rayon::ParIter or similar
@ -71,7 +71,7 @@ impl CpuTimeline {
}
/// Start a new measurement. par will be covering the parallelisation AFTER
/// this statement, till the next / end of the VSystem.
/// this statement, till the next / end of the System.
pub fn measure(&mut self, par: ParMode) { self.measures.push((Instant::now(), par)); }
fn end(&mut self) { self.measures.push((Instant::now(), ParMode::None)); }
@ -191,17 +191,17 @@ pub fn gen_stats(
///
/// ```
/// use specs::Read;
/// pub use veloren_common::vsystem::{Origin, ParMode, Phase, VJob, VSystem};
/// pub use veloren_common::system::{Job, Origin, ParMode, Phase, System};
/// # use std::time::Duration;
/// pub struct Sys;
/// impl<'a> VSystem<'a> for Sys {
/// impl<'a> System<'a> for Sys {
/// type SystemData = (Read<'a, ()>, Read<'a, ()>);
///
/// const NAME: &'static str = "example";
/// const ORIGIN: Origin = Origin::Frontend("voxygen");
/// const PHASE: Phase = Phase::Create;
///
/// fn run(job: &mut VJob<Self>, (_read, _read2): Self::SystemData) {
/// fn run(job: &mut Job<Self>, (_read, _read2): Self::SystemData) {
/// std::thread::sleep(Duration::from_millis(100));
/// job.cpu_stats.measure(ParMode::Rayon);
/// std::thread::sleep(Duration::from_millis(500));
@ -210,33 +210,33 @@ pub fn gen_stats(
/// }
/// }
/// ```
pub trait VSystem<'a> {
pub trait System<'a> {
const NAME: &'static str;
const PHASE: Phase;
const ORIGIN: Origin;
type SystemData: specs::SystemData<'a>;
fn run(job: &mut VJob<Self>, data: Self::SystemData);
fn run(job: &mut Job<Self>, data: Self::SystemData);
fn sys_name() -> String { format!("{}_sys", Self::NAME) }
}
pub fn dispatch<'a, 'b, T>(builder: &mut specs::DispatcherBuilder<'a, 'b>, dep: &[&str])
where
T: for<'c> VSystem<'c> + Send + 'a + Default,
T: for<'c> System<'c> + Send + 'a + Default,
{
builder.add(VJob::<T>::default(), &T::sys_name(), dep);
builder.add(Job::<T>::default(), &T::sys_name(), dep);
}
pub fn run_now<'a, 'b, T>(world: &'a specs::World)
where
T: for<'c> VSystem<'c> + Send + 'a + Default,
T: for<'c> System<'c> + Send + 'a + Default,
{
VJob::<T>::default().run_now(world);
Job::<T>::default().run_now(world);
}
/// This Struct will wrap the System in order to avoid the can only impl trait
/// for local defined structs error It also contains the cpu measurements
pub struct VJob<T>
pub struct Job<T>
where
T: ?Sized,
{
@ -244,9 +244,9 @@ where
pub cpu_stats: CpuTimeline,
}
impl<'a, T> System<'a> for VJob<T>
impl<'a, T> specs::System<'a> for Job<T>
where
T: VSystem<'a>,
T: System<'a>,
{
type SystemData = (T::SystemData, ReadExpect<'a, SysMetrics>);
@ -263,9 +263,9 @@ where
}
}
impl<'a, T> Default for VJob<T>
impl<'a, T> Default for Job<T>
where
T: VSystem<'a> + Default,
T: System<'a> + Default,
{
fn default() -> Self {
Self {

View File

@ -7,8 +7,8 @@ use common::{
},
event::{EventBus, ServerEvent},
resources::DeltaTime,
system::{Job, Origin, Phase, System},
uid::UidAllocator,
vsystem::{Origin, Phase, VJob, VSystem},
};
use specs::{
saveload::MarkerAllocator, shred::ResourceId, Entities, Join, Read, ReadStorage, SystemData,
@ -30,7 +30,7 @@ pub struct ReadData<'a> {
#[derive(Default)]
pub struct Sys;
impl<'a> VSystem<'a> for Sys {
impl<'a> System<'a> for Sys {
type SystemData = (
ReadData<'a>,
WriteStorage<'a, Auras>,
@ -41,7 +41,7 @@ impl<'a> VSystem<'a> for Sys {
const ORIGIN: Origin = Origin::Common;
const PHASE: Phase = Phase::Create;
fn run(_job: &mut VJob<Self>, (read_data, mut auras, mut buffs): Self::SystemData) {
fn run(_job: &mut Job<Self>, (read_data, mut auras, mut buffs): Self::SystemData) {
let mut server_emitter = read_data.server_bus.emitter();
let dt = read_data.dt.0;

View File

@ -6,8 +6,8 @@ use common::{
},
event::{EventBus, ServerEvent},
resources::{DeltaTime, Time},
system::{Job, Origin, Phase, System},
uid::{Uid, UidAllocator},
vsystem::{Origin, Phase, VJob, VSystem},
GroupTarget,
};
use specs::{
@ -40,7 +40,7 @@ pub struct ReadData<'a> {
/// This system is responsible for handling beams that heal or do damage
#[derive(Default)]
pub struct Sys;
impl<'a> VSystem<'a> for Sys {
impl<'a> System<'a> for Sys {
type SystemData = (
ReadData<'a>,
WriteStorage<'a, BeamSegment>,
@ -51,7 +51,7 @@ impl<'a> VSystem<'a> for Sys {
const ORIGIN: Origin = Origin::Common;
const PHASE: Phase = Phase::Create;
fn run(_job: &mut VJob<Self>, (read_data, mut beam_segments, mut beams): Self::SystemData) {
fn run(_job: &mut Job<Self>, (read_data, mut beam_segments, mut beams): Self::SystemData) {
let mut server_emitter = read_data.server_bus.emitter();
let time = read_data.time.0;

View File

@ -5,7 +5,7 @@ use common::{
},
event::{EventBus, ServerEvent},
resources::DeltaTime,
vsystem::{Origin, Phase, VJob, VSystem},
system::{Job, Origin, Phase, System},
Damage, DamageSource,
};
use specs::{
@ -23,7 +23,7 @@ pub struct ReadData<'a> {
#[derive(Default)]
pub struct Sys;
impl<'a> VSystem<'a> for Sys {
impl<'a> System<'a> for Sys {
type SystemData = (
ReadData<'a>,
WriteStorage<'a, Health>,
@ -37,7 +37,7 @@ impl<'a> VSystem<'a> for Sys {
const PHASE: Phase = Phase::Create;
fn run(
_job: &mut VJob<Self>,
_job: &mut Job<Self>,
(read_data, mut healths, mut energies, mut buffs, mut stats): Self::SystemData,
) {
let mut server_emitter = read_data.server_bus.emitter();

View File

@ -18,8 +18,8 @@ use common::{
self,
behavior::{CharacterBehavior, JoinData, JoinStruct},
},
system::{Job, Origin, Phase, System},
uid::Uid,
vsystem::{Origin, Phase, VJob, VSystem},
};
use std::time::Duration;
@ -73,7 +73,7 @@ pub struct ReadData<'a> {
#[derive(Default)]
pub struct Sys;
impl<'a> VSystem<'a> for Sys {
impl<'a> System<'a> for Sys {
#[allow(clippy::type_complexity)]
type SystemData = (
ReadData<'a>,
@ -93,7 +93,7 @@ impl<'a> VSystem<'a> for Sys {
#[allow(clippy::while_let_on_iterator)] // TODO: Pending review in #587
fn run(
_job: &mut VJob<Self>,
_job: &mut Job<Self>,
(
read_data,
mut character_states,

View File

@ -1,8 +1,8 @@
use common::{
comp::{BuffChange, ControlEvent, Controller},
event::{EventBus, ServerEvent},
system::{Job, Origin, Phase, System},
uid::UidAllocator,
vsystem::{Origin, Phase, VJob, VSystem},
};
use specs::{
saveload::{Marker, MarkerAllocator},
@ -21,14 +21,14 @@ pub struct ReadData<'a> {
#[derive(Default)]
pub struct Sys;
impl<'a> VSystem<'a> for Sys {
impl<'a> System<'a> for Sys {
type SystemData = (ReadData<'a>, WriteStorage<'a, Controller>);
const NAME: &'static str = "controller";
const ORIGIN: Origin = Origin::Common;
const PHASE: Phase = Phase::Create;
fn run(_job: &mut VJob<Self>, (read_data, mut controllers): Self::SystemData) {
fn run(_job: &mut Job<Self>, (read_data, mut controllers): Self::SystemData) {
let mut server_emitter = read_data.server_bus.emitter();
for (entity, controller) in (&read_data.entities, &mut controllers).join() {

View File

@ -15,7 +15,7 @@ pub mod state;
mod stats;
// External
use common::vsystem::{dispatch, VSystem};
use common::system::{dispatch, System};
use specs::DispatcherBuilder;
pub fn add_local_systems(dispatch_builder: &mut DispatcherBuilder) {

View File

@ -2,9 +2,9 @@ use common::{
combat::{AttackerInfo, TargetInfo},
comp::{Body, CharacterState, Energy, Group, Health, Inventory, Melee, Ori, Pos, Scale, Stats},
event::{EventBus, ServerEvent},
system::{Job, Origin, Phase, System},
uid::Uid,
util::Dir,
vsystem::{Origin, Phase, VJob, VSystem},
GroupTarget,
};
use specs::{
@ -34,14 +34,14 @@ pub struct ReadData<'a> {
#[derive(Default)]
pub struct Sys;
impl<'a> VSystem<'a> for Sys {
impl<'a> System<'a> for Sys {
type SystemData = (ReadData<'a>, WriteStorage<'a, Melee>);
const NAME: &'static str = "melee";
const ORIGIN: Origin = Origin::Common;
const PHASE: Phase = Phase::Create;
fn run(_job: &mut VJob<Self>, (read_data, mut melee_attacks): Self::SystemData) {
fn run(_job: &mut Job<Self>, (read_data, mut melee_attacks): Self::SystemData) {
let mut server_emitter = read_data.server_bus.emitter();
// Attacks
for (attacker, uid, pos, ori, melee_attack, body) in (

View File

@ -1,7 +1,7 @@
use common::{
comp::{Controller, MountState, Mounting, Ori, Pos, Vel},
system::{Job, Origin, Phase, System},
uid::UidAllocator,
vsystem::{Origin, Phase, VJob, VSystem},
};
use specs::{
saveload::{Marker, MarkerAllocator},
@ -12,7 +12,7 @@ use vek::*;
/// This system is responsible for controlling mounts
#[derive(Default)]
pub struct Sys;
impl<'a> VSystem<'a> for Sys {
impl<'a> System<'a> for Sys {
#[allow(clippy::type_complexity)]
type SystemData = (
Read<'a, UidAllocator>,
@ -30,7 +30,7 @@ impl<'a> VSystem<'a> for Sys {
const PHASE: Phase = Phase::Create;
fn run(
_job: &mut VJob<Self>,
_job: &mut Job<Self>,
(
uid_allocator,
entities,

View File

@ -8,10 +8,10 @@ use common::{
metrics::PhysicsMetrics,
resources::DeltaTime,
span,
system::{Job, Origin, ParMode, Phase, System},
terrain::{Block, TerrainGrid},
uid::Uid,
vol::ReadVol,
vsystem::{Origin, ParMode, Phase, VJob, VSystem},
};
use rayon::iter::ParallelIterator;
use specs::{Entities, Join, ParJoin, Read, ReadExpect, ReadStorage, WriteExpect, WriteStorage};
@ -63,7 +63,7 @@ fn calc_z_limit(
#[derive(Default)]
pub struct Sys;
impl<'a> VSystem<'a> for Sys {
impl<'a> System<'a> for Sys {
#[allow(clippy::type_complexity)]
type SystemData = (
Entities<'a>,
@ -96,7 +96,7 @@ impl<'a> VSystem<'a> for Sys {
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587
#[allow(clippy::blocks_in_if_conditions)] // TODO: Pending review in #587
fn run(
job: &mut VJob<Self>,
job: &mut Job<Self>,
(
entities,
uids,

View File

@ -6,9 +6,9 @@ use common::{
},
event::{EventBus, ServerEvent},
resources::DeltaTime,
system::{Job, Origin, Phase, System},
uid::UidAllocator,
util::Dir,
vsystem::{Origin, Phase, VJob, VSystem},
GroupTarget,
};
use specs::{
@ -35,7 +35,7 @@ pub struct ReadData<'a> {
/// This system is responsible for handling projectile effect triggers
#[derive(Default)]
pub struct Sys;
impl<'a> VSystem<'a> for Sys {
impl<'a> System<'a> for Sys {
type SystemData = (
ReadData<'a>,
WriteStorage<'a, Ori>,
@ -46,10 +46,7 @@ impl<'a> VSystem<'a> for Sys {
const ORIGIN: Origin = Origin::Common;
const PHASE: Phase = Phase::Create;
fn run(
_job: &mut VJob<Self>,
(read_data, mut orientations, mut projectiles): Self::SystemData,
) {
fn run(_job: &mut Job<Self>, (read_data, mut orientations, mut projectiles): Self::SystemData) {
let mut server_emitter = read_data.server_bus.emitter();
// Attacks

View File

@ -6,9 +6,9 @@ use common::{
},
event::{EventBus, ServerEvent},
resources::{DeltaTime, Time},
system::{Job, Origin, Phase, System},
uid::{Uid, UidAllocator},
util::Dir,
vsystem::{Origin, Phase, VJob, VSystem},
GroupTarget,
};
use specs::{
@ -42,7 +42,7 @@ pub struct ReadData<'a> {
/// attacking
#[derive(Default)]
pub struct Sys;
impl<'a> VSystem<'a> for Sys {
impl<'a> System<'a> for Sys {
type SystemData = (
ReadData<'a>,
WriteStorage<'a, Shockwave>,
@ -54,7 +54,7 @@ impl<'a> VSystem<'a> for Sys {
const PHASE: Phase = Phase::Create;
fn run(
_job: &mut VJob<Self>,
_job: &mut Job<Self>,
(read_data, mut shockwaves, mut shockwave_hit_lists): Self::SystemData,
) {
let mut server_emitter = read_data.server_bus.emitter();

View File

@ -7,8 +7,8 @@ use common::{
event::{EventBus, ServerEvent},
outcome::Outcome,
resources::{DeltaTime, Time},
system::{Job, Origin, Phase, System},
uid::Uid,
vsystem::{Origin, Phase, VJob, VSystem},
};
use hashbrown::HashSet;
use specs::{
@ -35,7 +35,7 @@ pub struct ReadData<'a> {
/// This system kills players, levels them up, and regenerates energy.
#[derive(Default)]
pub struct Sys;
impl<'a> VSystem<'a> for Sys {
impl<'a> System<'a> for Sys {
#[allow(clippy::type_complexity)]
type SystemData = (
ReadData<'a>,
@ -52,7 +52,7 @@ impl<'a> VSystem<'a> for Sys {
const PHASE: Phase = Phase::Create;
fn run(
_job: &mut VJob<Self>,
_job: &mut Job<Self>,
(
read_data,
mut stats,

View File

@ -64,9 +64,9 @@ use common::{
recipe::default_recipe_book,
resources::TimeOfDay,
rtsim::RtSimEntity,
system::run_now,
terrain::TerrainChunkSize,
vol::{ReadVol, RectVolSize},
vsystem::run_now,
};
use common_net::{
msg::{

View File

@ -1,13 +1,13 @@
use super::*;
use common::{
event::{EventBus, ServerEvent},
vsystem::{Origin, Phase, VJob, VSystem},
system::{Job, Origin, Phase, System},
};
use specs::{Read, WriteExpect};
#[derive(Default)]
pub struct Sys;
impl<'a> VSystem<'a> for Sys {
impl<'a> System<'a> for Sys {
#[allow(clippy::type_complexity)]
type SystemData = (Read<'a, EventBus<ServerEvent>>, WriteExpect<'a, RtSim>);
@ -15,7 +15,7 @@ impl<'a> VSystem<'a> for Sys {
const ORIGIN: Origin = Origin::Server;
const PHASE: Phase = Phase::Create;
fn run(_job: &mut VJob<Self>, (_server_event_bus, mut rtsim): Self::SystemData) {
fn run(_job: &mut Job<Self>, (_server_event_bus, mut rtsim): Self::SystemData) {
for _chunk in std::mem::take(&mut rtsim.chunks.chunks_to_load) {
// TODO
}

View File

@ -10,9 +10,9 @@ use self::{chunks::Chunks, entity::Entity};
use common::{
comp,
rtsim::{RtSimController, RtSimEntity, RtSimId},
system::{dispatch, System},
terrain::TerrainChunk,
vol::RectRasterableVol,
vsystem::{dispatch, VSystem},
};
use common_sys::state::State;
use rand::prelude::*;

View File

@ -6,8 +6,8 @@ use common::{
comp::inventory::loadout_builder::LoadoutBuilder,
event::{EventBus, ServerEvent},
resources::DeltaTime,
system::{Job, Origin, Phase, System},
terrain::TerrainGrid,
vsystem::{Origin, Phase, VJob, VSystem},
};
use specs::{Join, Read, ReadExpect, ReadStorage, WriteExpect, WriteStorage};
use std::sync::Arc;
@ -16,7 +16,7 @@ const ENTITY_TICK_PERIOD: u64 = 30;
#[derive(Default)]
pub struct Sys;
impl<'a> VSystem<'a> for Sys {
impl<'a> System<'a> for Sys {
#[allow(clippy::type_complexity)]
type SystemData = (
Read<'a, DeltaTime>,
@ -35,7 +35,7 @@ impl<'a> VSystem<'a> for Sys {
const PHASE: Phase = Phase::Create;
fn run(
_job: &mut VJob<Self>,
_job: &mut Job<Self>,
(
dt,
server_event_bus,

View File

@ -2,14 +2,14 @@ use super::*;
use common::{
comp::Pos,
event::{EventBus, ServerEvent},
system::{Job, Origin, Phase, System},
terrain::TerrainGrid,
vsystem::{Origin, Phase, VJob, VSystem},
};
use specs::{Entities, Read, ReadExpect, ReadStorage, WriteExpect};
#[derive(Default)]
pub struct Sys;
impl<'a> VSystem<'a> for Sys {
impl<'a> System<'a> for Sys {
#[allow(clippy::type_complexity)]
type SystemData = (
Read<'a, EventBus<ServerEvent>>,
@ -25,7 +25,7 @@ impl<'a> VSystem<'a> for Sys {
const PHASE: Phase = Phase::Create;
fn run(
_job: &mut VJob<Self>,
_job: &mut Job<Self>,
(
_server_event_bus,
mut rtsim,

View File

@ -17,12 +17,12 @@ use common::{
event::{Emitter, EventBus, ServerEvent},
path::TraversalConfig,
resources::{DeltaTime, TimeOfDay},
system::{Job, Origin, Phase, System},
terrain::{Block, TerrainGrid},
time::DayPeriod,
uid::{Uid, UidAllocator},
util::Dir,
vol::ReadVol,
vsystem::{Origin, Phase, VJob, VSystem},
};
use rand::{thread_rng, Rng};
use rayon::iter::ParallelIterator;
@ -98,7 +98,7 @@ const AVG_FOLLOW_DIST: f32 = 6.0;
/// This system will allow NPCs to modify their controller
#[derive(Default)]
pub struct Sys;
impl<'a> VSystem<'a> for Sys {
impl<'a> System<'a> for Sys {
#[allow(clippy::type_complexity)]
type SystemData = (
ReadData<'a>,
@ -113,7 +113,7 @@ impl<'a> VSystem<'a> for Sys {
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587
fn run(
_job: &mut VJob<Self>,
_job: &mut Job<Self>,
(read_data, event_bus, mut agents, mut controllers): Self::SystemData,
) {
(

View File

@ -9,10 +9,10 @@ use common::{
outcome::Outcome,
region::{Event as RegionEvent, RegionMap},
resources::TimeOfDay,
system::{Job, Origin, Phase, System},
terrain::TerrainChunkSize,
uid::Uid,
vol::RectVolSize,
vsystem::{Origin, Phase, VJob, VSystem},
};
use common_net::{msg::ServerGeneral, sync::CompSyncPackage};
use specs::{
@ -23,7 +23,7 @@ use vek::*;
/// This system will send physics updates to the client
#[derive(Default)]
pub struct Sys;
impl<'a> VSystem<'a> for Sys {
impl<'a> System<'a> for Sys {
#[allow(clippy::type_complexity)]
type SystemData = (
Entities<'a>,
@ -54,7 +54,7 @@ impl<'a> VSystem<'a> for Sys {
const PHASE: Phase = Phase::Create;
fn run(
_job: &mut VJob<Self>,
_job: &mut Job<Self>,
(
entities,
tick,

View File

@ -1,8 +1,8 @@
use crate::client::Client;
use common::{
comp::invite::{Invite, PendingInvites},
system::{Job, Origin, Phase, System},
uid::Uid,
vsystem::{Origin, Phase, VJob, VSystem},
};
use common_net::msg::{InviteAnswer, ServerGeneral};
use specs::{Entities, Join, ReadStorage, WriteStorage};
@ -10,7 +10,7 @@ use specs::{Entities, Join, ReadStorage, WriteStorage};
/// This system removes timed out invites
#[derive(Default)]
pub struct Sys;
impl<'a> VSystem<'a> for Sys {
impl<'a> System<'a> for Sys {
#[allow(clippy::type_complexity)]
type SystemData = (
Entities<'a>,
@ -25,7 +25,7 @@ impl<'a> VSystem<'a> for Sys {
const PHASE: Phase = Phase::Create;
fn run(
_job: &mut VJob<Self>,
_job: &mut Job<Self>,
(entities, mut invites, mut pending_invites, clients, uids): Self::SystemData,
) {
let now = std::time::Instant::now();

View File

@ -5,8 +5,8 @@ use crate::{
use common::{
metrics::SysMetrics,
resources::TimeOfDay,
system::{Job, Origin, Phase, System},
terrain::TerrainGrid,
vsystem::{Origin, Phase, VJob, VSystem},
};
use specs::{Entities, Join, Read, ReadExpect};
use std::time::Instant;
@ -14,7 +14,7 @@ use std::time::Instant;
/// This system exports metrics
#[derive(Default)]
pub struct Sys;
impl<'a> VSystem<'a> for Sys {
impl<'a> System<'a> for Sys {
#[allow(clippy::type_complexity)]
type SystemData = (
Option<Entities<'a>>,
@ -34,7 +34,7 @@ impl<'a> VSystem<'a> for Sys {
const PHASE: Phase = Phase::Apply;
fn run(
_job: &mut VJob<Self>,
_job: &mut Job<Self>,
(
entities,
tick,
@ -56,7 +56,7 @@ impl<'a> VSystem<'a> for Sys {
//this system hasn't run yet
state.remove(Self::NAME);
for (name, stat) in common::vsystem::gen_stats(&state, tick_start.0, 8, 8) {
for (name, stat) in common::system::gen_stats(&state, tick_start.0, 8, 8) {
export_ecs
.system_start_time
.with_label_values(&[&name])

View File

@ -11,7 +11,7 @@ pub mod terrain;
pub mod terrain_sync;
pub mod waypoint;
use common::vsystem::{dispatch, run_now};
use common::system::{dispatch, run_now};
use specs::DispatcherBuilder;
use std::{
marker::PhantomData,

View File

@ -5,8 +5,8 @@ use crate::{
use common::{
comp::{ChatType, Player, UnresolvedChatMsg},
event::{EventBus, ServerEvent},
system::{Job, Origin, Phase, System},
uid::Uid,
vsystem::{Origin, Phase, VJob, VSystem},
};
use common_net::msg::{ClientGeneral, ServerGeneral};
use specs::{Entities, Join, Read, ReadExpect, ReadStorage};
@ -122,7 +122,7 @@ impl Sys {
/// This system will handle new messages from clients
#[derive(Default)]
pub struct Sys;
impl<'a> VSystem<'a> for Sys {
impl<'a> System<'a> for Sys {
#[allow(clippy::type_complexity)]
type SystemData = (
Entities<'a>,
@ -141,7 +141,7 @@ impl<'a> VSystem<'a> for Sys {
const PHASE: Phase = Phase::Create;
fn run(
_job: &mut VJob<Self>,
_job: &mut Job<Self>,
(
entities,
server_event_bus,

View File

@ -3,8 +3,8 @@ use common::{
comp::{ChatMode, Player, UnresolvedChatMsg},
event::{EventBus, ServerEvent},
resources::Time,
system::{Job, Origin, Phase, System},
uid::Uid,
vsystem::{Origin, Phase, VJob, VSystem},
};
use common_net::msg::{
validate_chat_msg, ChatMsgValidationError, ClientGeneral, MAX_BYTES_CHAT_MSG,
@ -66,7 +66,7 @@ impl Sys {
/// This system will handle new messages from clients
#[derive(Default)]
pub struct Sys;
impl<'a> VSystem<'a> for Sys {
impl<'a> System<'a> for Sys {
#[allow(clippy::type_complexity)]
type SystemData = (
Entities<'a>,
@ -84,7 +84,7 @@ impl<'a> VSystem<'a> for Sys {
const PHASE: Phase = Phase::Create;
fn run(
_job: &mut VJob<Self>,
_job: &mut Job<Self>,
(
entities,
server_event_bus,

View File

@ -2,9 +2,9 @@ use crate::{client::Client, metrics::NetworkRequestMetrics, presence::Presence,
use common::{
comp::{CanBuild, ControlEvent, Controller, ForceUpdate, Health, Ori, Pos, Stats, Vel},
event::{EventBus, ServerEvent},
system::{Job, Origin, Phase, System},
terrain::{TerrainChunkSize, TerrainGrid},
vol::{ReadVol, RectVolSize},
vsystem::{Origin, Phase, VJob, VSystem},
};
use common_net::msg::{ClientGeneral, PresenceKind, ServerGeneral};
use common_sys::state::BlockChange;
@ -166,7 +166,7 @@ impl Sys {
/// This system will handle new messages from clients
#[derive(Default)]
pub struct Sys;
impl<'a> VSystem<'a> for Sys {
impl<'a> System<'a> for Sys {
#[allow(clippy::type_complexity)]
type SystemData = (
Entities<'a>,
@ -192,7 +192,7 @@ impl<'a> VSystem<'a> for Sys {
const PHASE: Phase = Phase::Create;
fn run(
_job: &mut VJob<Self>,
_job: &mut Job<Self>,
(
entities,
server_event_bus,

View File

@ -2,7 +2,7 @@ use crate::{client::Client, metrics::PlayerMetrics, Settings};
use common::{
event::{EventBus, ServerEvent},
resources::Time,
vsystem::{Origin, Phase, VJob, VSystem},
system::{Job, Origin, Phase, System},
};
use common_net::msg::PingMsg;
use specs::{Entities, Join, Read, ReadExpect, ReadStorage};
@ -22,7 +22,7 @@ impl Sys {
/// This system will handle new messages from clients
#[derive(Default)]
pub struct Sys;
impl<'a> VSystem<'a> for Sys {
impl<'a> System<'a> for Sys {
#[allow(clippy::type_complexity)]
type SystemData = (
Entities<'a>,
@ -38,7 +38,7 @@ impl<'a> VSystem<'a> for Sys {
const PHASE: Phase = Phase::Create;
fn run(
_job: &mut VJob<Self>,
_job: &mut Job<Self>,
(entities, server_event_bus, time, player_metrics, clients, settings): Self::SystemData,
) {
let mut server_emitter = server_event_bus.emitter();

View File

@ -3,7 +3,7 @@ use common::{
effect::Effect,
event::{EventBus, ServerEvent},
resources::DeltaTime,
vsystem::{Origin, Phase, VJob, VSystem},
system::{Job, Origin, Phase, System},
Damage, DamageSource, Explosion, RadiusEffect,
};
use specs::{Entities, Join, Read, ReadStorage, WriteStorage};
@ -11,7 +11,7 @@ use specs::{Entities, Join, Read, ReadStorage, WriteStorage};
/// This system is responsible for handling misc object behaviours
#[derive(Default)]
pub struct Sys;
impl<'a> VSystem<'a> for Sys {
impl<'a> System<'a> for Sys {
#[allow(clippy::type_complexity)]
type SystemData = (
Entities<'a>,
@ -28,7 +28,7 @@ impl<'a> VSystem<'a> for Sys {
const PHASE: Phase = Phase::Create;
fn run(
_job: &mut VJob<Self>,
_job: &mut Job<Self>,
(entities, _dt, server_bus, positions, velocities, physics_states, mut objects): Self::SystemData,
) {
let mut server_emitter = server_bus.emitter();

View File

@ -1,7 +1,7 @@
use crate::{persistence::character_updater, presence::Presence, sys::SysScheduler};
use common::{
comp::{Inventory, Stats, Waypoint},
vsystem::{Origin, Phase, VJob, VSystem},
system::{Job, Origin, Phase, System},
};
use common_net::msg::PresenceKind;
use specs::{Join, ReadExpect, ReadStorage, Write};
@ -9,7 +9,7 @@ use specs::{Join, ReadExpect, ReadStorage, Write};
#[derive(Default)]
pub struct Sys;
impl<'a> VSystem<'a> for Sys {
impl<'a> System<'a> for Sys {
#[allow(clippy::type_complexity)]
type SystemData = (
ReadStorage<'a, Presence>,
@ -25,7 +25,7 @@ impl<'a> VSystem<'a> for Sys {
const PHASE: Phase = Phase::Create;
fn run(
_job: &mut VJob<Self>,
_job: &mut Job<Self>,
(
presences,
player_stats,

View File

@ -4,8 +4,8 @@ use common::{
Gravity, Group, Health, Inventory, Item, LightEmitter, Mass, MountState, Mounting, Ori,
Player, Poise, Pos, Scale, Shockwave, Stats, Sticky, Vel,
},
system::{Job, Origin, Phase, System},
uid::Uid,
vsystem::{Origin, Phase, VJob, VSystem},
};
use common_net::{
msg::EcsCompPacket,
@ -23,14 +23,14 @@ use vek::*;
/// modification
#[derive(Default)]
pub struct Sys;
impl<'a> VSystem<'a> for Sys {
impl<'a> System<'a> for Sys {
type SystemData = (TrackedComps<'a>, WriteTrackers<'a>);
const NAME: &'static str = "sentinel";
const ORIGIN: Origin = Origin::Server;
const PHASE: Phase = Phase::Create;
fn run(_job: &mut VJob<Self>, (comps, mut trackers): Self::SystemData) {
fn run(_job: &mut Job<Self>, (comps, mut trackers): Self::SystemData) {
record_changes(&comps, &mut trackers);
}
}

View File

@ -6,10 +6,10 @@ use crate::{
use common::{
comp::{Ori, Pos, Vel},
region::{region_in_vd, regions_in_vd, Event as RegionEvent, RegionMap},
system::{Job, Origin, Phase, System},
terrain::TerrainChunkSize,
uid::Uid,
vol::RectVolSize,
vsystem::{Origin, Phase, VJob, VSystem},
};
use common_net::msg::ServerGeneral;
use specs::{
@ -21,7 +21,7 @@ use vek::*;
/// This system will update region subscriptions based on client positions
#[derive(Default)]
pub struct Sys;
impl<'a> VSystem<'a> for Sys {
impl<'a> System<'a> for Sys {
#[allow(clippy::type_complexity)]
type SystemData = (
Entities<'a>,
@ -43,7 +43,7 @@ impl<'a> VSystem<'a> for Sys {
#[allow(clippy::blocks_in_if_conditions)] // TODO: Pending review in #587
fn run(
_job: &mut VJob<Self>,
_job: &mut Job<Self>,
(
entities,
region_map,

View File

@ -6,8 +6,8 @@ use common::{
event::{EventBus, ServerEvent},
generation::get_npc_name,
npc::NPC_NAMES,
system::{Job, Origin, Phase, System},
terrain::TerrainGrid,
vsystem::{Origin, Phase, VJob, VSystem},
LoadoutBuilder, SkillSetBuilder,
};
use common_net::msg::ServerGeneral;
@ -24,7 +24,7 @@ use vek::*;
/// 4. Removes chunks outside the range of players
#[derive(Default)]
pub struct Sys;
impl<'a> VSystem<'a> for Sys {
impl<'a> System<'a> for Sys {
#[allow(clippy::type_complexity)] // TODO: Pending review in #587
type SystemData = (
Read<'a, EventBus<ServerEvent>>,
@ -43,7 +43,7 @@ impl<'a> VSystem<'a> for Sys {
const PHASE: Phase = Phase::Create;
fn run(
_job: &mut VJob<Self>,
_job: &mut Job<Self>,
(
server_event_bus,
tick,

View File

@ -1,8 +1,8 @@
use crate::{client::Client, presence::Presence};
use common::{
comp::Pos,
system::{Job, Origin, Phase, System},
terrain::TerrainGrid,
vsystem::{Origin, Phase, VJob, VSystem},
};
use common_net::msg::ServerGeneral;
use common_sys::state::TerrainChanges;
@ -12,7 +12,7 @@ use specs::{Join, Read, ReadExpect, ReadStorage};
/// chunks
#[derive(Default)]
pub struct Sys;
impl<'a> VSystem<'a> for Sys {
impl<'a> System<'a> for Sys {
#[allow(clippy::type_complexity)]
type SystemData = (
ReadExpect<'a, TerrainGrid>,
@ -27,7 +27,7 @@ impl<'a> VSystem<'a> for Sys {
const PHASE: Phase = Phase::Create;
fn run(
_job: &mut VJob<Self>,
_job: &mut Job<Self>,
(terrain, terrain_changes, positions, presences, clients): Self::SystemData,
) {
// Sync changed chunks

View File

@ -2,7 +2,7 @@ use crate::client::Client;
use common::{
comp::{Player, Pos, Waypoint, WaypointArea},
resources::Time,
vsystem::{Origin, Phase, VJob, VSystem},
system::{Job, Origin, Phase, System},
};
use common_net::msg::{Notification, ServerGeneral};
use specs::{Entities, Join, Read, ReadStorage, WriteStorage};
@ -14,7 +14,7 @@ const NOTIFY_TIME: f64 = 10.0;
/// TODO: Make this faster by only considering local waypoints
#[derive(Default)]
pub struct Sys;
impl<'a> VSystem<'a> for Sys {
impl<'a> System<'a> for Sys {
#[allow(clippy::type_complexity)]
type SystemData = (
Entities<'a>,
@ -31,7 +31,7 @@ impl<'a> VSystem<'a> for Sys {
const PHASE: Phase = Phase::Create;
fn run(
_job: &mut VJob<Self>,
_job: &mut Job<Self>,
(
entities,
positions,

View File

@ -1,7 +1,7 @@
pub mod floater;
mod interpolation;
use common::vsystem::{dispatch, VSystem};
use common::system::{dispatch, System};
use specs::DispatcherBuilder;
pub fn add_local_systems(dispatch_builder: &mut DispatcherBuilder) {

View File

@ -5,8 +5,8 @@ use crate::ecs::{
use common::{
comp::{Health, HealthSource, Pos},
resources::DeltaTime,
system::{Job, Origin, Phase, System},
uid::Uid,
vsystem::{Origin, Phase, VJob, VSystem},
};
use specs::{Entities, Join, Read, ReadExpect, ReadStorage, WriteStorage};
@ -17,7 +17,7 @@ pub const HP_ACCUMULATETIME: f32 = 1.0;
#[derive(Default)]
pub struct Sys;
impl<'a> VSystem<'a> for Sys {
impl<'a> System<'a> for Sys {
#[allow(clippy::type_complexity)]
type SystemData = (
Entities<'a>,
@ -35,7 +35,7 @@ impl<'a> VSystem<'a> for Sys {
#[allow(clippy::blocks_in_if_conditions)] // TODO: Pending review in #587
fn run(
_job: &mut VJob<Self>,
_job: &mut Job<Self>,
(entities, my_entity, dt, uids, pos, healths, mut hp_floater_lists): Self::SystemData,
) {
// Add hp floater lists to all entities with health and a position

View File

@ -2,7 +2,7 @@ use crate::ecs::comp::Interpolated;
use common::{
comp::{object, Body, Ori, Pos, Vel},
resources::DeltaTime,
vsystem::{Origin, Phase, VJob, VSystem},
system::{Job, Origin, Phase, System},
};
use specs::{Entities, Join, Read, ReadStorage, WriteStorage};
use tracing::warn;
@ -11,7 +11,7 @@ use vek::*;
/// This system will allow NPCs to modify their controller
#[derive(Default)]
pub struct Sys;
impl<'a> VSystem<'a> for Sys {
impl<'a> System<'a> for Sys {
#[allow(clippy::type_complexity)]
type SystemData = (
Entities<'a>,
@ -28,7 +28,7 @@ impl<'a> VSystem<'a> for Sys {
const PHASE: Phase = Phase::Create;
fn run(
_job: &mut VJob<Self>,
_job: &mut Job<Self>,
(entities, dt, positions, orientations, velocities, bodies, mut interpolated): Self::SystemData,
) {
// Update interpolated positions and orientations