Skip to main content

LogicGate

Enum LogicGate 

Source
pub enum LogicGate {
Show 31 variants BoolAnd, BoolOr, BoolXor, BoolNand, BoolNor, BoolNot, BitAnd, BitOr, BitXor, BitNand, BitNor, BitNot, BitShiftLeft, BitShiftRight, Add, Sub, Mul, ModFloored, Mod, Div, Ceil, Floor, Blend, Eq, Neq, Lt, Leq, Gt, Geq, Const, EdgeDetector,
}

Variants§

§

BoolAnd

§

BoolOr

§

BoolXor

§

BoolNand

§

BoolNor

§

BoolNot

§

BitAnd

§

BitOr

§

BitXor

§

BitNand

§

BitNor

§

BitNot

§

BitShiftLeft

§

BitShiftRight

§

Add

§

Sub

§

Mul

§

ModFloored

§

Mod

§

Div

§

Ceil

§

Floor

§

Blend

§

Eq

§

Neq

§

Lt

§

Leq

§

Gt

§

Geq

§

Const

§

EdgeDetector

Implementations§

Source§

impl LogicGate

Source

pub const COMPONENT_BOOL_AND: BString

Source

pub const COMPONENT_BOOL_OR: BString

Source

pub const COMPONENT_BOOL_XOR: BString

Source

pub const COMPONENT_BOOL_NAND: BString

Source

pub const COMPONENT_BOOL_NOR: BString

Source

pub const COMPONENT_BOOL_NOT: BString

Source

pub const COMPONENT_BIT_AND: BString

Source

pub const COMPONENT_BIT_OR: BString

Source

pub const COMPONENT_BIT_XOR: BString

Source

pub const COMPONENT_BIT_NAND: BString

Source

pub const COMPONENT_BIT_NOR: BString

Source

pub const COMPONENT_BIT_NOT: BString

Source

pub const COMPONENT_BIT_SHIFT_LEFT: BString

Source

pub const COMPONENT_BIT_SHIFT_RIGHT: BString

Source

pub const COMPONENT_SUB: BString

Source

pub const COMPONENT_MUL: BString

Source

pub const COMPONENT_MOD_FLOORED: BString

Source

pub const COMPONENT_MOD: BString

Source

pub const COMPONENT_DIV: BString

Source

pub const COMPONENT_ADD: BString

Source

pub const COMPONENT_CEIL: BString

Source

pub const COMPONENT_FLOOR: BString

Source

pub const COMPONENT_EQ: BString

Source

pub const COMPONENT_NEQ: BString

Source

pub const COMPONENT_LT: BString

Source

pub const COMPONENT_LEQ: BString

Source

pub const COMPONENT_GT: BString

Source

pub const COMPONENT_GEQ: BString

Source

pub const COMPONENT_CONST: BString

Source

pub const COMPONENT_BLEND: BString

Source

pub const COMPONENT_EDGE_DETECTOR: BString

Source

pub const STRUCT_BOOL_BOOL_STR: &str = "BrickComponentData_WireGraph_Expr_Bool_Bool"

Source

pub const STRUCT_BINARY_BOOLBOOL_BOOL_STR: &str = "BrickComponentData_WireGraph_Expr_BoolBool_Bool"

Source

pub const STRUCT_COMPARE_STR: &str = "BrickComponentData_WireGraph_Expr_Compare"

Source

pub const STRUCT_FLOAT_FLOAT_STR: &str = "BrickComponentData_WireGraph_Expr_Float_Float"

Source

pub const STRUCT_INT_INT_STR: &str = "BrickComponentData_WireGraph_Expr_Int_Int"

Source

pub const STRUCT_BINARY_INTINT_INT_STR: &str = "BrickComponentData_WireGraph_Expr_IntInt_Int"

Source

pub const STRUCT_MATH_COMPARE_STR: &str = "BrickComponentData_WireGraph_Expr_MathCompare"

Source

pub const STRUCT_NUMNUM_NUM_STR: &str = "BrickComponentData_WireGraph_Expr_PrimMathVariantPrimMathVariant_PrimMathVariant"

Source

pub const STRUCT_CONSTANT_STR: &str = "BrickComponentData_WireGraphPseudo_Const"

