Placeholder for lines

main
Elijah Voigt 1 month ago
parent e09ee105ea
commit a668b946f2

@ -379,7 +379,7 @@ fn setup_grid(
mut materials: ResMut<Assets<ColorMaterial>>,
mut checklist: ResMut<SetupChecklist>,
) {
let m: Mesh = Rectangle::new(SCALE, SCALE).into();
let m: Mesh = Rectangle::new(SCALE * 0.9, SCALE * 0.9).into();
let mh: Handle<Mesh> = meshes.add(m);
let m2d = Mesh2d(mh);
let c: Color = WHITE.with_alpha(0.5).into();
@ -387,10 +387,15 @@ fn setup_grid(
let mat = MeshMaterial2d(ch);
let t = Transform::from_xyz(0.0, 0.0, -1.0);
for x in 0..X_MAX {
for y in 0..Y_MAX {
for y in 0..Y_MAX {
// Spawn this line
let gp = GridPosition { x: 0, y };
commands.spawn((gp, Line(y as u8), LineBlocks::default(), t));
// Spawn the grid squares for this line
for x in 0..X_MAX {
let gp = GridPosition { x, y };
commands.spawn((gp, m2d.clone(), mat.clone(), t.clone()));
commands.spawn((gp, m2d.clone(), mat.clone(), t));
}
}
@ -407,6 +412,20 @@ struct ShapeBlock(Entity);
#[relationship_target(relationship = ShapeBlock)]
struct ShapeBlocks(Vec<Entity>);
/// Line number component
#[derive(Component)]
struct Line(u8);
/// Blocks <- Line Relationship
#[derive(Component)]
#[relationship(relationship_target = LineBlocks)]
struct LineBlock(Entity);
/// Line -> Blocks Relationship
#[derive(Component, Default)]
#[relationship_target(relationship = LineBlock)]
struct LineBlocks(Vec<Entity>);
/// Event handler for transforming a handle component into a thing
fn add_shape(
event: On<Add, AssetComponent<ShapeAsset>>,

Loading…
Cancel
Save