Skip to content

Commit 5755b89

Browse files
TekhnaeRaavzicklag
authored andcommitted
Change Sessions::create_with to take SessionPlugin
1 parent fc00c0c commit 5755b89

6 files changed

Lines changed: 15 additions & 16 deletions

File tree

demos/asset_packs/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn main() {
4646

4747
// Create a new session for the game menu. Each session is it's own bones world with it's own
4848
// plugins, systems, and entities.
49-
game.sessions.create_with("menu", |builder| {
49+
game.sessions.create_with("menu", |builder: &mut SessionBuilder| {
5050
// Install the default bones_framework plugin for this session
5151
builder
5252
.install_plugin(DefaultSessionPlugin)

demos/hello_world/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fn main() {
1010

1111
// Create a new session for the game menu. Each session is it's own bones world with it's own
1212
// plugins, systems, and entities.
13-
game.sessions.create_with("menu", |session| {
13+
game.sessions.create_with("menu", |session: &mut SessionBuilder| {
1414
session
1515
// Install the default bones_framework plugin for this session
1616
.install_plugin(DefaultSessionPlugin)

demos/scripting/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn main() {
2222
.register_default_assets();
2323
GameMeta::register_schema();
2424

25-
game.sessions.create_with("launch", |builder| {
25+
game.sessions.create_with("launch", |builder: &mut SessionBuilder| {
2626
builder.add_startup_system(launch_game_session);
2727
});
2828

@@ -42,7 +42,7 @@ fn launch_game_session(
4242
) {
4343
session_ops.delete = true;
4444
// Build game session and add to `Sessions`
45-
sessions.create_with("game", |builder| {
45+
sessions.create_with("game", |builder: &mut SessionBuilder| {
4646
builder
4747
.install_plugin(DefaultSessionPlugin)
4848
// Install the plugin that will load our lua plugins and run them in the game session

framework_crates/bones_framework/tests/reset.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ pub fn startup_system_reset() {
1111
game.init_shared_resource::<Counter>();
1212

1313
// Session startup increments counter by 1
14-
game.sessions.create_with("game", |builder| {
15-
builder.add_startup_system(|mut counter: ResMut<Counter>| {
16-
// Increment to 1
17-
counter.0 += 1;
14+
game.sessions
15+
.create_with("game", |builder: &mut SessionBuilder| {
16+
builder.add_startup_system(|mut counter: ResMut<Counter>| {
17+
// Increment to 1
18+
counter.0 += 1;
19+
});
1820
});
19-
});
2021

2122
// Step twice, startup system should only run once
2223
game.step(Instant::now());
@@ -52,7 +53,7 @@ pub fn single_success_system_reset() {
5253
let mut game = Game::new();
5354

5455
// Session startup increments counter by 1
55-
game.sessions.create_with("game", |builder| {
56+
game.sessions.create_with("game", |builder: &mut SessionBuilder| {
5657
builder.init_resource::<Counter>();
5758
{
5859
let res = builder.resource_mut::<Counter>().unwrap();
@@ -126,7 +127,7 @@ pub fn reset_world_resource_override() {
126127
let mut game = Game::new();
127128

128129
// insert counter resource
129-
game.sessions.create_with("game", |builder| {
130+
game.sessions.create_with("game", |builder: &mut SessionBuilder| {
130131
builder.init_resource::<Counter>();
131132
});
132133

@@ -165,7 +166,7 @@ pub fn reset_world_emtpy_resource() {
165166
let mut game = Game::new();
166167

167168
// insert counter resource
168-
game.sessions.create_with("game", |builder| {
169+
game.sessions.create_with("game", |builder: &mut SessionBuilder| {
169170
builder.init_resource::<Counter>();
170171
});
171172

framework_crates/bones_lib/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,13 +792,13 @@ impl Sessions {
792792
pub fn create_with<N: TryInto<Ustr>>(
793793
&mut self,
794794
name: N,
795-
build_function: impl FnOnce(&mut SessionBuilder),
795+
plugin: impl SessionPlugin,
796796
) -> &mut Session
797797
where
798798
<N as TryInto<Ustr>>::Error: Debug,
799799
{
800800
let mut builder = SessionBuilder::new(name);
801-
build_function(&mut builder);
801+
builder.install_plugin(plugin);
802802
builder.finish_and_add(self)
803803
}
804804

framework_crates/bones_schema/src/alloc/layout.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ const LAYOUT_ERR: LayoutError = if let Err(e) = Layout::from_size_align(0, 0) {
4141
};
4242

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

0 commit comments

Comments
 (0)