Update viewshed in distinct stage to ensure that data is synced.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Nolan Darilek 2022-07-11 14:01:25 -05:00
parent 3994fef9d0
commit a1cfc448db
2 changed files with 8 additions and 5 deletions

View File

@ -385,10 +385,7 @@ impl<D: 'static + Clone + Default + Send + Sync> Plugin for MapPlugin<D> {
}
let config = app.world.get_resource::<MapConfig>().unwrap().clone();
app.register_type::<Portal>()
.add_system_to_stage(
CoreStage::PreUpdate,
spawn_colliders::<D>.before(crate::visibility::UPDATE_VIEWSHED_LABEL),
)
.add_system_to_stage(CoreStage::PreUpdate, spawn_colliders::<D>)
.add_system_to_stage(CoreStage::PreUpdate, spawn_portals::<D>)
.add_system_to_stage(CoreStage::PreUpdate, spawn_portal_colliders::<D>);
if config.speak_area_descriptions {

View File

@ -433,10 +433,16 @@ pub const UPDATE_VIEWSHED_LABEL: &str = "UPDATE_VIEWSHED";
impl<D: 'static + Clone + Default + Send + Sync> Plugin for VisibilityPlugin<D> {
fn build(&self, app: &mut App) {
const UPDATE_VIEWSHED_STAGE: &str = "UPDATE_VIEWSHED_STAGE";
app.add_event::<VisibilityChanged>()
.add_stage_after(
CoreStage::PreUpdate,
UPDATE_VIEWSHED_STAGE,
SystemStage::parallel(),
)
.add_system_to_stage(CoreStage::PreUpdate, add_visibility_indices::<D>)
.add_system_set_to_stage(
CoreStage::PreUpdate,
UPDATE_VIEWSHED_STAGE,
SystemSet::new()
.with_run_criteria(FixedTimestep::step(0.05))
.with_system(update_viewshed::<D>)