Skip to main content

euv_engine/entity/
struct.rs

1use crate::*;
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    pub(crate) id: u64,
10    /// The human-readable name of this entity.
11    pub(crate) name: String,
12    /// The world-space transform (position, rotation, scale).
13    #[get(type(copy))]
14    #[get_mut(pub(crate))]
15    pub(crate) transform: Transform2D,
16    /// Whether this entity is active and should receive updates.
17    #[get(type(copy))]
18    pub(crate) active: bool,
19    /// The list of components attached to this entity.
20    #[get_mut(pub(crate))]
21    pub(crate) components: Vec<ComponentRc>,
22    /// Optional tags for grouping and querying entities.
23    #[get_mut(pub(crate))]
24    pub(crate) tags: Vec<String>,
25}
26
27/// A publish-subscribe event bus for decoupled inter-entity communication.
28///
29/// Entities and game systems can subscribe to named event channels and
30/// emit events that are dispatched to all registered handlers.
31#[derive(Clone, Data, New)]
32pub struct EventBus {
33    /// The map from event name to the list of registered handler closures.
34    #[get_mut(pub(crate))]
35    #[new(skip)]
36    pub(crate) handlers: EventHandlers,
37}