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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
use crate::component::{
Component, ComponentDescriptor, ComponentInitFuture, DisabilityFlags, InspectableComponent,
SerializedComponent,
};
use crate::physics::PhysicsState;
use dropbear_engine::graphics::SharedGraphicsContext;
use serde::{Deserialize, Serialize};
use std::sync::Arc;
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct SerializedEntityStatus {
#[serde(default)]
pub hidden: bool,
#[serde(default)]
pub disabled: bool,
}
#[typetag::serde]
impl SerializedComponent for SerializedEntityStatus {}
#[derive(Debug, Clone)]
pub struct EntityStatus {
pub hidden: bool,
pub disabled: bool,
}
impl Component for EntityStatus {
type SerializedForm = SerializedEntityStatus;
type RequiredComponentTypes = (Self,);
fn descriptor() -> ComponentDescriptor {
ComponentDescriptor {
fqtn: "eucalyptus_core::entity_status::EntityStatus".to_string(),
type_name: "EntityStatus".to_string(),
category: None,
description: Some("Controls entity visibility and activation".to_string()),
disabled_flags: DisabilityFlags::Never,
internal: true,
}
}
fn init(
ser: &'_ Self::SerializedForm,
_graphics: Arc<SharedGraphicsContext>,
) -> ComponentInitFuture<'_, Self> {
let hidden = ser.hidden;
let disabled = ser.disabled;
Box::pin(async move { Ok((Self { hidden, disabled },)) })
}
fn update_component(
&mut self,
_world: &hecs::World,
_physics: &mut PhysicsState,
_entity: hecs::Entity,
_dt: f32,
_graphics: Arc<SharedGraphicsContext>,
) {
}
fn save(&self, _world: &hecs::World, _entity: hecs::Entity) -> Box<dyn SerializedComponent> {
Box::new(SerializedEntityStatus {
hidden: self.hidden,
disabled: self.disabled,
})
}
}
impl InspectableComponent for EntityStatus {
fn inspect(
&mut self,
_world: &hecs::World,
_entity: hecs::Entity,
_ui: &mut egui::Ui,
_graphics: Arc<SharedGraphicsContext>,
) {
}
}