summaryrefslogtreecommitdiff
path: root/ecs
diff options
context:
space:
mode:
Diffstat (limited to 'ecs')
-rw-r--r--ecs/Cargo.toml1
-rw-r--r--ecs/src/actions.rs15
-rw-r--r--ecs/src/component/local.rs18
-rw-r--r--ecs/src/query.rs49
-rw-r--r--ecs/src/sole.rs24
-rw-r--r--ecs/src/system.rs14
-rw-r--r--ecs/src/system/stateful.rs5
-rw-r--r--ecs/src/system/util.rs16
8 files changed, 2 insertions, 140 deletions
diff --git a/ecs/Cargo.toml b/ecs/Cargo.toml
index 0f86ef7..342f087 100644
--- a/ecs/Cargo.toml
+++ b/ecs/Cargo.toml
@@ -5,7 +5,6 @@ edition = "2021"
[features]
debug = ["dep:tracing"]
-system-param-compat-checks = []
[dependencies]
seq-macro = "0.3.5"
diff --git a/ecs/src/actions.rs b/ecs/src/actions.rs
index 72cc95d..f7b00d3 100644
--- a/ecs/src/actions.rs
+++ b/ecs/src/actions.rs
@@ -1,4 +1,3 @@
-use std::any::Any;
use std::marker::PhantomData;
use std::sync::{Arc, Weak};
@@ -95,18 +94,6 @@ unsafe impl<'world> SystemParam<'world> for Actions<'world>
{
Self::new(&world.data.action_queue)
}
-
- fn is_compatible<Other: SystemParam<'world>>() -> bool
- {
- let other_comparable = Other::get_comparable();
-
- other_comparable.downcast_ref::<Comparable>().is_none()
- }
-
- fn get_comparable() -> Box<dyn Any>
- {
- Box::new(())
- }
}
#[derive(Debug, Clone)]
@@ -157,5 +144,3 @@ pub(crate) enum Action
RemoveComponents(Uid, Vec<ComponentMetadata>),
Stop,
}
-
-struct Comparable;
diff --git a/ecs/src/component/local.rs b/ecs/src/component/local.rs
index 9d32d47..20627bf 100644
--- a/ecs/src/component/local.rs
+++ b/ecs/src/component/local.rs
@@ -1,8 +1,6 @@
-use std::any::Any;
use std::ops::{Deref, DerefMut};
use crate::component::Component;
-use crate::uid::Uid;
use crate::system::{ComponentRefMut, Param as SystemParam, System};
use crate::World;
@@ -39,22 +37,6 @@ where
Self { local_component }
}
-
- fn is_compatible<Other: SystemParam<'world>>() -> bool
- {
- let other_comparable = Other::get_comparable();
-
- let Some(other_id) = other_comparable.downcast_ref::<Uid>() else {
- return true;
- };
-
- LocalComponent::id() != *other_id
- }
-
- fn get_comparable() -> Box<dyn Any>
- {
- Box::new(LocalComponent::id())
- }
}
impl<'world, LocalComponent> Deref for Local<'world, LocalComponent>
diff --git a/ecs/src/query.rs b/ecs/src/query.rs
index 69bb35d..253398d 100644
--- a/ecs/src/query.rs
+++ b/ecs/src/query.rs
@@ -1,5 +1,3 @@
-use std::any::Any;
-use std::collections::HashSet;
use std::iter::{Filter, Flatten, Map};
use std::marker::PhantomData;
@@ -10,11 +8,7 @@ use crate::component::storage::{
EntityIter,
Storage as ComponentStorage,
};
-use crate::component::{
- Component,
- Metadata as ComponentMetadata,
- Sequence as ComponentSequence,
-};
+use crate::component::{Component, Sequence as ComponentSequence};
use crate::lock::{ReadGuard, WriteGuard};
use crate::query::options::Options;
use crate::system::{
@@ -149,24 +143,6 @@ where
{
Self::new(world)
}
-
- fn is_compatible<Other: SystemParam<'world>>() -> bool
- {
- let other_comparable = Other::get_comparable();
-
- let Some(other_query_component_ids) =
- other_comparable.downcast_ref::<QueryComponentIds>()
- else {
- return true;
- };
-
- !other_query_component_ids.contains_component_in::<Comps>()
- }
-
- fn get_comparable() -> Box<dyn Any>
- {
- Box::new(QueryComponentIds { component_ids: Comps::metadata() })
- }
}
type ComponentIterMapFn = for<'a> fn(&'a Archetype) -> EntityIter<'a>;
@@ -259,26 +235,3 @@ fn lock_component_ro(
);
})
}
-
-#[derive(Debug)]
-struct QueryComponentIds
-{
- component_ids: Vec<ComponentMetadata>,
-}
-
-impl QueryComponentIds
-{
- fn contains_component_in<OtherComps>(&self) -> bool
- where
- OtherComps: ComponentSequence,
- {
- let other_ids = OtherComps::metadata()
- .into_iter()
- .map(|component_metadata| component_metadata.id)
- .collect::<HashSet<_>>();
-
- self.component_ids
- .iter()
- .all(|component_metadata| other_ids.contains(&component_metadata.id))
- }
-}
diff --git a/ecs/src/sole.rs b/ecs/src/sole.rs
index 4a4f3af..084a06b 100644
--- a/ecs/src/sole.rs
+++ b/ecs/src/sole.rs
@@ -1,4 +1,4 @@
-use std::any::{type_name, Any, TypeId};
+use std::any::{type_name, Any};
use std::fmt::Debug;
use std::marker::PhantomData;
use std::ops::{Deref, DerefMut};
@@ -113,23 +113,6 @@ where
Self::new(sole)
}
-
- fn is_compatible<Other: SystemParam<'world>>() -> bool
- {
- let other_comparable = Other::get_comparable();
-
- let Some(comparable) = other_comparable.downcast_ref::<Comparable>() else {
- // The other system param is not Single
- return true;
- };
-
- TypeId::of::<SoleT>() != comparable.sole_type_id
- }
-
- fn get_comparable() -> Box<dyn Any>
- {
- Box::new(Comparable { sole_type_id: TypeId::of::<SoleT>() })
- }
}
impl<'world, SoleT> Deref for Single<'world, SoleT>
@@ -201,8 +184,3 @@ where
Single::new(&self.sole)
}
}
-
-struct Comparable
-{
- sole_type_id: TypeId,
-}
diff --git a/ecs/src/system.rs b/ecs/src/system.rs
index afb5aac..046d25b 100644
--- a/ecs/src/system.rs
+++ b/ecs/src/system.rs
@@ -13,14 +13,11 @@ use crate::component::{
FromOptionalMut as FromOptionalMutComponent,
};
use crate::lock::{ReadGuard, WriteGuard};
-use crate::system::util::check_params_are_compatible;
use crate::tuple::{ReduceElement as TupleReduceElement, With as TupleWith};
use crate::World;
pub mod stateful;
-mod util;
-
pub trait System<'world, Impl>: 'static
{
type Input;
@@ -64,10 +61,6 @@ macro_rules! impl_system {
where
'this: 'world
{
- #(
- check_params_are_compatible!(I, TParam~I, $c);
- )*
-
let func = *self;
func(#({
@@ -159,9 +152,6 @@ impl Debug for TypeErased
type TypeErasedRunFn = dyn Fn(&dyn Any, &World) + RefUnwindSafe + UnwindSafe;
/// A parameter to a [`System`].
-///
-/// # Safety
-/// The `is_compatible` function is used for safety so it must be implemented properly.
pub unsafe trait Param<'world>
{
type Input;
@@ -176,10 +166,6 @@ pub unsafe trait Param<'world>
system: &'world impl System<'world, SystemImpl>,
world: &'world World,
) -> Self;
-
- fn is_compatible<Other: Param<'world>>() -> bool;
-
- fn get_comparable() -> Box<dyn Any>;
}
pub struct NoInitParamFlag {}
diff --git a/ecs/src/system/stateful.rs b/ecs/src/system/stateful.rs
index 810a071..536e6ed 100644
--- a/ecs/src/system/stateful.rs
+++ b/ecs/src/system/stateful.rs
@@ -6,7 +6,6 @@ use seq_macro::seq;
use crate::component::Component;
use crate::lock::Lock;
-use crate::system::util::check_params_are_compatible;
use crate::system::{
ComponentRefMut,
Into as IntoSystem,
@@ -90,10 +89,6 @@ macro_rules! impl_system {
where
'this: 'world
{
- #(
- check_params_are_compatible!(I, TParam~I, $c);
- )*
-
let func = self.func;
func(#({
diff --git a/ecs/src/system/util.rs b/ecs/src/system/util.rs
deleted file mode 100644
index 54fff0e..0000000
--- a/ecs/src/system/util.rs
+++ /dev/null
@@ -1,16 +0,0 @@
-macro_rules! check_params_are_compatible {
- ($excluded_index: tt, $param: ident, $cnt: tt) => {
- #[cfg(feature = "system-param-compat-checks")]
- {
- seq!(N in 0..$cnt {
- if N != $excluded_index {
- if !$param::is_compatible::<TParam~N>() {
- panic!("Atleast two parameters are incompatible");
- }
- }
- });
- }
- };
-}
-
-pub(crate) use check_params_are_compatible;