fix unloadng of temp terrain

This commit is contained in:
2025-05-02 20:53:04 +01:00
parent b7261ae847
commit 18756b2366
2 changed files with 15 additions and 5 deletions
+12 -1
View File
@@ -92,6 +92,10 @@ pub struct CurrentWorldSpriteState {
}
use std::time::Instant;
#[derive(Component)]
pub struct TerrainSprite;
// TODO: re-rendering on z-index change is inefficient, replace with shifting pool system for z-index change
pub fn build_world_sprites(
mut query: Query<(&FloorTile, &Transform)>,
mut commands: Commands,
@@ -99,10 +103,17 @@ pub fn build_world_sprites(
textures: Res<Textures>,
texture_ids: Res<TextureIDs>,
z_index: ResMut<game::ZIndex>,
query_1: Query<Entity, With<TerrainSprite>>,
) {
if cwss.state != WorldSpriteState::WaitingForRender {
return;
}
// despawn all query_1 entities
for entity in query_1.iter() {
commands.entity(entity).despawn();
}
let now = Instant::now();
if cwss.state == WorldSpriteState::WaitingForRender {
cwss.state = WorldSpriteState::InProgress;
@@ -120,7 +131,7 @@ pub fn build_world_sprites(
image: texture.clone(),
..Default::default()
};
commands.spawn((sprite, *transform));
commands.spawn((sprite, *transform, TerrainSprite));
}
}
cwss.state = WorldSpriteState::RenderReady;