Source

pub const STRUCT_BLEND_STR: &str = "BrickComponentData_WireGraph_Expr_MathBlend"

Source

pub const STRUCT_EDGE_DETECTOR_STR: &str = "BrickComponentData_WireGraph_Expr_EdgeDetector"

Source

pub const STRUCT_BOOL_BOOL: BString

Source

pub const STRUCT_BINARY_BOOLBOOL_BOOL: BString

Source

pub const STRUCT_COMPARE: BString

Source

pub const STRUCT_FLOAT_FLOAT: BString

Source

pub const STRUCT_INT_INT: BString

Source

pub const STRUCT_INTINT_INT: BString

Source

pub const STRUCT_MATH_COMPARE: BString

Source

pub const STRUCT_NUMNUM_NUM: BString

Source

pub const STRUCT_CONST: BString

Source

pub const STRUCT_BLEND: BString

Source

pub const STRUCT_EDGE_DETECTOR: BString

Source

pub const BOOL_INPUT: BString

Source

pub const BOOL_INPUT_A: BString

Source

pub const BOOL_INPUT_B: BString

Source

pub const BOOL_OUTPUT: BString

Source

pub const INPUT: BString

Source

pub const BLEND: BString

Source

pub const INPUT_A: BString

Source

pub const INPUT_B: BString

Source

pub const OUTPUT: BString

Source

pub const VALUE: BString

Source

pub const RISING_EDGE: BString

Source

pub const FALLING_EDGE: BString

Source

pub const fn component_name(&self) -> BString

Source

pub const fn is_bool_input(&self) -> bool

Source

pub const fn is_bool_output(&self) -> bool

Source

pub const fn struct_name(&self) -> BString

Source

pub fn schema(&self) -> BrdbSchemaMeta

Source

pub fn wire_port_names(&self) -> Vec<BString>

Source

pub fn data_index(&self, name: &str) -> (Option<usize>, Option<usize>)

Source

pub fn num_inputs(&self) -> usize

Source

pub fn default_inputs(&self) -> Vec<Box<dyn AsBrdbValue>>

Source

pub fn default_outputs(&self) -> Vec<Box<dyn AsBrdbValue>>

Source

pub fn input_of(&self, brick_id: usize) -> WirePort

Source

pub fn input_a_of(&self, brick_id: usize) -> WirePort

Examples found in repository?
examples/write_fixtures.rs (line 194)
157fn wires_world() -> World {
158    // Mirror of examples/write_wire.rs (single grid, single chunk — fully
159    // deterministic), extended to 3 bricks/2 wires: a boolean NOT gate feeds
160    // one input of an AND gate, whose output feeds a rerouter.
161    let mut world = World::new();
162    world.register_all_components();
163    world.meta.bundle.description = "Wire fixture".to_string();
164
165    let (a, a_id) = Brick {
166        position: (30, 0, 1).into(),
167        color: (255, 0, 0).into(),
168        asset: assets::bricks::B_REROUTE,
169        ..Default::default()
170    }
171    .with_component(assets::components::Rerouter)
172    .with_id_split();
173    let (b, b_id) = Brick {
174        position: (15, 0, 1).into(),
175        color: (0, 255, 0).into(),
176        asset: assets::components::LogicGate::BoolAnd.brick(),
177        ..Default::default()
178    }
179    .with_component(assets::components::LogicGate::BoolAnd.component())
180    .with_id_split();
181    let (c, c_id) = Brick {
182        position: (0, 0, 1).into(),
183        color: (0, 0, 255).into(),
184        asset: assets::components::LogicGate::BoolNot.brick(),
185        ..Default::default()
186    }
187    .with_component(assets::components::LogicGate::BoolNot.component())
188    .with_id_split();
189
190    world.add_bricks([a, b, c]);
191    // Wire 1: NOT.output -> AND.inputA
192    world.add_wire_connection(
193        assets::components::LogicGate::BoolNot.output_of(c_id),
194        assets::components::LogicGate::BoolAnd.input_a_of(b_id),
195    );
196    // Wire 2: AND.output -> Rerouter.input
197    world.add_wire_connection(
198        assets::components::LogicGate::BoolAnd.output_of(b_id),
199        assets::components::Rerouter::input_of(a_id),
200    );
201
202    world
203}
Source

