Skip to content

Commit

Permalink
feat(bevy): Migrated to Bevy 0.12 (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vortex committed Nov 5, 2023
1 parent e179cb5 commit 69c3a4a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ homepage = "https://github.com/zkat/big-brain"
[workspace]

[dependencies]
bevy = { version = "0.11", default-features = false }
bevy = { version = "0.12.0", default-features = false }
big-brain-derive = { version = "=0.18.0", path = "./derive" }

[dev-dependencies]
bevy = { version = "0.11", default-features = true }
bevy = { version = "0.12.0", default-features = true }
rand = { version = "0.8.5", features = ["small_rng"] }

[features]
Expand Down
24 changes: 12 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ pub mod prelude {
};
}

use bevy::{ecs::schedule::ScheduleLabel, prelude::*};
use bevy::{ecs::schedule::ScheduleLabel, prelude::*, utils::intern::Interned};

/// Core [`Plugin`] for Big Brain behavior. Required for any of the
/// [`Thinker`](thinker::Thinker)-related magic to work.
Expand All @@ -222,42 +222,42 @@ use bevy::{ecs::schedule::ScheduleLabel, prelude::*};
#[reflect(from_reflect = false)]
pub struct BigBrainPlugin {
#[reflect(ignore)]
schedule: Box<dyn ScheduleLabel>,
schedule: Interned<dyn ScheduleLabel>,
#[reflect(ignore)]
cleanup_schedule: Box<dyn ScheduleLabel>,
cleanup_schedule: Interned<dyn ScheduleLabel>,
}

impl BigBrainPlugin {
/// Create the BigBrain plugin which runs the scorers, thinker and actions in the specified
/// schedule
pub fn new(schedule: impl ScheduleLabel) -> Self {
Self {
schedule: Box::new(schedule),
cleanup_schedule: Box::new(Last),
schedule: schedule.intern(),
cleanup_schedule: Last.intern(),
}
}

/// Overwrite the Schedule that is used to run cleanup tasks. By default this happens in Last.
pub fn set_cleanup_schedule(mut self, cleanup_schedule: impl ScheduleLabel) -> Self {
self.cleanup_schedule = Box::new(cleanup_schedule);
self.cleanup_schedule = cleanup_schedule.intern();
self
}
}

impl Plugin for BigBrainPlugin {
fn build(&self, app: &mut App) {
app.configure_sets(
self.schedule.dyn_clone(),
self.schedule.intern(),
(
BigBrainSet::Scorers,
BigBrainSet::Thinkers,
BigBrainSet::Actions,
)
.chain(),
)
.configure_set(self.cleanup_schedule.dyn_clone(), BigBrainSet::Cleanup)
.configure_sets(self.cleanup_schedule.intern(), BigBrainSet::Cleanup)
.add_systems(
self.schedule.dyn_clone(),
self.schedule.intern(),
(
scorers::fixed_score_system,
scorers::measured_scorers_system,
Expand All @@ -270,15 +270,15 @@ impl Plugin for BigBrainPlugin {
.in_set(BigBrainSet::Scorers),
)
.add_systems(
self.schedule.dyn_clone(),
self.schedule.intern(),
thinker::thinker_system.in_set(BigBrainSet::Thinkers),
)
.add_systems(
self.schedule.dyn_clone(),
self.schedule.intern(),
(actions::steps_system, actions::concurrent_system).in_set(BigBrainSet::Actions),
)
.add_systems(
self.cleanup_schedule.dyn_clone(),
self.cleanup_schedule.intern(),
(
thinker::thinker_component_attach_system,
thinker::thinker_component_detach_system,
Expand Down

0 comments on commit 69c3a4a

Please sign in to comment.