reorganize a bit

This commit is contained in:
OMGeeky
2025-04-18 20:08:15 +02:00
parent 8c3b29719e
commit 79445c7157
2 changed files with 30 additions and 25 deletions

View File

@@ -6,6 +6,8 @@ impl Plugin for BlockLabelPlugin {
}
}
#[derive(Component, Debug)]
pub struct CanvasText;
#[derive(Bundle, Debug)]
pub struct BlockLabelBundle {
text: Text2d,

View File

@@ -54,8 +54,6 @@ pub struct BlockBundle {
block_visuals: BlockVisuals,
}
#[derive(Component, Debug)]
pub struct CanvasText;
#[derive(Component, Debug)]
pub struct BlockVisuals {
size: IVec2,
@@ -390,13 +388,13 @@ fn spawn_block_definition_from_asset(
if let Some(e) = spawned_block {
commands.entity(e).despawn_recursive();
}
spawn_block_definition(commands, asset_server, block);
spawn_block_definition(&mut commands, &asset_server, block);
state.set(AppState::Running)
}
}
fn spawn_block_definition(
mut commands: Commands,
asset_server: Res<AssetServer>,
mut commands: &mut Commands,
asset_server: &Res<AssetServer>,
block: BlockDefinition,
) {
let font = asset_server.load("fonts/arcane_nine.otf");
@@ -435,8 +433,14 @@ fn spawn_block_definition(
.map(|(id, con)| (id, ConnectionReference(commands.spawn(con).id())))
.collect();
// let child_blocks = block.inner_blocks.iter().map(|block| {
// spawn_block_definition(commands, asset_server, block.clone());
// });
let wires = block.wires.iter().map(|wire| {
wire.connections.iter().flat_map(|con| {
wire.connections
.iter()
.flat_map(|con| {
if (con.parent_block != block.id) {
warn!("get connections from sub blocks is not implemented yet");
// todo!("get connections from sub blocks (not blocks outside the one containing the wire and only one level deep)");
@@ -453,11 +457,10 @@ fn spawn_block_definition(
None
}
})
.collect()
});
for wire in wires {
commands.spawn(Wire {
connections: wire.collect(),
});
commands.spawn(Wire { connections: wire });
}
commands