pub fn input_b_of(&self, brick_id: usize) -> WirePort

Source

pub fn input_blend_of(&self, brick_id: usize) -> WirePort

Source

pub fn output_of(&self, brick_id: usize) -> WirePort

Examples found in repository?
examples/write_wire.rs (line 35)
5fn main() -> Result<(), Box<dyn std::error::Error>> {
6    let path = PathBuf::from("./example_wire.brdb");
7
8    // Ensures the memory db can be created without errors
9    let db = Brdb::new(&path)?.into_reader();
10    let mut world = World::new();
11    // Register the built-in component type/struct mappings so the gate and
12    // rerouter component types resolve when writing.
13    world.register_all_components();
14    world.meta.bundle.description = "Example World".to_string();
15
16    let (a, a_id) = Brick {
17        position: (0, 0, 1).into(),
18        color: (255, 0, 0).into(),
19        asset: assets::bricks::B_REROUTE,
20        ..Default::default()
21    }
22    .with_component(assets::components::Rerouter)
23    .with_id_split();
24    let (b, b_id) = Brick {
25        position: (15, 0, 1).into(),
26        color: (255, 0, 0).into(),
27        asset: assets::components::LogicGate::BoolNot.brick(),
28        ..Default::default()
29    }
30    .with_component(assets::components::LogicGate::BoolNot.component())
31    .with_id_split();
32
33    world.add_bricks([a, b]);
34    world.add_wire_connection(
35        assets::components::LogicGate::BoolNot.output_of(b_id),
36        assets::components::Rerouter::input_of(a_id),
37    );
38
39    db.save("example world", &world)?;
40
41    println!("{}", db.get_fs()?.render());
42
43    Ok(())
44}
More examples
Hide additional examples
examples/write_fixtures.rs (line 193)
157fn wires_world() -> World {
158    // Mirror of examples/write_wire.rs (single grid, single chunk — fully
159    // deterministic), extended to 3 bricks/2 wires: a boolean NOT gate feeds
160    // one input of an AND gate, whose output feeds a rerouter.
161    let mut world = World::new();
162    world.register_all_components();
163    world.meta.bundle.description = "Wire fixture".to_string();
164
165    let (a, a_id) = Brick {
166        position: (30, 0, 1).into(),
167        color: (255, 0, 0).into(),
168        asset: assets::bricks::B_REROUTE,
169        ..Default::default()
170    }
171    .with_component(assets::components::Rerouter)
172    .with_id_split();
173    let (b, b_id) = Brick {
174        position: (15, 0, 1).into(),
175        color: (0, 255, 0).into(),
176        asset: assets::components::LogicGate::BoolAnd.brick(),
177        ..Default::default()
178    }
179    .with_component(assets::components::LogicGate::BoolAnd.component())
180    .with_id_split();
181    let (c, c_id) = Brick {
182        position: (0, 0, 1).into(),
183        color: (0, 0, 255).into(),
184        asset: assets::components::LogicGate::BoolNot.brick(),
185        ..Default::default()
186    }
187    .with_component(assets::components::LogicGate::BoolNot.component())
188    .with_id_split();
189
190    world.add_bricks([a, b, c]);
191    // Wire 1: NOT.output -> AND.inputA
192    world.add_wire_connection(
193        assets::components::LogicGate::BoolNot.output_of(c_id),
194        assets::components::LogicGate::BoolAnd.input_a_of(b_id),
195    );
196    // Wire 2: AND.output -> Rerouter.input
197    world.add_wire_connection(
198        assets::components::LogicGate::BoolAnd.output_of(b_id),
199        assets::components::Rerouter::input_of(a_id),
200    );
201
202    world
203}
Source

pub fn rising_edge_of(&self, brick_id: usize) -> WirePort

Source

pub fn falling_edge_of(&self, brick_id: usize) -> WirePort

Source

pub fn component(self) -> LogicGateComponent

