Whole lot of bug fixes
This commit is contained in:
parent
5c2efc2b11
commit
2a38d63847
@ -1,6 +1,6 @@
|
||||
use bevy::{prelude::*, render::{camera::ScalingMode, view::RenderLayers}};
|
||||
|
||||
use crate::{markers::{IconCreatorEntityParentMarker, IconCreatorRootMarker, IconCreatorSceneRootMarker, InIconCreatorSceneMarker}, state::IconCreatorState};
|
||||
use crate::{markers::{IconCreatorCameraMarker, IconCreatorEntityParentMarker, IconCreatorRootMarker, IconCreatorSceneRootMarker, InIconCreatorSceneMarker}, state::IconCreatorState};
|
||||
|
||||
pub fn setup_icon_creation_scenes(
|
||||
mut commands: Commands,
|
||||
@ -46,6 +46,7 @@ pub fn setup_icon_creation_scenes(
|
||||
transform: Transform::from_xyz(0.0, 0.0, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..Default::default()
|
||||
},
|
||||
IconCreatorCameraMarker,
|
||||
RenderLayers::layer(icon_creator_state.render_layer),
|
||||
Name::new("Scene camera"),
|
||||
))
|
||||
|
@ -9,14 +9,14 @@ const MIN_FRAMES_TO_RENDER: u8 = 3;
|
||||
/// It should keep track of the amount of frames.
|
||||
pub fn update_icon_creator_scenes(
|
||||
mut commands: Commands,
|
||||
mut scene_query: Query<(&InIconCreatorSceneMarker, &mut Visibility, &mut IconCreatorSceneRootMarker), With<SceneOccupiedMarker>>,
|
||||
mut scene_query: Query<(Entity, &InIconCreatorSceneMarker, &mut Visibility, &mut IconCreatorSceneRootMarker), With<SceneOccupiedMarker>>,
|
||||
mut scene_camera_query: Query<(&mut Camera, &InIconCreatorSceneMarker), With<IconCreatorCameraMarker>>,
|
||||
scene_entity_parent_query: Query<(Entity, &InIconCreatorSceneMarker), With<IconCreatorEntityParentMarker>>,
|
||||
scene_child_query: Query<(&Parent, &InIconCreatorSceneMarker, &EntityGettingIconMarker), With<IconCreatorEntityChildMarker>>,
|
||||
mut images: ResMut<Assets<Image>>,
|
||||
mut created_icons: ResMut<CreatedIcons>,
|
||||
) {
|
||||
for (scene_marker, mut scene_root_visibility, mut scene_root_marker) in scene_query.iter_mut() {
|
||||
for (scene_root_entity, scene_marker, mut scene_root_visibility, mut scene_root_marker) in scene_query.iter_mut() {
|
||||
for (mut scene_camera, in_scene) in scene_camera_query.iter_mut() {
|
||||
if scene_marker.0 != in_scene.0 { continue; }
|
||||
for (scene_parent_entity, in_scene) in scene_entity_parent_query.iter() {
|
||||
@ -36,8 +36,8 @@ pub fn update_icon_creator_scenes(
|
||||
};
|
||||
scene_camera.target = RenderTarget::Image(camera_target_image_handle);
|
||||
} else if scene_root_marker.0 >= MIN_FRAMES_TO_RENDER + entity_getting_icon_marker.extra_frames.unwrap_or(0) {
|
||||
// Unoccupy
|
||||
if let Some(mut entity_commands) = commands.get_entity(scene_parent_entity) {
|
||||
commands.entity(scene_root_entity).remove::<SceneOccupiedMarker>();
|
||||
if let Some(mut entity_commands) = commands.get_entity(scene_parent_entity) { // Unoccupy
|
||||
entity_commands.remove::<SceneOccupiedMarker>();
|
||||
scene_camera.is_active = false;
|
||||
*scene_root_visibility = Visibility::Hidden;
|
||||
@ -60,7 +60,7 @@ pub fn update_give_work_to_scenes(
|
||||
mut scene_query: Query<(Entity, &InIconCreatorSceneMarker, &RenderLayers), (With<IconCreatorSceneRootMarker>, Without<SceneOccupiedMarker>)>,
|
||||
scene_entity_parent_query: Query<(Entity, &InIconCreatorSceneMarker), With<IconCreatorEntityParentMarker>>,
|
||||
) {
|
||||
for (needs_icon_entity, needs_icon_marker) in needs_icon_query.iter() {
|
||||
'a: for (needs_icon_entity, needs_icon_marker) in needs_icon_query.iter() {
|
||||
// move this entity to any unoccupied scene.
|
||||
// Then set the scene to occupied (Visibility::Visible & Camera.active = true & Occupied component)
|
||||
for (scene_entity, scene_marker, scene_render_layer) in scene_query.iter_mut() {
|
||||
@ -80,6 +80,7 @@ pub fn update_give_work_to_scenes(
|
||||
.insert(VisibilityBundle::default())
|
||||
.remove::<NeedsIconMarker>();
|
||||
commands.entity(scene_entity).insert(SceneOccupiedMarker);
|
||||
break 'a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user