mittens_engine/engine/ecs/component/
background.rs1use crate::engine::ecs::component::Component;
2
3#[derive(Debug, Default, Clone, Copy)]
4pub struct BackgroundComponent {
5 pub occlusion_and_lighting: bool,
11
12 pub ray_casting: bool,
17}
18
19impl BackgroundComponent {
20 pub fn new() -> Self {
21 Self {
22 occlusion_and_lighting: false,
23 ray_casting: false,
24 }
25 }
26
27 pub fn with_occlusion_and_lighting(mut self) -> Self {
28 self.occlusion_and_lighting = true;
29 self
30 }
31
32 pub fn with_ray_casting(mut self) -> Self {
33 self.ray_casting = true;
34 self
35 }
36}
37
38impl Component for BackgroundComponent {
39 fn as_any(&self) -> &dyn std::any::Any {
40 self
41 }
42
43 fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
44 self
45 }
46
47 fn name(&self) -> &'static str {
48 "background"
49 }
50
51 fn to_mms_ast(
52 &self,
53 _world: &crate::engine::ecs::World,
54 ) -> crate::scripting::ast::ComponentExpression {
55 use crate::engine::ecs::component::ce_helpers::*;
56 let mut ce = ce("Background");
57 if self.occlusion_and_lighting {
58 ce = ce.with_call("occlusion_and_lighting", vec![]);
59 }
60 if self.ray_casting {
61 ce = ce.with_call("ray_casting", vec![]);
62 }
63 ce
64 }
65}