Examples found in repository?
examples/write_wire.rs (line 30)
5fn main() -> Result<(), Box<dyn std::error::Error>> {
6    let path = PathBuf::from("./example_wire.brdb");
7
8    // Ensures the memory db can be created without errors
9    let db = Brdb::new(&path)?.into_reader();
10    let mut world = World::new();
11    // Register the built-in component type/struct mappings so the gate and
12    // rerouter component types resolve when writing.
13    world.register_all_components();
14    world.meta.bundle.description = "Example World".to_string();
15
16    let (a, a_id) = Brick {
17        position: (0, 0, 1).into(),
18        color: (255, 0, 0).into(),
19        asset: assets::bricks::B_REROUTE,
20        ..Default::default()
21    }
22    .with_component(assets::components::Rerouter)
23    .with_id_split();
24    let (b, b_id) = Brick {
25        position: (15, 0, 1).into(),
26        color: (255, 0, 0).into(),
27        asset: assets::components::LogicGate::BoolNot.brick(),
28        ..Default::default()
29    }
30    .with_component(assets::components::LogicGate::BoolNot.component())
31    .with_id_split();
32
33    world.add_bricks([a, b]);
34    world.add_wire_connection(
35        assets::components::LogicGate::BoolNot.output_of(b_id),
36        assets::components::Rerouter::input_of(a_id),
37    );
38
39    db.save("example world", &world)?;
40
41    println!("{}", db.get_fs()?.render());
42
43    Ok(())
44}
More examples
Hide additional examples
examples/write_fixtures.rs (line 179)
157fn wires_world() -> World {
158    // Mirror of examples/write_wire.rs (single grid, single chunk — fully
159    // deterministic), extended to 3 bricks/2 wires: a boolean NOT gate feeds
160    // one input of an AND gate, whose output feeds a rerouter.
161    let mut world = World::new();
162    world.register_all_components();
163    world.meta.bundle.description = "Wire fixture".to_string();
164
165    let (a, a_id) = Brick {
166        position: (30, 0, 1).into(),
167        color: (255, 0, 0).into(),
168        asset: assets::bricks::B_REROUTE,
169        ..Default::default()
170    }
171    .with_component(assets::components::Rerouter)
172    .with_id_split();
173    let (b, b_id) = Brick {
174        position: (15, 0, 1).into(),
175        color: (0, 255, 0).into(),
176        asset: assets::components::LogicGate::BoolAnd.brick(),
177        ..Default::default()
178    }
179    .with_component(assets::components::LogicGate::BoolAnd.component())
180    .with_id_split();
181    let (c, c_id) = Brick {
182        position: (0, 0, 1).into(),
183        color: (0, 0, 255).into(),
184        asset: assets::components::LogicGate::BoolNot.brick(),
185        ..Default::default()
186    }
187    .with_component(assets::components::LogicGate::BoolNot.component())
188    .with_id_split();
189
190    world.add_bricks([a, b, c]);
191    // Wire 1: NOT.output -> AND.inputA
192    world.add_wire_connection(
193        assets::components::LogicGate::BoolNot.output_of(c_id),
194        assets::components::LogicGate::BoolAnd.input_a_of(b_id),
195    );
196    // Wire 2: AND.output -> Rerouter.input
197    world.add_wire_connection(
198        assets::components::LogicGate::BoolAnd.output_of(b_id),
199        assets::components::Rerouter::input_of(a_id),
200    );
201
202    world
203}
Source

pub fn component_with_overrides( self, overrides: HashMap<BString, Box<dyn AsBrdbValue>>, ) -> LogicGateComponent

