summaryrefslogtreecommitdiff
path: root/ecs/src/lib.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-08-01 16:11:15 +0200
committerHampusM <hampus@hampusmat.com>2024-08-02 15:34:54 +0200
commitfd42ca5a25f8bab3ea66252f8bc0db02604f70dd (patch)
tree6d384b5f462e2699342372f6b56791fc4607e9c6 /ecs/src/lib.rs
parent70c7d745f918dd23343599963a619539f4f880cb (diff)
feat(ecs): add relationships
Diffstat (limited to 'ecs/src/lib.rs')
-rw-r--r--ecs/src/lib.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/ecs/src/lib.rs b/ecs/src/lib.rs
index 741b555..b920b48 100644
--- a/ecs/src/lib.rs
+++ b/ecs/src/lib.rs
@@ -12,6 +12,7 @@ use std::vec::Drain;
use crate::actions::Action;
use crate::component::storage::Storage as ComponentStorage;
use crate::component::{Component, Id as ComponentId, Sequence as ComponentSequence};
+use crate::entity::Uid as EntityUid;
use crate::event::{Event, Id as EventId, Ids, Sequence as EventSequence};
use crate::extension::{Collector as ExtensionCollector, Extension};
use crate::lock::Lock;
@@ -22,10 +23,12 @@ use crate::type_name::TypeName;
pub mod actions;
pub mod component;
+pub mod entity;
pub mod event;
pub mod extension;
pub mod lock;
pub mod query;
+pub mod relationship;
pub mod sole;
pub mod system;
pub mod tuple;
@@ -57,15 +60,18 @@ impl World
///
/// # Panics
/// Will panic if mutable internal lock cannot be acquired.
- pub fn create_entity<Comps>(&mut self, components: Comps)
+ pub fn create_entity<Comps>(&mut self, components: Comps) -> EntityUid
where
Comps: ComponentSequence,
{
- self.data
+ let (_, entity_uid) = self
+ .data
.component_storage
.write_nonblock()
.expect("Failed to acquire read-write component storage lock")
.push_entity(components.into_vec());
+
+ entity_uid
}
/// Adds a globally shared singleton value.