parent
3d983f0b5d
commit
858f752842
@ -0,0 +1,90 @@
|
|||||||
|
use logicworld_subassembly::{lw, COMPONENT_MAP};
|
||||||
|
use vecmath::Vector3;
|
||||||
|
|
||||||
|
use crate::router::{ConnectionMap, SQUARE};
|
||||||
|
|
||||||
|
pub fn builder(
|
||||||
|
height: usize,
|
||||||
|
parent_address: u32,
|
||||||
|
next_address: &mut u32,
|
||||||
|
position: &Vector3<i32>,
|
||||||
|
components: &mut Vec<lw::Component>,
|
||||||
|
wires: &mut Vec<lw::Wire>,
|
||||||
|
connection_map: &mut ConnectionMap,
|
||||||
|
layer_builder: impl Fn(
|
||||||
|
usize,
|
||||||
|
&mut u32,
|
||||||
|
u32,
|
||||||
|
&mut Vector3<i32>,
|
||||||
|
&mut Vec<lw::Component>,
|
||||||
|
&mut Vec<lw::Wire>,
|
||||||
|
&mut ConnectionMap,
|
||||||
|
),
|
||||||
|
) {
|
||||||
|
let mount = lw::Component {
|
||||||
|
address: *next_address,
|
||||||
|
parent: parent_address,
|
||||||
|
numeric_id: COMPONENT_MAP["MHG.Mount"],
|
||||||
|
position: *position,
|
||||||
|
rotation: quaternion::id(),
|
||||||
|
inputs: vec![],
|
||||||
|
outputs: vec![],
|
||||||
|
custom_data: lw::Mount::new(8).custom_data(),
|
||||||
|
};
|
||||||
|
let next_board = lw::Component {
|
||||||
|
address: *next_address + 1,
|
||||||
|
parent: mount.address,
|
||||||
|
numeric_id: COMPONENT_MAP["MHG.CircuitBoard"],
|
||||||
|
position: [-SQUARE / 2, 3 * SQUARE - SQUARE / 3, -SQUARE / 2],
|
||||||
|
rotation: quaternion::id(),
|
||||||
|
inputs: vec![],
|
||||||
|
outputs: vec![],
|
||||||
|
custom_data: lw::CircuitBoard::default().with_size(3, 2).custom_data(),
|
||||||
|
};
|
||||||
|
|
||||||
|
*next_address += 2;
|
||||||
|
|
||||||
|
let mut next_parent = next_board.address;
|
||||||
|
components.push(mount);
|
||||||
|
components.push(next_board);
|
||||||
|
|
||||||
|
for i_bit in 0..height {
|
||||||
|
let mut next_position_within = [SQUARE / 2, SQUARE / 2, SQUARE / 2];
|
||||||
|
let mount = lw::Component {
|
||||||
|
address: *next_address,
|
||||||
|
parent: next_parent,
|
||||||
|
numeric_id: COMPONENT_MAP["MHG.Mount"],
|
||||||
|
position: next_position_within,
|
||||||
|
rotation: quaternion::id(),
|
||||||
|
inputs: vec![],
|
||||||
|
outputs: vec![],
|
||||||
|
custom_data: lw::Mount::new(8).custom_data(),
|
||||||
|
};
|
||||||
|
let next_board = lw::Component {
|
||||||
|
address: *next_address + 1,
|
||||||
|
parent: mount.address,
|
||||||
|
numeric_id: COMPONENT_MAP["MHG.CircuitBoard"],
|
||||||
|
position: [-SQUARE / 2, 3 * SQUARE - SQUARE / 3, -SQUARE / 2],
|
||||||
|
rotation: quaternion::id(),
|
||||||
|
inputs: vec![],
|
||||||
|
outputs: vec![],
|
||||||
|
custom_data: lw::CircuitBoard::default().with_size(3, 2).custom_data(),
|
||||||
|
};
|
||||||
|
*next_address += 2;
|
||||||
|
next_position_within[0] += SQUARE;
|
||||||
|
|
||||||
|
layer_builder(
|
||||||
|
i_bit,
|
||||||
|
next_address,
|
||||||
|
next_parent,
|
||||||
|
&mut next_position_within,
|
||||||
|
components,
|
||||||
|
wires,
|
||||||
|
connection_map,
|
||||||
|
);
|
||||||
|
|
||||||
|
next_parent = next_board.address;
|
||||||
|
components.push(mount);
|
||||||
|
components.push(next_board);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue