|
|
|
@ -50,6 +50,7 @@ fn init_dice_cuboid(mut commands: Commands, mut meshes: ResMut<Assets<Mesh>>) {
|
|
|
|
[1.0, e], [0.0, e], [0.0, f], [1.0, f],
|
|
|
|
[1.0, e], [0.0, e], [0.0, f], [1.0, f],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
info!("Adding cuboid {:?}", cuboid);
|
|
|
|
commands.insert_resource(DiceCuboid { mesh: meshes.add(cuboid) });
|
|
|
|
commands.insert_resource(DiceCuboid { mesh: meshes.add(cuboid) });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -97,9 +98,7 @@ fn init_dice_ui(mut commands: Commands) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn init_dice(
|
|
|
|
fn init_dice(mut commands: Commands) {
|
|
|
|
mut commands: Commands,
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
[
|
|
|
|
[
|
|
|
|
["a", "b", "c", "d", "e", "f"],
|
|
|
|
["a", "b", "c", "d", "e", "f"],
|
|
|
|
["g", "h", "i", "j", "k", "l"],
|
|
|
|
["g", "h", "i", "j", "k", "l"],
|
|
|
|
@ -107,7 +106,7 @@ fn init_dice(
|
|
|
|
]
|
|
|
|
]
|
|
|
|
.into_iter()
|
|
|
|
.into_iter()
|
|
|
|
.enumerate()
|
|
|
|
.enumerate()
|
|
|
|
.for_each(|(idx, set)| {
|
|
|
|
.for_each(|(_idx, set)| {
|
|
|
|
commands
|
|
|
|
commands
|
|
|
|
.spawn((
|
|
|
|
.spawn((
|
|
|
|
GameChoice::Dice,
|
|
|
|
GameChoice::Dice,
|
|
|
|
@ -182,7 +181,6 @@ struct DiceCuboid {
|
|
|
|
|
|
|
|
|
|
|
|
impl EntityCommand for Die {
|
|
|
|
impl EntityCommand for Die {
|
|
|
|
fn apply(self, id: Entity, world: &mut World) {
|
|
|
|
fn apply(self, id: Entity, world: &mut World) {
|
|
|
|
|
|
|
|
|
|
|
|
info!("Applying entity command for die");
|
|
|
|
info!("Applying entity command for die");
|
|
|
|
|
|
|
|
|
|
|
|
// Image we will render our texture to
|
|
|
|
// Image we will render our texture to
|
|
|
|
@ -227,7 +225,8 @@ impl EntityCommand for Die {
|
|
|
|
.id();
|
|
|
|
.id();
|
|
|
|
|
|
|
|
|
|
|
|
// Scene being rendered to a texture
|
|
|
|
// Scene being rendered to a texture
|
|
|
|
world.spawn((
|
|
|
|
world
|
|
|
|
|
|
|
|
.spawn((
|
|
|
|
NodeBundle {
|
|
|
|
NodeBundle {
|
|
|
|
style: Style {
|
|
|
|
style: Style {
|
|
|
|
width: Val::Percent(100.0),
|
|
|
|
width: Val::Percent(100.0),
|
|
|
|
@ -274,18 +273,21 @@ impl EntityCommand for Die {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// Material used for this object
|
|
|
|
// Material used for this object
|
|
|
|
let this_material = world.resource_mut::<Assets<StandardMaterial>>().add(StandardMaterial {
|
|
|
|
let this_material =
|
|
|
|
base_color_texture: Some(image_handle),
|
|
|
|
world
|
|
|
|
..default()
|
|
|
|
.resource_mut::<Assets<StandardMaterial>>()
|
|
|
|
});
|
|
|
|
.add(StandardMaterial {
|
|
|
|
|
|
|
|
base_color_texture: Some(image_handle),
|
|
|
|
|
|
|
|
..default()
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
let pbr_bundle = PbrBundle {
|
|
|
|
let pbr_bundle = PbrBundle {
|
|
|
|
mesh: world.resource::<DiceCuboid>().mesh.clone(),
|
|
|
|
mesh: world.resource::<DiceCuboid>().mesh.clone(),
|
|
|
|
material: this_material,
|
|
|
|
material: this_material.clone(),
|
|
|
|
..default()
|
|
|
|
..default()
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
world.entity_mut(id).insert((self, pbr_bundle));
|
|
|
|
world.entity_mut(id).insert((self, pbr_bundle.clone()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|