mittens_engine/engine/ecs/component/
mirror.rs1use crate::engine::ecs::ComponentId;
2use crate::engine::ecs::component::Component;
3
4#[derive(Debug, Clone)]
10pub struct MirrorComponent {
11 pub quality: i32,
13 component: Option<ComponentId>,
14}
15
16impl MirrorComponent {
17 pub fn new(quality: i32) -> Self {
18 Self {
19 quality: quality.clamp(64, 2048),
20 component: None,
21 }
22 }
23}
24
25impl Default for MirrorComponent {
26 fn default() -> Self {
27 Self::new(512)
28 }
29}
30
31impl Component for MirrorComponent {
32 fn name(&self) -> &'static str {
33 "mirror"
34 }
35
36 fn set_id(&mut self, component: ComponentId) {
37 self.component = Some(component);
38 }
39
40 fn as_any(&self) -> &dyn std::any::Any {
41 self
42 }
43
44 fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
45 self
46 }
47
48 fn to_mms_ast(
49 &self,
50 _world: &crate::engine::ecs::World,
51 ) -> crate::scripting::ast::ComponentExpression {
52 use crate::engine::ecs::component::ce_helpers::*;
53 ce_call("Mirror", "quality", vec![num(self.quality as f64)])
54 }
55}