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 ///
9 /// `get_id` is public because tests/entity/fn.rs, tests/pool/fn.rs reads this field from
10 /// outside this crate. `get_mut` / `set` stay crate-internal.
11 #[get_mut(pub(crate))]
12 #[get(type(copy))]
13 #[set(pub(crate))]
14 pub id: u64,
15 /// The human-readable name of this entity.
16 ///
17 /// `get_name` is public because tests/entity/fn.rs, tests/pool/fn.rs, tests/remaining/fn.rs reads this field from
18 /// outside this crate. `get_mut` / `set` stay crate-internal.
19 #[get_mut(pub(crate))]
20 #[set(pub(crate))]
21 pub name: String,
22 /// The world-space transform (position, rotation, scale).
23 ///
24 /// `get_transform` is public because tests/entity/fn.rs, tests/pool/fn.rs reads this field from
25 /// outside this crate. `get_mut` / `set` stay crate-internal.
26 #[get_mut(pub(crate))]
27 #[get(type(copy))]
28 #[set(pub(crate))]
29 pub transform: Transform2D,
30 /// Whether this entity is active and should receive updates.
31 ///
32 /// `get_active` / `set_active` are public because tests/entity/fn.rs, tests/pool/fn.rs reads this field from
33 /// outside this crate. `get_mut` / `set` stay crate-internal.
34 #[get_mut(pub(crate))]
35 #[get(type(copy))]
36 pub active: bool,
37 /// The list of components attached to this entity.
38 ///
39 /// `get_components` is public because tests/entity/fn.rs, tests/pool/fn.rs reads this field from
40 /// outside this crate. `get_mut` / `set` stay crate-internal.
41 #[get_mut(pub(crate))]
42 #[set(pub(crate))]
43 pub components: Vec<ComponentRc>,
44 /// Optional tags for grouping and querying entities.
45 ///
46 /// `get_tags` is public because tests/entity/fn.rs, tests/pool/fn.rs reads this field from
47 /// outside this crate. `get_mut` / `set` stay crate-internal.
48 #[get_mut(pub(crate))]
49 #[set(pub(crate))]
50 pub tags: Vec<String>,
51}
52
53/// A publish-subscribe event bus for decoupled inter-entity communication.
54///
55/// Entities and game systems can subscribe to named event channels and
56/// emit events that are dispatched to all registered handlers.
57#[derive(Clone, Data, New)]
58pub struct EventBus {
59 /// The map from event name to the list of registered handler closures.
60 #[get_mut(pub(crate))]
61 #[new(skip)]
62 #[get(pub(crate))]
63 #[set(pub(crate))]
64 pub(crate) handlers: EventHandlers,
65}