detect hand change and render it
This commit is contained in:
parent
d506a25716
commit
3417384b86
9 changed files with 138 additions and 68 deletions
|
|
@ -1,9 +1,44 @@
|
|||
use bevy::prelude::*;
|
||||
|
||||
use crate::{
|
||||
game::wall::{Wall, WallTiles},
|
||||
tiles::Tile,
|
||||
};
|
||||
|
||||
#[derive(Component)]
|
||||
pub(crate) struct Player {
|
||||
pub(crate) name: String,
|
||||
}
|
||||
|
||||
fn spawn_players(mut commands: Commands) {}
|
||||
|
||||
#[derive(Component)]
|
||||
pub(crate) struct Points(pub isize);
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct Hand;
|
||||
|
||||
#[derive(Component)]
|
||||
#[relationship_target(relationship = InHand, linked_spawn)]
|
||||
pub struct HandTiles(Vec<Entity>);
|
||||
|
||||
#[derive(Component)]
|
||||
#[relationship(relationship_target = HandTiles)]
|
||||
pub struct InHand(pub Entity);
|
||||
|
||||
pub(crate) fn deal_hands(
|
||||
mut commands: Commands,
|
||||
wall: Single<Entity, With<Wall>>,
|
||||
wall_tiles: Query<Entity, With<WallTiles>>,
|
||||
tiles: Query<Entity, With<Tile>>,
|
||||
) -> Result {
|
||||
let hand = wall_tiles.iter().collect::<Vec<_>>();
|
||||
|
||||
commands
|
||||
.get_entity(*wall)?
|
||||
.remove_children(hand.last_chunk::<13>().unwrap());
|
||||
|
||||
commands.spawn((Hand, HandTiles(hand)));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue