intuicio_framework_ecs/
lib.rs1pub mod actor;
2pub mod archetype;
3pub mod bundle;
4pub mod commands;
5pub mod entity;
6pub mod multiverse;
7pub mod observer;
8pub mod prefab;
9pub mod processor;
10pub mod query;
11pub mod resources;
12pub mod scheduler;
13pub mod systems;
14pub mod universe;
15pub mod world;
16
17pub mod prelude {
18 pub use crate::{
19 commands::*, entity::*, query::*, resources::*, scheduler::*, systems::*, universe::*,
20 world::*, Component, ComponentRef, ComponentRefMut,
21 };
22}
23
24use crate::archetype::ArchetypeEntityColumnAccess;
25use std::ops::{Deref, DerefMut};
26
27pub trait Component: Send + Sync + 'static {}
28
29impl<T: Send + Sync + 'static> Component for T {}
30
31pub struct ComponentRef<'a, const LOCKING: bool, T: Send + Sync + 'static> {
32 inner: ArchetypeEntityColumnAccess<'a, LOCKING, T>,
33}
34
35impl<const LOCKING: bool, T: Send + Sync + 'static> Deref for ComponentRef<'_, LOCKING, T> {
36 type Target = T;
37
38 fn deref(&self) -> &Self::Target {
39 self.inner.read().unwrap()
40 }
41}
42
43pub struct ComponentRefMut<'a, const LOCKING: bool, T: Send + Sync + 'static> {
44 inner: ArchetypeEntityColumnAccess<'a, LOCKING, T>,
45}
46
47impl<const LOCKING: bool, T: Send + Sync + 'static> Deref for ComponentRefMut<'_, LOCKING, T> {
48 type Target = T;
49
50 fn deref(&self) -> &Self::Target {
51 self.inner.read().unwrap()
52 }
53}
54
55impl<const LOCKING: bool, T: Send + Sync + 'static> DerefMut for ComponentRefMut<'_, LOCKING, T> {
56 fn deref_mut(&mut self) -> &mut Self::Target {
57 self.inner.write().unwrap()
58 }
59}