summaryrefslogtreecommitdiff
path: root/engine-ecs/src/lib.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2026-08-31 05:34:28 +0200
committerHampusM <hampus@hampusmat.com>2026-08-31 05:34:28 +0200
commit6c0db8d03888edddcd811166b1297ae185f2bfbe (patch)
treecfc27e0849884d6c76476994383b8b57befbd584 /engine-ecs/src/lib.rs
parent3c252d952fb3a639b84f2c0e63157e0d26862f28 (diff)
feat(engine-ecs): add whether component is a sole to component::Info
Diffstat (limited to 'engine-ecs/src/lib.rs')
-rw-r--r--engine-ecs/src/lib.rs49
1 files changed, 25 insertions, 24 deletions
diff --git a/engine-ecs/src/lib.rs b/engine-ecs/src/lib.rs
index 0d7df79..8e8cc69 100644
--- a/engine-ecs/src/lib.rs
+++ b/engine-ecs/src/lib.rs
@@ -1,6 +1,6 @@
#![deny(clippy::all, clippy::pedantic)]
-use std::any::{Any, TypeId};
+use std::any::Any;
use std::borrow::Cow;
use std::fmt::Debug;
use std::hint::cold_path;
@@ -54,7 +54,6 @@ use crate::query::{
TermsBuilderInterface,
MAX_TERM_CNT as QUERY_MAX_TERM_CNT,
};
-use crate::reflection::Type as TypeReflection;
use crate::sole::{Single, Sole};
use crate::system::observer::Observer;
use crate::system::{
@@ -694,22 +693,28 @@ impl World
&component_parts.pair_relation_metadata
{
Self::create_component_info_entity_if_missing(
- comp_id.relation(),
- pair_relation_metadata.name,
- pair_relation_metadata.ty,
- pair_relation_metadata.ty_id,
component_storage,
+ comp_id.relation(),
+ ComponentInfo {
+ type_reflection: pair_relation_metadata.ty,
+ ty_id: pair_relation_metadata.ty_id,
+ name: pair_relation_metadata.name,
+ is_sole: pair_relation_metadata.is_sole,
+ },
);
}
if let Some(pair_target_metadata) = &component_parts.pair_target_metadata
{
Self::create_component_info_entity_if_missing(
- comp_id.target(),
- pair_target_metadata.name,
- pair_target_metadata.ty,
- pair_target_metadata.ty_id,
component_storage,
+ comp_id.target(),
+ ComponentInfo {
+ type_reflection: pair_target_metadata.ty,
+ ty_id: pair_target_metadata.ty_id,
+ name: pair_target_metadata.name,
+ is_sole: pair_target_metadata.is_sole,
+ },
);
}
@@ -717,11 +722,14 @@ impl World
}
Self::create_component_info_entity_if_missing(
- comp_id,
- comp_name,
- component_parts.type_reflection,
- comp_type_id,
component_storage,
+ comp_id,
+ ComponentInfo {
+ type_reflection: component_parts.type_reflection,
+ ty_id: comp_type_id,
+ name: comp_name,
+ is_sole: component_parts.is_sole,
+ },
);
event_submitter.submit_event(
@@ -735,11 +743,9 @@ impl World
}
fn create_component_info_entity_if_missing(
- comp_id: Uid,
- comp_name: &'static str,
- type_reflection: Option<&'static TypeReflection>,
- type_id: TypeId,
component_storage: &mut ComponentStorage,
+ comp_id: Uid,
+ comp_info: ComponentInfo,
)
{
if let Some(comp_ent_archetype) = component_storage.get_entity_archetype(comp_id)
@@ -755,12 +761,7 @@ impl World
}
}
- let comp_info_parts = ComponentInfo {
- type_reflection,
- name: comp_name,
- ty_id: type_id,
- }
- .into_parts();
+ let comp_info_parts = comp_info.into_parts();
match component_storage.add_entity_component(
comp_id,