mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 14:26:04 +00:00
Wait for plugins to load before starting the ECS
Also runs `App:finish()` after plugins finish loading.
This commit is contained in:
parent
aa2039c868
commit
9fc51e6c82
1 changed files with 10 additions and 2 deletions
|
@ -39,7 +39,7 @@ use azalea_protocol::{
|
||||||
resolver,
|
resolver,
|
||||||
};
|
};
|
||||||
use azalea_world::{Instance, InstanceContainer, InstanceName, PartialInstance};
|
use azalea_world::{Instance, InstanceContainer, InstanceName, PartialInstance};
|
||||||
use bevy_app::{App, Plugin, PluginGroup, PluginGroupBuilder, Update};
|
use bevy_app::{App, Plugin, PluginGroup, PluginGroupBuilder, PluginsState, Update};
|
||||||
use bevy_ecs::{
|
use bevy_ecs::{
|
||||||
bundle::Bundle,
|
bundle::Bundle,
|
||||||
component::Component,
|
component::Component,
|
||||||
|
@ -60,7 +60,7 @@ use tokio::{
|
||||||
},
|
},
|
||||||
time,
|
time,
|
||||||
};
|
};
|
||||||
use tracing::{debug, error};
|
use tracing::{debug, error, info};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -863,6 +863,14 @@ pub fn start_ecs_runner(
|
||||||
run_schedule_receiver: mpsc::Receiver<()>,
|
run_schedule_receiver: mpsc::Receiver<()>,
|
||||||
run_schedule_sender: mpsc::Sender<()>,
|
run_schedule_sender: mpsc::Sender<()>,
|
||||||
) -> Arc<Mutex<World>> {
|
) -> Arc<Mutex<World>> {
|
||||||
|
// Wait for plugins to load
|
||||||
|
if app.plugins_state() == PluginsState::Adding {
|
||||||
|
info!("Waiting for plugins to load ...");
|
||||||
|
while matches!(app.plugins_state(), PluginsState::Adding) {}
|
||||||
|
}
|
||||||
|
// Finish adding the plugins
|
||||||
|
app.finish();
|
||||||
|
|
||||||
// all resources should have been added by now so we can take the ecs from the
|
// all resources should have been added by now so we can take the ecs from the
|
||||||
// app
|
// app
|
||||||
let ecs = Arc::new(Mutex::new(std::mem::take(app.world_mut())));
|
let ecs = Arc::new(Mutex::new(std::mem::take(app.world_mut())));
|
||||||
|
|
Loading…
Add table
Reference in a new issue