change scheduling

Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
Schmarni
2024-05-19 04:48:49 +02:00
parent 72f2e7174e
commit fb9ec378c8
12 changed files with 292 additions and 127 deletions

View File

@@ -1,11 +1,13 @@
use std::sync::{Arc, RwLock};
use bevy::prelude::*;
use bevy::{ecs::schedule::ScheduleLabel, prelude::*};
pub struct XrSessionPlugin;
impl Plugin for XrSessionPlugin {
fn build(&self, app: &mut App) {
app.init_schedule(XrSessionCreated);
app.init_schedule(XrSessionEnding);
app.add_event::<CreateXrSession>()
.add_event::<DestroyXrSession>()
.add_event::<BeginXrSession>()
@@ -16,8 +18,21 @@ impl Plugin for XrSessionPlugin {
handle_session.run_if(resource_exists::<XrSharedStatus>),
);
}
fn finish(&self, app: &mut App) {
// This is in finnish because we need the RenderPlugin to already be added.
app.init_schedule(XrRenderSessionEnding);
}
}
#[derive(ScheduleLabel, Clone, Copy, PartialEq, Eq, Debug, Hash)]
pub struct XrSessionCreated;
#[derive(ScheduleLabel, Clone, Copy, PartialEq, Eq, Debug, Hash)]
pub struct XrSessionEnding;
#[derive(ScheduleLabel, Clone, Copy, PartialEq, Eq, Debug, Hash)]
pub struct XrRenderSessionEnding;
#[derive(Event, Clone, Copy, Deref)]
pub struct XrStatusChanged(pub XrStatus);