mittens_engine/engine/ecs/component/
render_graph.rs1use crate::engine::ecs::ComponentId;
2use crate::engine::ecs::component::Component;
3
4#[derive(Debug, Clone, Copy)]
5pub struct RenderGraphComponent {
6 pub enabled: bool,
7}
8
9impl Default for RenderGraphComponent {
10 fn default() -> Self {
11 Self::new()
12 }
13}
14
15impl RenderGraphComponent {
16 pub fn new() -> Self {
17 Self { enabled: true }
18 }
19
20 pub fn on() -> Self {
21 Self { enabled: true }
22 }
23
24 pub fn off() -> Self {
25 Self { enabled: false }
26 }
27
28 pub fn with_enabled(mut self, enabled: bool) -> Self {
29 self.enabled = enabled;
30 self
31 }
32}
33
34impl Component for RenderGraphComponent {
35 fn name(&self) -> &'static str {
36 "render_graph"
37 }
38
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 init(&mut self, emit: &mut dyn crate::engine::ecs::SignalEmitter, component: ComponentId) {
48 emit.push_intent_now(
49 component,
50 crate::engine::ecs::IntentValue::RegisterRenderGraph {
51 component_ids: vec![component],
52 },
53 );
54 }
55
56 fn to_mms_ast(
57 &self,
58 _world: &crate::engine::ecs::World,
59 ) -> crate::scripting::ast::ComponentExpression {
60 use crate::engine::ecs::component::ce_helpers::*;
61 let ctor = if self.enabled { "on" } else { "off" };
62 ce_call("RenderGraph", ctor, vec![])
63 }
64}