euv_engine/entity/struct.rs
1use super::*;
2
3/// The fundamental entity in the engine, combining a transform with
4/// a collection of behavior-defining components.
5#[derive(Clone, Data, New)]
6pub struct Entity {
7 /// The unique identifier of this entity.
8 #[get(type(copy))]
9 #[get_mut(pub(crate))]
10 pub(crate) id: u64,
11 /// The human-readable name of this entity.
12 #[get_mut(pub(crate))]
13 #[set(pub(crate))]
14 pub(crate) name: String,
15 /// The world-space transform (position, rotation, scale).
16 #[get(type(copy))]
17 #[get_mut(pub(crate))]
18 #[set(pub(crate))]
19 pub(crate) transform: Transform2D,
20 /// Whether this entity is active and should receive updates.
21 #[get(type(copy))]
22 #[get_mut(pub(crate))]
23 pub(crate) active: bool,
24 /// The list of components attached to this entity.
25 #[get_mut(pub(crate))]
26 #[set(pub(crate))]
27 pub(crate) components: Vec<ComponentRc>,
28 /// Optional tags for grouping and querying entities.
29 #[get_mut(pub(crate))]
30 #[set(pub(crate))]
31 pub(crate) tags: Vec<String>,
32}
33
34/// A publish-subscribe event bus for decoupled inter-entity communication.
35///
36/// Entities and game systems can subscribe to named event channels and
37/// emit events that are dispatched to all registered handlers.
38#[derive(Clone, Data, New)]
39pub struct EventBus {
40 /// The map from event name to the list of registered handler closures.
41 #[get_mut(pub(crate))]
42 #[new(skip)]
43 #[get(pub(crate))]
44 #[set(pub(crate))]
45 pub(crate) handlers: EventHandlers,
46}