1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use crate::{
collections::{Arena, IterableMapMut, MapMut},
TypedIndex,
};
#[cfg(feature = "index-u64")]
pub type GenIndexType = crate::IndexU64;
#[cfg(not(feature = "index-u64"))]
pub type GenIndexType = crate::IndexF64;
pub type EntityId<E> = TypedIndex<E, GenIndexType>;
pub trait Entity: Sized {
type Storage: EntityStorage<Self>;
}
pub trait EntityStorage<E: Entity>:
Default + Arena<Key = EntityId<E>, Value = E> + for<'a> IterableMapMut<'a> + 'static
{
}
pub trait Component<E: Entity>: Sized {
type Storage: ComponentStorage<E, Self>;
}
pub trait ComponentStorage<E: Entity, C: Component<E>>:
Default + MapMut<Key = EntityId<E>, Value = C> + for<'a> IterableMapMut<'a> + 'static
{
}
pub type EntityStorageOf<E> = <E as Entity>::Storage;
pub type ComponentStorageOf<E, C> = <C as Component<E>>::Storage;