summaryrefslogtreecommitdiff
path: root/ecs/src/component.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ecs/src/component.rs')
-rw-r--r--ecs/src/component.rs18
1 files changed, 13 insertions, 5 deletions
diff --git a/ecs/src/component.rs b/ecs/src/component.rs
index 1fde5b4..bf19c9e 100644
--- a/ecs/src/component.rs
+++ b/ecs/src/component.rs
@@ -12,6 +12,7 @@ use crate::lock::{ReadGuard, WriteGuard};
use crate::system::{ComponentRef, ComponentRefMut, Input as SystemInput};
use crate::type_name::TypeName;
use crate::uid::Uid;
+use crate::util::Array;
use crate::{EntityComponent, World};
pub mod local;
@@ -170,9 +171,12 @@ pub trait Sequence
where
Self: 'component;
+ /// The number of components in this component sequence.
+ const COUNT: usize;
+
fn into_vec(self) -> Vec<Box<dyn Component>>;
- fn metadata() -> Vec<Metadata>;
+ fn metadata() -> impl Array<Metadata>;
fn added_event_ids() -> Vec<Uid>;
@@ -271,14 +275,16 @@ macro_rules! inner {
type Refs<'component> = (#(Comp~I::Ref<'component>,)*)
where Self: 'component;
+ const COUNT: usize = $c + 1;
+
fn into_vec(self) -> Vec<Box<dyn Component>>
{
Vec::from_iter([#(Box::new(self.I) as Box<dyn Component>,)*])
}
- fn metadata() -> Vec<Metadata>
+ fn metadata() -> impl Array<Metadata>
{
- vec![
+ [
#(
Metadata {
id: Comp~I::id(),
@@ -357,14 +363,16 @@ impl Sequence for ()
type MutRefs<'component> = ();
type Refs<'component> = ();
+ const COUNT: usize = 0;
+
fn into_vec(self) -> Vec<Box<dyn Component>>
{
Vec::new()
}
- fn metadata() -> Vec<Metadata>
+ fn metadata() -> impl Array<Metadata>
{
- Vec::new()
+ []
}
fn added_event_ids() -> Vec<Uid>