summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine-ecs/src/lib.rs7
-rw-r--r--engine-ecs/src/sole.rs7
2 files changed, 12 insertions, 2 deletions
diff --git a/engine-ecs/src/lib.rs b/engine-ecs/src/lib.rs
index da221cb..f9e8143 100644
--- a/engine-ecs/src/lib.rs
+++ b/engine-ecs/src/lib.rs
@@ -253,6 +253,7 @@ impl World
[
sole.into_parts(),
EntityName { name: name.into() }.into_parts(),
+ crate::sole::Is.into_parts(),
],
&ComponentAddingFlags { allow_soles: true },
);
@@ -682,7 +683,11 @@ impl World
Self::add_entity_components(
sole_parts.id,
- [sole_parts, EntityName { name: name.into() }.into_parts()],
+ [
+ sole_parts,
+ EntityName { name: name.into() }.into_parts(),
+ crate::sole::Is.into_parts(),
+ ],
&mut self.data.component_storage,
&EventSubmitter::new(&self.data.new_events),
&ComponentAddingFlags { allow_soles: true },
diff --git a/engine-ecs/src/sole.rs b/engine-ecs/src/sole.rs
index 9168414..cf5283b 100644
--- a/engine-ecs/src/sole.rs
+++ b/engine-ecs/src/sole.rs
@@ -7,7 +7,7 @@ use crate::component::{
WithAssociatedId as ComponentWithAssociatedId,
};
use crate::system::{Metadata as SystemMetadata, Param as SystemParam};
-use crate::World;
+use crate::{Component, World};
/// A component which has a single instance in the [`World`].
pub trait Sole: Any + IntoComponentParts + ComponentWithAssociatedId
@@ -20,6 +20,11 @@ pub trait Sole: Any + IntoComponentParts + ComponentWithAssociatedId
fn name(&self) -> &'static str;
}
+/// Marker component for the entities of soles.
+#[derive(Debug, Component)]
+#[non_exhaustive]
+pub struct Is;
+
/// Holds a reference to a singleton component.
#[derive(Debug)]
pub struct Single<'world, SoleT: Sole>