|
|
|
|
@ -1,3 +1,4 @@
|
|
|
|
|
#![allow(dead_code)]
|
|
|
|
|
#![allow(clippy::type_complexity)]
|
|
|
|
|
#![allow(clippy::too_many_arguments)]
|
|
|
|
|
|
|
|
|
|
@ -45,10 +46,10 @@ fn main() {
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
.add_observer(add_dialog_option)
|
|
|
|
|
.add_observer(add_dialog_line)
|
|
|
|
|
.add_observer(add_tree_monologue)
|
|
|
|
|
.add_observer(remove_tree_monologue)
|
|
|
|
|
.add_observer(hide_monologue_preview)
|
|
|
|
|
.add_observer(populate_tree)
|
|
|
|
|
.run();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -281,8 +282,6 @@ fn dialog_engine(
|
|
|
|
|
mut next_state: ResMut<NextState<DialogState>>,
|
|
|
|
|
// Monologue assets for obvious reasons
|
|
|
|
|
monologues: Res<Assets<Monologue>>,
|
|
|
|
|
// Monologue trees so we can remove that component at end of monologue
|
|
|
|
|
monologue_trees: Query<(Entity, &TreeMonologue), With<Tree>>,
|
|
|
|
|
// Dialog lines to despawn them at the end/start of a dialog
|
|
|
|
|
lines: Query<Entity, With<DialogLine>>,
|
|
|
|
|
) {
|
|
|
|
|
@ -419,10 +418,6 @@ fn add_dialog_option(trigger: Trigger<OnAdd, DialogOption>, mut commands: Comman
|
|
|
|
|
.observe(hover_dialog_option_out);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn add_dialog_line(trigger: Trigger<OnAdd, DialogLine>, mut commands: Commands) {
|
|
|
|
|
debug!("Adding dialog line");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn dialog_box_visibility(
|
|
|
|
|
state: Res<State<DialogState>>,
|
|
|
|
|
mut dialog_box: Single<&mut Visibility, With<DialogBox>>,
|
|
|
|
|
@ -617,45 +612,60 @@ fn preview_monologue(
|
|
|
|
|
fn spawn_monologue_tree(
|
|
|
|
|
trigger: Trigger<Pointer<Click>>,
|
|
|
|
|
tree_monologues: Query<&TreeMonologue, With<Button>>,
|
|
|
|
|
trees: Query<Entity, With<Tree>>,
|
|
|
|
|
mut commands: Commands,
|
|
|
|
|
) {
|
|
|
|
|
let tree_monologue = tree_monologues.get(trigger.target()).unwrap();
|
|
|
|
|
info!("Spawning monologuing tree");
|
|
|
|
|
commands.spawn((Tree, tree_monologue.clone()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// When a monologuing tree is added, give it a mesh, a material, and a position in space
|
|
|
|
|
///
|
|
|
|
|
/// TODO: This can be an `on_add` hook intead, just a little more clunky
|
|
|
|
|
fn populate_tree(
|
|
|
|
|
trigger: Trigger<OnAdd, TreeMonologue>,
|
|
|
|
|
time: Res<Time>,
|
|
|
|
|
trees: Query<Entity, With<Tree>>,
|
|
|
|
|
server: Res<AssetServer>,
|
|
|
|
|
mut commands: Commands,
|
|
|
|
|
mut meshes: ResMut<Assets<Mesh>>,
|
|
|
|
|
mut materials: ResMut<Assets<StandardMaterial>>,
|
|
|
|
|
server: Res<AssetServer>,
|
|
|
|
|
) {
|
|
|
|
|
let tree_monologue = tree_monologues.get(trigger.target()).unwrap();
|
|
|
|
|
if !trees.contains(trigger.target()) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
// Generate "random" X and Y Coordinates for this tree
|
|
|
|
|
// 1. Take the top 2 bytes
|
|
|
|
|
// 2. Interpet as u8s
|
|
|
|
|
// 3. Re-interpret as i8s
|
|
|
|
|
// 4. Cast to f32
|
|
|
|
|
let transform = {
|
|
|
|
|
let [a, b, c, d] = time.elapsed().as_secs_f32().to_be_bytes();
|
|
|
|
|
info!("Time bits: {a} {b} {c} {d}");
|
|
|
|
|
let x = c as i8 / 4;
|
|
|
|
|
let y = d as i8 / 4;
|
|
|
|
|
// Avoid mesh clipping by offsetting each on the z axis
|
|
|
|
|
let z = trees.iter().len() as f32;
|
|
|
|
|
info!("Coordiantes: {x} {y}");
|
|
|
|
|
Transform::from_xyz(x.into(), z, y.into()).with_scale(Vec3::splat(10.0))
|
|
|
|
|
};
|
|
|
|
|
// Generate "random" X and Y Coordinates for this tree
|
|
|
|
|
// 1. Take the top 2 bytes
|
|
|
|
|
// 2. Interpet as u8s
|
|
|
|
|
// 3. Re-interpret as i8s
|
|
|
|
|
// 4. Cast to f32
|
|
|
|
|
let transform = {
|
|
|
|
|
let [a, b, c, d] = time.elapsed().as_secs_f32().to_be_bytes();
|
|
|
|
|
info!("Time bits: {a} {b} {c} {d}");
|
|
|
|
|
let x = c as i8 / 4;
|
|
|
|
|
let y = d as i8 / 4;
|
|
|
|
|
// Avoid mesh clipping by offsetting each on the z axis
|
|
|
|
|
let z = trees.iter().len() as f32;
|
|
|
|
|
info!("Coordiantes: {x} {y}");
|
|
|
|
|
Transform::from_xyz(x.into(), z, y.into()).with_scale(Vec3::splat(10.0))
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let material = MeshMaterial3d(materials.add(StandardMaterial {
|
|
|
|
|
base_color_texture: Some(server.load("placeholder/tree.png")),
|
|
|
|
|
base_color: WHITE.into(),
|
|
|
|
|
alpha_mode: AlphaMode::Blend,
|
|
|
|
|
..default()
|
|
|
|
|
}));
|
|
|
|
|
let material = MeshMaterial3d(materials.add(StandardMaterial {
|
|
|
|
|
base_color_texture: Some(server.load("placeholder/tree.png")),
|
|
|
|
|
base_color: WHITE.into(),
|
|
|
|
|
alpha_mode: AlphaMode::Blend,
|
|
|
|
|
..default()
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
let mesh = Mesh3d(meshes.add(Plane3d::new(Vec3::Y, Vec2::splat(1.0))));
|
|
|
|
|
let mesh = Mesh3d(meshes.add(Plane3d::new(Vec3::Y, Vec2::splat(1.0))));
|
|
|
|
|
|
|
|
|
|
commands
|
|
|
|
|
.spawn((Tree, mesh, material, tree_monologue.clone(), transform))
|
|
|
|
|
.observe(delete_tree);
|
|
|
|
|
}
|
|
|
|
|
info!("Fleshing out monologuing tree");
|
|
|
|
|
|
|
|
|
|
commands
|
|
|
|
|
.entity(trigger.target())
|
|
|
|
|
.insert((mesh, material, transform))
|
|
|
|
|
.observe(delete_tree);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn hide_monologue_preview(
|
|
|
|
|
|