fix unloadng of temp terrain
This commit is contained in:
+12
-1
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user