|  |  | @ -56,6 +56,8 @@ fn main() { | 
			
		
	
		
		
			
				
					
					|  |  |  |         .add_observer(remove_tree_monologue) |  |  |  |         .add_observer(remove_tree_monologue) | 
			
		
	
		
		
			
				
					
					|  |  |  |         .add_observer(hide_monologue_preview) |  |  |  |         .add_observer(hide_monologue_preview) | 
			
		
	
		
		
			
				
					
					|  |  |  |         .add_observer(populate_tree) |  |  |  |         .add_observer(populate_tree) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         .add_observer(show_monologue_list) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         .add_observer(hide_monologue_list) | 
			
		
	
		
		
			
				
					
					|  |  |  |         .run(); |  |  |  |         .run(); | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -119,13 +121,14 @@ fn init_debug_ui(mut commands: Commands) { | 
			
		
	
		
		
			
				
					
					|  |  |  |     commands |  |  |  |     commands | 
			
		
	
		
		
			
				
					
					|  |  |  |         .spawn(( |  |  |  |         .spawn(( | 
			
		
	
		
		
			
				
					
					|  |  |  |             Node { |  |  |  |             Node { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 height: Val::Percent(90.0), |  |  |  |                 max_height: Val::Percent(90.0), | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                 align_self: AlignSelf::Center, |  |  |  |                 align_self: AlignSelf::Center, | 
			
		
	
		
		
			
				
					
					|  |  |  |                 justify_self: JustifySelf::Start, |  |  |  |                 justify_self: JustifySelf::Start, | 
			
		
	
		
		
			
				
					
					|  |  |  |                 ..default() |  |  |  |                 ..default() | 
			
		
	
		
		
			
				
					
					|  |  |  |             }, |  |  |  |             }, | 
			
		
	
		
		
			
				
					
					|  |  |  |             MonologuesContainer, |  |  |  |             MonologuesContainer, | 
			
		
	
		
		
			
				
					
					|  |  |  |             GlobalZIndex(i32::MAX - 1), |  |  |  |             GlobalZIndex(i32::MAX - 1), | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             BackgroundColor(PINK.into()), | 
			
		
	
		
		
			
				
					
					|  |  |  |             DebuggingState::On, |  |  |  |             DebuggingState::On, | 
			
		
	
		
		
			
				
					
					|  |  |  |         )) |  |  |  |         )) | 
			
		
	
		
		
			
				
					
					|  |  |  |         .with_children(|parent| { |  |  |  |         .with_children(|parent| { | 
			
		
	
	
		
		
			
				
					|  |  | @ -134,6 +137,7 @@ fn init_debug_ui(mut commands: Commands) { | 
			
		
	
		
		
			
				
					
					|  |  |  |                     height: Val::Percent(100.0), |  |  |  |                     height: Val::Percent(100.0), | 
			
		
	
		
		
			
				
					
					|  |  |  |                     flex_direction: FlexDirection::Column, |  |  |  |                     flex_direction: FlexDirection::Column, | 
			
		
	
		
		
			
				
					
					|  |  |  |                     padding: UiRect::all(Val::Px(10.0)), |  |  |  |                     padding: UiRect::all(Val::Px(10.0)), | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     overflow: Overflow::scroll_y(), | 
			
		
	
		
		
			
				
					
					|  |  |  |                     ..default() |  |  |  |                     ..default() | 
			
		
	
		
		
			
				
					
					|  |  |  |                 }, |  |  |  |                 }, | 
			
		
	
		
		
			
				
					
					|  |  |  |                 BackgroundColor(PINK.with_alpha(0.9).into()), |  |  |  |                 BackgroundColor(PINK.with_alpha(0.9).into()), | 
			
		
	
	
		
		
			
				
					|  |  | @ -144,6 +148,7 @@ fn init_debug_ui(mut commands: Commands) { | 
			
		
	
		
		
			
				
					
					|  |  |  |                     height: Val::Percent(100.0), |  |  |  |                     height: Val::Percent(100.0), | 
			
		
	
		
		
			
				
					
					|  |  |  |                     flex_direction: FlexDirection::Column, |  |  |  |                     flex_direction: FlexDirection::Column, | 
			
		
	
		
		
			
				
					
					|  |  |  |                     padding: UiRect::all(Val::Px(10.0)), |  |  |  |                     padding: UiRect::all(Val::Px(10.0)), | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     overflow: Overflow::scroll_y(), | 
			
		
	
		
		
			
				
					
					|  |  |  |                     ..default() |  |  |  |                     ..default() | 
			
		
	
		
		
			
				
					
					|  |  |  |                 }, |  |  |  |                 }, | 
			
		
	
		
		
			
				
					
					|  |  |  |                 BackgroundColor(ORANGE.with_alpha(0.9).into()), |  |  |  |                 BackgroundColor(ORANGE.with_alpha(0.9).into()), | 
			
		
	
	
		
		
			
				
					|  |  | @ -528,13 +533,11 @@ fn delete_tree(trigger: Trigger<Pointer<Click>>, mut commands: Commands) { | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | /// Load all monologues so they are in the asset store and trigger on-load events
 |  |  |  | /// Load all monologues so they are in the asset store and trigger on-load events
 | 
			
		
	
		
		
			
				
					
					|  |  |  | fn load_monologues( |  |  |  | fn load_monologues(server: ResMut<AssetServer>, mut loaded_assets: Local<Vec<Handle<Monologue>>>) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     server: ResMut<AssetServer>, |  |  |  |     *loaded_assets = include_str!("../../../assets/trees/MONOLOGUES") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     mut loaded_assets: Local<Vec<Handle<Monologue>>>, |  |  |  |         .split("\n") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | ) { |  |  |  |         .map(|path| server.load(path)) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     *loaded_assets = include_str!("../../../assets/trees/MONOLOGUES").split("\n").map(|path| { |  |  |  |         .collect(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         server.load(path) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     }).collect(); |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | fn spawn_debug_buttons( |  |  |  | fn spawn_debug_buttons( | 
			
		
	
	
		
		
			
				
					|  |  | @ -625,6 +628,32 @@ fn preview_monologue( | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | fn show_monologue_list( | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     trigger: Trigger<Pointer<Over>>, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     container: Query<Entity, With<MonologuesContainer>>, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     children: Query<&Children>, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     mut visibility: Query<&mut Visibility>, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | ) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     if let Ok(root) = container.get(trigger.target()) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         children.iter_descendants(root).for_each(|e| { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             *visibility.get_mut(e).unwrap() = Visibility::Inherited; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         }); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | fn hide_monologue_list( | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     trigger: Trigger<Pointer<Out>>, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     container: Query<Entity, With<MonologuesContainer>>, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     children: Query<&Children>, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     mut visibility: Query<&mut Visibility>, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | ) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     if let Ok(root) = container.get(trigger.target()) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         children.iter_descendants(root).for_each(|e| { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             *visibility.get_mut(e).unwrap() = Visibility::Hidden; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         }); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | fn spawn_monologue_tree( |  |  |  | fn spawn_monologue_tree( | 
			
		
	
		
		
			
				
					
					|  |  |  |     trigger: Trigger<Pointer<Click>>, |  |  |  |     trigger: Trigger<Pointer<Click>>, | 
			
		
	
		
		
			
				
					
					|  |  |  |     tree_monologues: Query<&TreeMonologue, With<Button>>, |  |  |  |     tree_monologues: Query<&TreeMonologue, With<Button>>, | 
			
		
	
	
		
		
			
				
					|  |  | @ -700,6 +729,7 @@ fn hide_monologue_preview( | 
			
		
	
		
		
			
				
					
					|  |  |  |     mut commands: Commands, |  |  |  |     mut commands: Commands, | 
			
		
	
		
		
			
				
					
					|  |  |  | ) { |  |  |  | ) { | 
			
		
	
		
		
			
				
					
					|  |  |  |     if !query.contains(trigger.target()) { |  |  |  |     if !query.contains(trigger.target()) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         info!("Processing over: {:?}", trigger.target()); | 
			
		
	
		
		
			
				
					
					|  |  |  |         commands.entity(*preview).despawn_related::<Children>(); |  |  |  |         commands.entity(*preview).despawn_related::<Children>(); | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
	
		
		
			
				
					|  |  | @ -709,17 +739,18 @@ fn drag_tree( | 
			
		
	
		
		
			
				
					
					|  |  |  |     state: Res<State<DebuggingState>>, |  |  |  |     state: Res<State<DebuggingState>>, | 
			
		
	
		
		
			
				
					
					|  |  |  |     mut query: Query<&mut Transform, With<Tree>>, |  |  |  |     mut query: Query<&mut Transform, With<Tree>>, | 
			
		
	
		
		
			
				
					
					|  |  |  |     camera: Single<(&Camera, &GlobalTransform), With<Camera>>, |  |  |  |     camera: Single<(&Camera, &GlobalTransform), With<Camera>>, | 
			
		
	
		
		
			
				
					
					|  |  |  |     window: Single<&Window> |  |  |  |     window: Single<&Window>, | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | ) { |  |  |  | ) { | 
			
		
	
		
		
			
				
					
					|  |  |  |     if *state.get() == DebuggingState::On { |  |  |  |     if *state.get() == DebuggingState::On { | 
			
		
	
		
		
			
				
					
					|  |  |  |         if let Ok(mut t) = query.get_mut(trigger.target()) { |  |  |  |         if let Ok(mut t) = query.get_mut(trigger.target()) { | 
			
		
	
		
		
			
				
					
					|  |  |  |             let world_position = window |  |  |  |             let world_position = window | 
			
		
	
		
		
			
				
					
					|  |  |  |                 .cursor_position() |  |  |  |                 .cursor_position() | 
			
		
	
		
		
			
				
					
					|  |  |  |                 .and_then(|cursor| { |  |  |  |                 .and_then(|cursor| camera.0.viewport_to_world(camera.1, cursor).ok()) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                     camera.0.viewport_to_world(camera.1, cursor).ok() |  |  |  |                 .map(|ray| { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 }).map(|ray| { |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                     // Compute ray's distance to entity
 |  |  |  |                     // Compute ray's distance to entity
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                     let distance = ray.intersect_plane(t.translation, InfinitePlane3d::new(t.up())).unwrap(); |  |  |  |                     let distance = ray | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         .intersect_plane(t.translation, InfinitePlane3d::new(t.up())) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         .unwrap(); | 
			
		
	
		
		
			
				
					
					|  |  |  |                     ray.get_point(distance) |  |  |  |                     ray.get_point(distance) | 
			
		
	
		
		
			
				
					
					|  |  |  |                 }); |  |  |  |                 }); | 
			
		
	
		
		
			
				
					
					|  |  |  |             t.translation = world_position.unwrap(); |  |  |  |             t.translation = world_position.unwrap(); | 
			
		
	
	
		
		
			
				
					|  |  | 
 |