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
impl LogicGate
pub const COMPONENT_BOOL_AND: BString
pub const COMPONENT_BOOL_OR: BString
pub const COMPONENT_BOOL_XOR: BString
pub const COMPONENT_BOOL_NAND: BString
pub const COMPONENT_BOOL_NOR: BString
pub const COMPONENT_BOOL_NOT: BString
pub const COMPONENT_BIT_AND: BString
pub const COMPONENT_BIT_OR: BString
pub const COMPONENT_BIT_XOR: BString
pub const COMPONENT_BIT_NAND: BString
pub const COMPONENT_BIT_NOR: BString
pub const COMPONENT_BIT_NOT: BString
pub const COMPONENT_BIT_SHIFT_LEFT: BString
pub const COMPONENT_BIT_SHIFT_RIGHT: BString
pub const COMPONENT_SUB: BString
pub const COMPONENT_MUL: BString
pub const COMPONENT_MOD_FLOORED: BString
pub const COMPONENT_MOD: BString
pub const COMPONENT_DIV: BString
pub const COMPONENT_ADD: BString
pub const COMPONENT_CEIL: BString
pub const COMPONENT_FLOOR: BString
pub const COMPONENT_EQ: BString
pub const COMPONENT_NEQ: BString
pub const COMPONENT_LT: BString
pub const COMPONENT_LEQ: BString
pub const COMPONENT_GT: BString
pub const COMPONENT_GEQ: BString
pub const COMPONENT_CONST: BString
pub const COMPONENT_BLEND: BString
pub const COMPONENT_EDGE_DETECTOR: BString
pub const STRUCT_BOOL_BOOL_STR: &str = "BrickComponentData_WireGraph_Expr_Bool_Bool"
pub const STRUCT_BINARY_BOOLBOOL_BOOL_STR: &str = "BrickComponentData_WireGraph_Expr_BoolBool_Bool"
pub const STRUCT_COMPARE_STR: &str = "BrickComponentData_WireGraph_Expr_Compare"
pub const STRUCT_FLOAT_FLOAT_STR: &str = "BrickComponentData_WireGraph_Expr_Float_Float"
pub const STRUCT_INT_INT_STR: &str = "BrickComponentData_WireGraph_Expr_Int_Int"
pub const STRUCT_BINARY_INTINT_INT_STR: &str = "BrickComponentData_WireGraph_Expr_IntInt_Int"
pub const STRUCT_MATH_COMPARE_STR: &str = "BrickComponentData_WireGraph_Expr_MathCompare"
pub const STRUCT_NUMNUM_NUM_STR: &str = "BrickComponentData_WireGraph_Expr_PrimMathVariantPrimMathVariant_PrimMathVariant"
pub const STRUCT_CONSTANT_STR: &str = "BrickComponentData_WireGraphPseudo_Const"
pub const STRUCT_BLEND_STR: &str = "BrickComponentData_WireGraph_Expr_MathBlend"
pub const STRUCT_EDGE_DETECTOR_STR: &str = "BrickComponentData_WireGraph_Expr_EdgeDetector"
pub const STRUCT_BOOL_BOOL: BString
pub const STRUCT_BINARY_BOOLBOOL_BOOL: BString
pub const STRUCT_COMPARE: BString
pub const STRUCT_FLOAT_FLOAT: BString
pub const STRUCT_INT_INT: BString
pub const STRUCT_INTINT_INT: BString
pub const STRUCT_MATH_COMPARE: BString
pub const STRUCT_NUMNUM_NUM: BString
pub const STRUCT_CONST: BString
pub const STRUCT_BLEND: BString
pub const STRUCT_EDGE_DETECTOR: BString
pub const BOOL_INPUT: BString
pub const BOOL_INPUT_A: BString
pub const BOOL_INPUT_B: BString
pub const BOOL_OUTPUT: BString
pub const INPUT: BString
pub const BLEND: BString
pub const INPUT_A: BString
pub const INPUT_B: BString
pub const OUTPUT: BString
pub const VALUE: BString
pub const RISING_EDGE: BString
pub const FALLING_EDGE: BString
pub const fn component_name(&self) -> BString
pub const fn is_bool_input(&self) -> bool
pub const fn is_bool_output(&self) -> bool
pub const fn struct_name(&self) -> BString
pub fn schema(&self) -> BrdbSchemaMeta
pub fn wire_port_names(&self) -> Vec<BString>
pub fn data_index(&self, name: &str) -> (Option<usize>, Option<usize>)
pub fn num_inputs(&self) -> usize
pub fn default_inputs(&self) -> Vec<Box<dyn AsBrdbValue>>
pub fn default_outputs(&self) -> Vec<Box<dyn AsBrdbValue>>
pub fn input_of(&self, brick_id: usize) -> WirePort
Sourcepub fn input_a_of(&self, brick_id: usize) -> WirePort
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}pub fn input_b_of(&self, brick_id: usize) -> WirePort
pub fn input_blend_of(&self, brick_id: usize) -> WirePort
Sourcepub fn output_of(&self, brick_id: usize) -> WirePort
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
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}pub fn rising_edge_of(&self, brick_id: usize) -> WirePort
pub fn falling_edge_of(&self, brick_id: usize) -> WirePort
Sourcepub fn component(self) -> LogicGateComponent
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
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}Sourcepub fn component_with_overrides(
self,
overrides: HashMap<BString, Box<dyn AsBrdbValue>>,
) -> LogicGateComponent
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}Sourcepub fn brick(self) -> BrickType
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
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§
impl Copy for LogicGate
impl Eq for LogicGate
Source§impl From<LogicGate> for LogicGateComponent
impl From<LogicGate> for LogicGateComponent
impl StructuralPartialEq for LogicGate
Auto Trait Implementations§
impl Freeze for LogicGate
impl RefUnwindSafe for LogicGate
impl Send for LogicGate
impl Sync for LogicGate
impl Unpin for LogicGate
impl UnsafeUnpin for LogicGate
impl UnwindSafe for LogicGate
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.