Examples found in repository?
examples/write_fixtures.rs (lines 306-315)
205fn components_world() -> World {
206    // Single grid, single chunk (all positions < 2048) — fully deterministic.
207    // register_all_components() embeds the full component catalog so every
208    // type below (light/interact/wiregraph-pseudo/expr) resolves; each
209    // component below carries non-default property values, and #4/#5 exercise
210    // a WireGraphVariant-typed property (BufferTicks' Input/Output, and the
211    // Constant gate's Value).
212    let mut world = World::new();
213    world.register_all_components();
214    world.meta.bundle.description = "Component fixture".to_string();
215
216    // 1: Point light — non-default brightness/radius/color, decoupled from
217    // brick color (bUseBrickColor: false).
218    world.bricks.push(
219        Brick {
220            position: (0, 0, 6).into(),
221            color: (255, 255, 255).into(),
222            ..Default::default()
223        }
224        .with_component(assets::LiteralComponent::new("Component_PointLight").with_data([
225            ("bMatchBrickShape", Box::new(false) as Box<dyn AsBrdbValue>),
226            ("bEnabled", Box::new(true)),
227            ("Brightness", Box::new(500.0f32)),
228            ("Radius", Box::new(800.0f32)),
229            (
230                "Color",
231                Box::new(SavedBrickColor { r: 10, g: 20, b: 30, a: 255 }),
232            ),
233            ("bUseBrickColor", Box::new(false)),
234            ("bCastShadows", Box::new(true)),
235        ])),
236    );
237
238    // 2: Spot light — narrow cone, non-default brightness/color.
239    world.bricks.push(
240        Brick {
241            position: (20, 0, 6).into(),
242            color: (255, 255, 0).into(),
243            ..Default::default()
244        }
245        .with_component(assets::LiteralComponent::new("Component_SpotLight").with_data([
246            ("InnerConeAngle", Box::new(15.0f32) as Box<dyn AsBrdbValue>),
247            ("OuterConeAngle", Box::new(45.0f32)),
248            ("bEnabled", Box::new(true)),
249            ("Brightness", Box::new(300.0f32)),
250            ("Radius", Box::new(600.0f32)),
251            (
252                "Color",
253                Box::new(SavedBrickColor { r: 255, g: 0, b: 0, a: 255 }),
254            ),
255            ("bUseBrickColor", Box::new(false)),
256            ("bCastShadows", Box::new(true)),
257        ])),
258    );
259
260    // 3: Interact — custom prompt text, hidden interaction.
261    world.bricks.push(
262        Brick {
263            position: (40, 0, 6).into(),
264            color: (0, 255, 255).into(),
265            ..Default::default()
266        }
267        .with_component(assets::LiteralComponent::new("Component_Interact").with_data([
268            (
269                "Message",
270                Box::new("You interacted!".to_string()) as Box<dyn AsBrdbValue>,
271            ),
272            ("ConsoleTag", Box::new("fixture_interact".to_string())),
273            ("bAllowNearbyInteraction", Box::new(false)),
274            ("bHiddenInteraction", Box::new(true)),
275            ("PromptCustomLabel", Box::new("Open Door".to_string())),
276        ])),
277    );
278
279    // 4: Buffer (ticks) — WireGraphPseudo component whose Input/Output are
280    // WireGraphVariant; non-default counters plus a Number/Bool variant pair.
281    world.bricks.push(
282        Brick {
283            position: (60, 0, 1).into(),
284            color: (128, 0, 128).into(),
285            asset: assets::components::BufferTicks::default().brick(),
286            ..Default::default()
287        }
288        .with_component(assets::components::BufferTicks {
289            current_ticks: 3,
290            ticks_to_wait: 10,
291            input: WireVariant::Number(2.5),
292            output: WireVariant::Bool(true),
293        }),
294    );
295
296    // 5: Blend gate — WireGraph_Expr_MathBlend's InputA/InputB are each a
297    // WireGraphPrimMathVariant (here an f64 and an i64 tag, showing the
298    // variant is polymorphic per-port); Blend itself is a plain f64.
299    world.bricks.push(
300        Brick {
301            position: (80, 0, 1).into(),
302            color: (0, 128, 0).into(),
303            asset: assets::components::LogicGate::Blend.brick(),
304            ..Default::default()
305        }
306        .with_component(assets::components::LogicGate::Blend.component_with_overrides(
307            HashMap::from([
308                (
309                    "InputA".into(),
310                    Box::new(WireVariant::Number(10.0)) as Box<dyn AsBrdbValue>,
311                ),
312                ("InputB".into(), Box::new(WireVariant::Int(7))),
313                ("Blend".into(), Box::new(0.75f64)),
314            ]),
315        )),
316    );
317
318    world
319}
Source

pub fn brick(self) -> BrickType

