diff options
Diffstat (limited to 'ecs/src')
-rw-r--r-- | ecs/src/actions.rs | 6 | ||||
-rw-r--r-- | ecs/src/component/local.rs | 4 | ||||
-rw-r--r-- | ecs/src/lib.rs | 4 | ||||
-rw-r--r-- | ecs/src/query.rs | 6 | ||||
-rw-r--r-- | ecs/src/sole.rs | 6 | ||||
-rw-r--r-- | ecs/src/system.rs | 28 | ||||
-rw-r--r-- | ecs/src/system/stateful.rs | 18 |
7 files changed, 36 insertions, 36 deletions
diff --git a/ecs/src/actions.rs b/ecs/src/actions.rs index 4cbd515..2ee5518 100644 --- a/ecs/src/actions.rs +++ b/ecs/src/actions.rs @@ -5,7 +5,7 @@ use std::sync::{Arc, Weak}; use crate::component::{Component, Sequence as ComponentSequence}; use crate::lock::{Lock, WriteGuard}; use crate::system::{NoInitParamFlag, Param as SystemParam, System}; -use crate::{ActionQueue, WorldData}; +use crate::{ActionQueue, World}; /// Used to to queue up actions for a [`World`] to perform. #[derive(Debug)] @@ -66,10 +66,10 @@ unsafe impl<'world> SystemParam<'world> for Actions<'world> fn new<SystemImpl>( _system: &'world impl System<'world, SystemImpl>, - world_data: &'world WorldData, + world: &'world World, ) -> Self { - Self::new(&world_data.action_queue) + Self::new(&world.data.action_queue) } fn is_compatible<Other: SystemParam<'world>>() -> bool diff --git a/ecs/src/component/local.rs b/ecs/src/component/local.rs index 89c3139..a365efe 100644 --- a/ecs/src/component/local.rs +++ b/ecs/src/component/local.rs @@ -3,7 +3,7 @@ use std::ops::{Deref, DerefMut}; use crate::component::{Component, Id}; use crate::system::{ComponentRefMut, Param as SystemParam, System}; -use crate::WorldData; +use crate::World; /// Holds a component which is local to a single system. #[derive(Debug)] @@ -29,7 +29,7 @@ where fn new<SystemImpl>( system: &'world impl System<'world, SystemImpl>, - _world_data: &'world WorldData, + _world: &'world World, ) -> Self { let local_component = system diff --git a/ecs/src/lib.rs b/ecs/src/lib.rs index 1f745b9..a33d72e 100644 --- a/ecs/src/lib.rs +++ b/ecs/src/lib.rs @@ -210,9 +210,9 @@ impl World for system_index in system_indices { let system = self.systems.get(*system_index).unwrap(); - // SAFETY: The world data lives long enough + // SAFETY: The world lives long enough unsafe { - system.run(&self.data); + system.run(&self); } } } diff --git a/ecs/src/query.rs b/ecs/src/query.rs index 8a63256..79ad292 100644 --- a/ecs/src/query.rs +++ b/ecs/src/query.rs @@ -21,7 +21,7 @@ use crate::system::{ Param as SystemParam, System, }; -use crate::{EntityComponent, WorldData}; +use crate::{EntityComponent, World, WorldData}; pub mod options; @@ -115,10 +115,10 @@ where fn new<SystemImpl>( _system: &'world impl System<'world, SystemImpl>, - world_data: &'world WorldData, + world: &'world World, ) -> Self { - Self::new(&world_data.component_storage) + Self::new(&world.data.component_storage) } fn is_compatible<Other: SystemParam<'world>>() -> bool diff --git a/ecs/src/sole.rs b/ecs/src/sole.rs index 39f65a7..4a4f3af 100644 --- a/ecs/src/sole.rs +++ b/ecs/src/sole.rs @@ -7,7 +7,7 @@ use std::sync::{Arc, Weak}; use crate::lock::{Lock, WriteGuard}; use crate::system::{NoInitParamFlag, Param as SystemParam, System}; use crate::type_name::TypeName; -use crate::WorldData; +use crate::World; /// A type which has a single instance and is shared globally. pub trait Sole: Any + TypeName @@ -104,10 +104,10 @@ where fn new<SystemImpl>( _system: &'world impl System<'world, SystemImpl>, - world_data: &'world WorldData, + world: &'world World, ) -> Self { - let sole = world_data.sole_storage.get::<SoleT>().unwrap_or_else(|| { + let sole = world.data.sole_storage.get::<SoleT>().unwrap_or_else(|| { panic!("Sole {} was not found in world", type_name::<SoleT>()) }); diff --git a/ecs/src/system.rs b/ecs/src/system.rs index 57b0756..aaf09fb 100644 --- a/ecs/src/system.rs +++ b/ecs/src/system.rs @@ -11,7 +11,7 @@ use crate::component::{Component, FromOptional as FromOptionalComponent}; use crate::lock::WriteGuard; use crate::system::util::check_params_are_compatible; use crate::tuple::{ReduceElement as TupleReduceElement, With as TupleWith}; -use crate::WorldData; +use crate::{World, WorldData}; pub mod stateful; @@ -26,7 +26,7 @@ pub trait System<'world, Impl>: 'static fn prepare(&self, world_data: &WorldData); - fn run<'this>(&'this self, world_data: &'world WorldData) + fn run<'this>(&'this self, world: &'world World) where 'this: 'world; @@ -65,7 +65,7 @@ macro_rules! impl_system { )* } - fn run<'this>(&'this self, world_data: &'world WorldData) + fn run<'this>(&'this self, world: &'world World) where 'this: 'world { @@ -76,7 +76,7 @@ macro_rules! impl_system { let func = *self; func(#({ - TParam~I::new(self, world_data) + TParam~I::new(self, world) },)*); } @@ -84,7 +84,7 @@ macro_rules! impl_system { { TypeErased { data: Box::new(self), - run: Box::new(|data, world_data| { + run: Box::new(|data, world| { // SAFETY: The caller of TypeErased::run ensures the lifetime // is correct let data = unsafe { &*std::ptr::from_ref(data) }; @@ -95,11 +95,11 @@ macro_rules! impl_system { // SAFETY: The caller of TypeErased::run ensures the lifetime // is correct - let world_data = unsafe { &*std::ptr::from_ref(world_data) }; + let world = unsafe { &*std::ptr::from_ref(world) }; - me.run(world_data); + me.run(world); }), - prepare: Box::new(|data, world_data| { + prepare: Box::new(|data, world| { // SAFETY: The caller of TypeErased::run ensures the lifetime // is correct let data = unsafe { &*std::ptr::from_ref(data) }; @@ -110,9 +110,9 @@ macro_rules! impl_system { // SAFETY: The caller of TypeErased::run ensures the lifetime // is correct - let world_data = unsafe { &*std::ptr::from_ref(world_data) }; + let world = unsafe { &*std::ptr::from_ref(world) }; - me.prepare(world_data); + me.prepare(world); }), } } @@ -159,12 +159,12 @@ impl TypeErased /// /// # Safety /// `world_data` must live at least as long as the [`World`] the system belongs to. - pub unsafe fn run(&self, world_data: &WorldData) + pub unsafe fn run(&self, world: &World) { // You have to dereference for downcasting to work for some reason let data = &*self.data; - (self.run)(data, world_data); + (self.run)(data, world); } /// Prepares the system. @@ -189,7 +189,7 @@ impl Debug for TypeErased } /// Function in [`TypeErased`] used to run the system. -type TypeErasedRunFn = dyn Fn(&dyn Any, &WorldData) + RefUnwindSafe + UnwindSafe; +type TypeErasedRunFn = dyn Fn(&dyn Any, &World) + RefUnwindSafe + UnwindSafe; /// Function in [`TypeErased`] used to prepare the system. type TypeErasedPrepareFn = dyn Fn(&dyn Any, &WorldData) + RefUnwindSafe + UnwindSafe; @@ -210,7 +210,7 @@ pub unsafe trait Param<'world> fn new<SystemImpl>( system: &'world impl System<'world, SystemImpl>, - world_data: &'world WorldData, + world: &'world World, ) -> Self; fn is_compatible<Other: Param<'world>>() -> bool; diff --git a/ecs/src/system/stateful.rs b/ecs/src/system/stateful.rs index 56c9d4f..26ceaaa 100644 --- a/ecs/src/system/stateful.rs +++ b/ecs/src/system/stateful.rs @@ -21,7 +21,7 @@ use crate::tuple::{ TakeOptionElementResult as TupleTakeOptionElementResult, WithOptionElements as TupleWithOptionElements, }; -use crate::WorldData; +use crate::{World, WorldData}; /// A stateful system. pub struct Stateful<Func> @@ -92,7 +92,7 @@ macro_rules! impl_system { )* } - fn run<'this>(&'this self, world_data: &'world WorldData) + fn run<'this>(&'this self, world: &'world World) where 'this: 'world { @@ -103,7 +103,7 @@ macro_rules! impl_system { let func = self.func; func(#({ - TParam~I::new(self, world_data) + TParam~I::new(self, &world) },)*); } @@ -111,7 +111,7 @@ macro_rules! impl_system { { TypeErased { data: Box::new(self), - run: Box::new(|data, world_data| { + run: Box::new(|data, world| { // SAFETY: The caller of TypeErased::run ensures the lifetime // is correct let data = unsafe { &*std::ptr::from_ref::<dyn Any>(data) }; @@ -120,11 +120,11 @@ macro_rules! impl_system { // SAFETY: The caller of TypeErased::run ensures the lifetime // is correct - let world_data = unsafe { &*std::ptr::from_ref(world_data) }; + let world = unsafe { &*std::ptr::from_ref(world) }; - me.run(world_data); + me.run(world); }), - prepare: Box::new(|data, world_data| { + prepare: Box::new(|data, world| { // SAFETY: The caller of TypeErased::run ensures the lifetime // is correct let data = unsafe { &*std::ptr::from_ref::<dyn Any>(data) }; @@ -133,9 +133,9 @@ macro_rules! impl_system { // SAFETY: The caller of TypeErased::run ensures the lifetime // is correct - let world_data = unsafe { &*std::ptr::from_ref(world_data) }; + let world = unsafe { &*std::ptr::from_ref(world) }; - me.prepare(world_data); + me.prepare(world); }), } } |