summaryrefslogtreecommitdiff
path: root/ecs/src/system/stateful.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ecs/src/system/stateful.rs')
-rw-r--r--ecs/src/system/stateful.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/ecs/src/system/stateful.rs b/ecs/src/system/stateful.rs
index 80ac346..54f6979 100644
--- a/ecs/src/system/stateful.rs
+++ b/ecs/src/system/stateful.rs
@@ -1,13 +1,12 @@
-use std::any::{Any, TypeId};
+use std::any::{type_name, Any, TypeId};
use std::panic::{RefUnwindSafe, UnwindSafe};
use hashbrown::HashMap;
use seq_macro::seq;
-use crate::component::Component;
+use crate::component::{Component, HandleMut as ComponentHandleMut};
use crate::lock::Lock;
use crate::system::{
- ComponentRefMut,
Into as IntoSystem,
Param,
ParamWithInputFilter,
@@ -26,7 +25,7 @@ use crate::World;
pub struct Stateful<Func>
{
func: Func,
- local_components: HashMap<Uid, Lock<Box<dyn Component>>>,
+ local_components: HashMap<Uid, Lock<Box<dyn Any>>>,
}
macro_rules! impl_system {
@@ -110,14 +109,14 @@ macro_rules! impl_system {
fn get_local_component_mut<LocalComponent: Component>(
&self,
- ) -> Option<ComponentRefMut<LocalComponent>>
+ ) -> Option<ComponentHandleMut<LocalComponent>>
{
let local_component = self.local_components
.get(&LocalComponent::id())?
.write_nonblock()
.expect("Failed to aquire read-write local component lock");
- Some(ComponentRefMut::new(local_component))
+ Some(ComponentHandleMut::new(local_component))
}
fn set_local_component<LocalComponent: Component>(
@@ -128,7 +127,10 @@ macro_rules! impl_system {
self.local_components
.insert(
LocalComponent::id(),
- Lock::new(Box::new(local_component))
+ Lock::new(
+ Box::new(local_component),
+ type_name::<LocalComponent>()
+ )
);
}
}