Examples found in repository?
examples/write_wire.rs (line 27)
5fn main() -> Result<(), Box<dyn std::error::Error>> {
6    let path = PathBuf::from("./example_wire.brdb");
7
8    // Ensures the memory db can be created without errors
9    let db = Brdb::new(&path)?.into_reader();
10    let mut world = World::new();
11    // Register the built-in component type/struct mappings so the gate and
12    // rerouter component types resolve when writing.
13    world.register_all_components();
14    world.meta.bundle.description = "Example World".to_string();
15
16    let (a, a_id) = Brick {
17        position: (0, 0, 1).into(),
18        color: (255, 0, 0).into(),
19        asset: assets::bricks::B_REROUTE,
20        ..Default::default()
21    }
22    .with_component(assets::components::Rerouter)
23    .with_id_split();
24    let (b, b_id) = Brick {
25        position: (15, 0, 1).into(),
26        color: (255, 0, 0).into(),
27        asset: assets::components::LogicGate::BoolNot.brick(),
28        ..Default::default()
29    }
30    .with_component(assets::components::LogicGate::BoolNot.component())
31    .with_id_split();
32
33    world.add_bricks([a, b]);
34    world.add_wire_connection(
35        assets::components::LogicGate::BoolNot.output_of(b_id),
36        assets::components::Rerouter::input_of(a_id),
37    );
38
39    db.save("example world", &world)?;
40
41    println!("{}", db.get_fs()?.render());
42
43    Ok(())
44}
More examples
Hide additional examples
examples/write_fixtures.rs (line 176)
157fn wires_world() -> World {
158    // Mirror of examples/write_wire.rs (single grid, single chunk — fully
159    // deterministic), extended to 3 bricks/2 wires: a boolean NOT gate feeds
160    // one input of an AND gate, whose output feeds a rerouter.
161    let mut world = World::new();
162    world.register_all_components();
163    world.meta.bundle.description = "Wire fixture".to_string();
164
165    let (a, a_id) = Brick {
166        position: (30, 0, 1).into(),
167        color: (255, 0, 0).into(),
168        asset: assets::bricks::B_REROUTE,
169        ..Default::default()
170    }
171    .with_component(assets::components::Rerouter)
172    .with_id_split();
173    let (b, b_id) = Brick {
174        position: (15, 0, 1).into(),
175        color: (0, 255, 0).into(),
176        asset: assets::components::LogicGate::BoolAnd.brick(),
177        ..Default::default()
178    }
179    .with_component(assets::components::LogicGate::BoolAnd.component())
180    .with_id_split();
181    let (c, c_id) = Brick {
182        position: (0, 0, 1).into(),
183        color: (0, 0, 255).into(),
184        asset: assets::components::LogicGate::BoolNot.brick(),
185        ..Default::default()
186    }
187    .with_component(assets::components::LogicGate::BoolNot.component())
188    .with_id_split();
189
190    world.add_bricks([a, b, c]);
191    // Wire 1: NOT.output -> AND.inputA
192    world.add_wire_connection(
193        assets::components::LogicGate::BoolNot.output_of(c_id),
194        assets::components::LogicGate::BoolAnd.input_a_of(b_id),
195    );
196    // Wire 2: AND.output -> Rerouter.input
197    world.add_wire_connection(
198        assets::components::LogicGate::BoolAnd.output_of(b_id),
199        assets::components::Rerouter::input_of(a_id),
200    );
201
202    world
203}
204
205fn components_world() -> World {
206    // Single grid, single chunk (all positions < 2048) — fully deterministic.
207    // register_all_components() embeds the full component catalog so every
208    // type below (light/interact/wiregraph-pseudo/expr) resolves; each
209    // component below carries non-default property values, and #4/#5 exercise
210    // a WireGraphVariant-typed property (BufferTicks' Input/Output, and the
211    // Constant gate's Value).
212    let mut world = World::new();
213    world.register_all_components();
214    world.meta.bundle.description = "Component fixture".to_string();
215
216    // 1: Point light — non-default brightness/radius/color, decoupled from
217    // brick color (bUseBrickColor: false).
218    world.bricks.push(
219        Brick {
220            position: (0, 0, 6).into(),
221            color: (255, 255, 255).into(),
222            ..Default::default()
223        }
224        .with_component(assets::LiteralComponent::new("Component_PointLight").with_data([
225            ("bMatchBrickShape", Box::new(false) as Box<dyn AsBrdbValue>),
226            ("bEnabled", Box::new(true)),
227            ("Brightness", Box::new(500.0f32)),
228            ("Radius", Box::new(800.0f32)),
229            (
230                "Color",
231                Box::new(SavedBrickColor { r: 10, g: 20, b: 30, a: 255 }),
232            ),
233            ("bUseBrickColor", Box::new(false)),
234            ("bCastShadows", Box::new(true)),
235        ])),
236    );
237
238    // 2: Spot light — narrow cone, non-default brightness/color.
239    world.bricks.push(
240        Brick {
241            position: (20, 0, 6).into(),
242            color: (255, 255, 0).into(),
243            ..Default::default()
244        }
245        .with_component(assets::LiteralComponent::new("Component_SpotLight").with_data([
246            ("InnerConeAngle", Box::new(15.0f32) as Box<dyn AsBrdbValue>),
247            ("OuterConeAngle", Box::new(45.0f32)),
248            ("bEnabled", Box::new(true)),
249            ("Brightness", Box::new(300.0f32)),
250            ("Radius", Box::new(600.0f32)),
251            (
252                "Color",
253                Box::new(SavedBrickColor { r: 255, g: 0, b: 0, a: 255 }),
254            ),
255            ("bUseBrickColor", Box::new(false)),
256            ("bCastShadows", Box::new(true)),
257        ])),
258    );
259
260    // 3: Interact — custom prompt text, hidden interaction.
261    world.bricks.push(
262        Brick {
263            position: (40, 0, 6).into(),
264            color: (0, 255, 255).into(),
265            ..Default::default()
266        }
267        .with_component(assets::LiteralComponent::new("Component_Interact").with_data([
268            (
269                "Message",
270                Box::new("You interacted!".to_string()) as Box<dyn AsBrdbValue>,
271            ),
272            ("ConsoleTag", Box::new("fixture_interact".to_string())),
273            ("bAllowNearbyInteraction", Box::new(false)),
274            ("bHiddenInteraction", Box::new(true)),
275            ("PromptCustomLabel", Box::new("Open Door".to_string())),
276        ])),
277    );
278
279    // 4: Buffer (ticks) — WireGraphPseudo component whose Input/Output are
280    // WireGraphVariant; non-default counters plus a Number/Bool variant pair.
281    world.bricks.push(
282        Brick {
283            position: (60, 0, 1).into(),
284            color: (128, 0, 128).into(),
285            asset: assets::components::BufferTicks::default().brick(),
286            ..Default::default()
287        }
288        .with_component(assets::components::BufferTicks {
289            current_ticks: 3,
290            ticks_to_wait: 10,
291            input: WireVariant::Number(2.5),
292            output: WireVariant::Bool(true),
293        }),
294    );
295
296    // 5: Blend gate — WireGraph_Expr_MathBlend's InputA/InputB are each a
297    // WireGraphPrimMathVariant (here an f64 and an i64 tag, showing the
298    // variant is polymorphic per-port); Blend itself is a plain f64.
299    world.bricks.push(
300        Brick {
301            position: (80, 0, 1).into(),
302            color: (0, 128, 0).into(),
303            asset: assets::components::LogicGate::Blend.brick(),
304            ..Default::default()
305        }
306        .with_component(assets::components::LogicGate::Blend.component_with_overrides(
307            HashMap::from([
308                (
309                    "InputA".into(),
310                    Box::new(WireVariant::Number(10.0)) as Box<dyn AsBrdbValue>,
311                ),
312                ("InputB".into(), Box::new(WireVariant::Int(7))),
313                ("Blend".into(), Box::new(0.75f64)),
314            ]),
315        )),
316    );
317
318    world
319}

Trait Implementations§

Source§

impl Clone for LogicGate

Source§

fn clone(&self) -> LogicGate

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for LogicGate

Source§

impl Debug for LogicGate

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for LogicGate

Source§

impl From<LogicGate> for LogicGateComponent

Source§

fn from(ty: LogicGate) -> Self

Converts to this type from the input type.
Source§

impl Hash for LogicGate

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for LogicGate

Source§

fn eq(&self, other: &LogicGate) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for LogicGate

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.