render some tiles
This commit is contained in:
parent
bea146d439
commit
d506a25716
8 changed files with 129 additions and 60 deletions
|
|
@ -1,4 +1,5 @@
|
|||
use bevy::prelude::*;
|
||||
use tracing::instrument;
|
||||
|
||||
use crate::tiles::{self, *};
|
||||
|
||||
|
|
@ -11,8 +12,7 @@ impl Plugin for Riichi {
|
|||
fn build(&self, app: &mut App) {
|
||||
app.init_resource::<Compass>()
|
||||
.add_systems(Startup, init_match)
|
||||
.add_systems(Startup, tiles::init_tiles)
|
||||
.add_systems(Update, wall::build_wall)
|
||||
.add_systems(Startup, (tiles::init_tiles, wall::build_wall).chain())
|
||||
// semicolon stopper
|
||||
;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,19 +6,22 @@ use crate::game::InWall;
|
|||
use crate::tiles::Tile;
|
||||
|
||||
#[derive(Component)]
|
||||
#[relationship_target(relationship = InWall)]
|
||||
pub struct Wall(Vec<Entity>);
|
||||
#[relationship_target(relationship = InWall, linked_spawn)]
|
||||
pub struct WallTiles(Vec<Entity>);
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct Wall;
|
||||
|
||||
#[instrument(level = "trace", skip_all)]
|
||||
pub(crate) fn build_wall(mut commands: Commands, tiles: Query<Entity, With<Tile>>) -> Result {
|
||||
let mut rng = rand::rng();
|
||||
|
||||
let mut wall = commands.spawn(Wall(vec![]));
|
||||
|
||||
let mut shuffled = tiles.iter().collect::<Vec<_>>();
|
||||
let mut shuffled = tiles
|
||||
.iter()
|
||||
.inspect(|e| debug!("{e:?}"))
|
||||
.collect::<Vec<_>>();
|
||||
shuffled.shuffle(&mut rng);
|
||||
|
||||
wall.replace_children(&shuffled);
|
||||
let mut wall = commands.spawn((Wall, WallTiles(shuffled)));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue