Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions demos/asset_packs/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ fn main() {

// Create a new session for the game menu. Each session is it's own bones world with it's own
// plugins, systems, and entities.
game.sessions.create_with("menu", |builder| {
// Install the default bones_framework plugin for this session
builder
.install_plugin(DefaultSessionPlugin)
// Add our menu system to the update stage
.add_system_to_stage(Update, menu_system);
});
game.sessions
.create_with("menu", |builder: &mut SessionBuilder| {
// Install the default bones_framework plugin for this session
builder
.install_plugin(DefaultSessionPlugin)
// Add our menu system to the update stage
.add_system_to_stage(Update, menu_system);
});

BonesBevyRenderer::new(game).app().run();
}
Expand Down
15 changes: 8 additions & 7 deletions demos/hello_world/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ fn main() {

// Create a new session for the game menu. Each session is it's own bones world with it's own
// plugins, systems, and entities.
game.sessions.create_with("menu", |session| {
session
// Install the default bones_framework plugin for this session
.install_plugin(DefaultSessionPlugin)
// Add our menu system to the update stage
.add_system_to_stage(Update, menu_system);
});
game.sessions
.create_with("menu", |session: &mut SessionBuilder| {
session
// Install the default bones_framework plugin for this session
.install_plugin(DefaultSessionPlugin)
// Add our menu system to the update stage
.add_system_to_stage(Update, menu_system);
});

BonesBevyRenderer::new(game).app().run();
}
Expand Down
9 changes: 5 additions & 4 deletions demos/scripting/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ fn main() {
.register_default_assets();
GameMeta::register_schema();

game.sessions.create_with("launch", |builder| {
builder.add_startup_system(launch_game_session);
});
game.sessions
.create_with("launch", |builder: &mut SessionBuilder| {
builder.add_startup_system(launch_game_session);
});

let mut renderer = BonesBevyRenderer::new(game);
renderer.app_namespace = (
Expand All @@ -42,7 +43,7 @@ fn launch_game_session(
) {
session_ops.delete = true;
// Build game session and add to `Sessions`
sessions.create_with("game", |builder| {
sessions.create_with("game", |builder: &mut SessionBuilder| {
builder
.install_plugin(DefaultSessionPlugin)
// Install the plugin that will load our lua plugins and run them in the game session
Expand Down
56 changes: 30 additions & 26 deletions framework_crates/bones_framework/tests/reset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ pub fn startup_system_reset() {
game.init_shared_resource::<Counter>();

// Session startup increments counter by 1
game.sessions.create_with("game", |builder| {
builder.add_startup_system(|mut counter: ResMut<Counter>| {
// Increment to 1
counter.0 += 1;
game.sessions
.create_with("game", |builder: &mut SessionBuilder| {
builder.add_startup_system(|mut counter: ResMut<Counter>| {
// Increment to 1
counter.0 += 1;
});
});
});

// Step twice, startup system should only run once
game.step(Instant::now());
Expand Down Expand Up @@ -52,23 +53,24 @@ pub fn single_success_system_reset() {
let mut game = Game::new();

// Session startup increments counter by 1
game.sessions.create_with("game", |builder| {
builder.init_resource::<Counter>();
{
let res = builder.resource_mut::<Counter>().unwrap();
assert_eq!(res.0, 0);
}
// system
builder.add_single_success_system(|mut counter: ResMut<Counter>| -> Option<()> {
// Increment until 2
counter.0 += 1;
if counter.0 >= 2 {
return Some(());
game.sessions
.create_with("game", |builder: &mut SessionBuilder| {
builder.init_resource::<Counter>();
{
let res = builder.resource_mut::<Counter>().unwrap();
assert_eq!(res.0, 0);
}

None
// system
builder.add_single_success_system(|mut counter: ResMut<Counter>| -> Option<()> {
// Increment until 2
counter.0 += 1;
if counter.0 >= 2 {
return Some(());
}

None
});
});
});

// Step three times, single success should've incremented counter to 2 and completed.
game.step(Instant::now());
Expand Down Expand Up @@ -126,9 +128,10 @@ pub fn reset_world_resource_override() {
let mut game = Game::new();

// insert counter resource
game.sessions.create_with("game", |builder| {
builder.init_resource::<Counter>();
});
game.sessions
.create_with("game", |builder: &mut SessionBuilder| {
builder.init_resource::<Counter>();
});

game.step(Instant::now());
{
Expand Down Expand Up @@ -165,9 +168,10 @@ pub fn reset_world_emtpy_resource() {
let mut game = Game::new();

// insert counter resource
game.sessions.create_with("game", |builder| {
builder.init_resource::<Counter>();
});
game.sessions
.create_with("game", |builder: &mut SessionBuilder| {
builder.init_resource::<Counter>();
});

game.step(Instant::now());
{
Expand Down
4 changes: 2 additions & 2 deletions framework_crates/bones_lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -792,13 +792,13 @@ impl Sessions {
pub fn create_with<N: TryInto<Ustr>>(
&mut self,
name: N,
build_function: impl FnOnce(&mut SessionBuilder),
plugin: impl SessionPlugin,
) -> &mut Session
where
<N as TryInto<Ustr>>::Error: Debug,
{
let mut builder = SessionBuilder::new(name);
build_function(&mut builder);
builder.install_plugin(plugin);
builder.finish_and_add(self)
}

Expand Down
2 changes: 0 additions & 2 deletions framework_crates/bones_schema/src/alloc/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ const LAYOUT_ERR: LayoutError = if let Err(e) = Layout::from_size_align(0, 0) {
};

impl LayoutExt for Layout {
#[must_use = "this returns the padding needed, \
without modifying the `Layout`"]
#[inline]
fn padding_needed_for(&self, align: usize) -> usize {
let len = self.size();
Expand Down