mittens_engine/engine/ecs/component/
light_quantization.rs1use crate::engine::ecs::ComponentId;
2use crate::engine::ecs::component::Component;
3
4#[derive(Debug, Clone, Copy)]
9pub struct LightQuantizationComponent {
10 pub quant_steps: f32,
11}
12
13impl LightQuantizationComponent {
14 pub const DEFAULT_STEPS: f32 = 3.0;
16
17 pub fn new() -> Self {
18 Self {
19 quant_steps: Self::DEFAULT_STEPS,
20 }
21 }
22
23 pub fn steps(steps: f32) -> Self {
24 Self { quant_steps: steps }
25 }
26
27 pub fn with_steps(mut self, steps: f32) -> Self {
28 self.quant_steps = steps;
29 self
30 }
31}
32
33impl Default for LightQuantizationComponent {
34 fn default() -> Self {
35 Self::new()
36 }
37}
38
39impl Component for LightQuantizationComponent {
40 fn name(&self) -> &'static str {
41 "light_quantization"
42 }
43
44 fn as_any(&self) -> &dyn std::any::Any {
45 self
46 }
47
48 fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
49 self
50 }
51
52 fn init(&mut self, emit: &mut dyn crate::engine::ecs::SignalEmitter, component: ComponentId) {
53 emit.push_intent_now(
54 component,
55 crate::engine::ecs::IntentValue::RegisterLightQuantization {
56 component_ids: vec![component],
57 },
58 );
59 }
60
61 fn to_mms_ast(
62 &self,
63 _world: &crate::engine::ecs::World,
64 ) -> crate::scripting::ast::ComponentExpression {
65 use crate::engine::ecs::component::ce_helpers::*;
66 ce_call(
67 "LightQuantization",
68 "steps",
69 vec![num(self.quant_steps as f64)],
70 )
71 }
72}