Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
b63fc4d
feat: move TileLayer grid methods into separate type & add resizing m…
TekhnaeRaav May 8, 2026
336cea4
refactor: move startup systems to `SystemStage` out of `SystemStages`.
TekhnaeRaav May 10, 2026
ab9dcc3
chore: remove mutable world borrows from `World::init_resource`
TekhnaeRaav May 11, 2026
f41606e
refactor: move single success systems management out of SystemStages …
TekhnaeRaav May 11, 2026
a4ac50a
refactor!: move startup resource management out of SystemStages and i…
TekhnaeRaav May 12, 2026
95f5ae7
chore: remove deprecated comment
TekhnaeRaav May 12, 2026
de7468a
chore: remove uneeded copies & clones.
TekhnaeRaav May 13, 2026
4ee0bfb
chore: remove mutable reference requirement on `clear_owned_resources…
TekhnaeRaav May 13, 2026
3af9bb5
feat: add retain resources methods on UntypedResources & World
TekhnaeRaav May 13, 2026
eb5e28c
refactor!: put SingleSuccessSystems resource in prelude & update sing…
TekhnaeRaav May 13, 2026
7994b37
refactor!: remove SessionRunner support requirements for ResetWorld.
TekhnaeRaav May 13, 2026
98ebf2f
chore: remove uneeded mutable reference
TekhnaeRaav May 13, 2026
b20c6fd
doc: clarify `insert_resource`
TekhnaeRaav May 14, 2026
7565ddb
doc: clarify SessionCommand activation timing
TekhnaeRaav May 14, 2026
9a0af60
refactor!: SystemStages, Session, and ResetWorld
TekhnaeRaav May 17, 2026
b5dd6fc
chore: remove CurrentSystemStage
TekhnaeRaav May 17, 2026
d1bc431
feat: add serde ser & de to GamepadAxis, GamepadButton, and KeyCode
TekhnaeRaav May 29, 2026
eb34856
doc: fix formatting
TekhnaeRaav May 29, 2026
c3666dd
add Hash & Eq schema function opt-in derive macro attributes for HasS…
TekhnaeRaav Jun 1, 2026
d8b8554
feat: impl From<T> for Maybe<T>
TekhnaeRaav Jul 31, 2026
7f736d1
chore: add todo, remove todo
TekhnaeRaav Jul 31, 2026
eed5887
feat: impl HasSchema for MouseButton
TekhnaeRaav Jul 31, 2026
5e5a7ca
feat: allow any schema for key deserialization
TekhnaeRaav Jul 31, 2026
c87e850
refactor!: adds the gilrs GamepadId to the bones gamepad events and p…
TekhnaeRaav Jul 31, 2026
25d3a83
refactor!: require default for network Controls
TekhnaeRaav Aug 2, 2026
ed63b64
doc: explain ResetWorld standard kept resources
TekhnaeRaav Aug 2, 2026
eb7ba94
refactor!: revert gilrs::GamepadId implementation into bones gamepad …
TekhnaeRaav Aug 6, 2026
188fe83
doc: add doc & todo
TekhnaeRaav Aug 14, 2026
a43616a
feat: add builder functions to `Session`
TekhnaeRaav Aug 14, 2026
f738b80
fix: test compile error
TekhnaeRaav Aug 14, 2026
302370f
refactor!: revamp and cleanup network input collection and docs.
TekhnaeRaav Aug 14, 2026
38016c4
fix!: remove `tile_size` field from EntityGridMap since this value is…
TekhnaeRaav Sep 12, 2026
b251882
feat!: add `CoreStage::StartupResource` which runs before `CoreStage:…
TekhnaeRaav Sep 12, 2026
89b71c1
fix: rename doc reference
TekhnaeRaav Oct 11, 2026
59ca10c
doc: remove unfinished sentence
TekhnaeRaav Oct 11, 2026
788a258
fix!: remove need for Ulid when creating a single success system.
TekhnaeRaav Oct 11, 2026
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
12 changes: 5 additions & 7 deletions demos/asset_packs/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,11 @@ 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: &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);
});
.create("menu")
// 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
10 changes: 3 additions & 7 deletions demos/assets_minimal/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,13 @@ 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.
let mut menu_session_builder = SessionBuilder::new("menu");

// Install the default bones_framework plugin for this session
menu_session_builder
game.sessions
.create("menu")
// 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);

// Finalize session and register with game sessions.
menu_session_builder.finish_and_add(&mut game.sessions);

BonesBevyRenderer::new(game).app().run();
}

Expand Down
29 changes: 14 additions & 15 deletions demos/features/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,18 @@ struct MenuData {
}

/// Menu plugin
pub fn menu_plugin(session: &mut SessionBuilder) {
pub fn menu_plugin(session: &mut Session) {
// Register our menu system
session
// Install the bones_framework default plugins for this session
.install_plugin(DefaultSessionPlugin)
// Initialize our menu data resource
.init_resource::<MenuData>();
.init_startup_resource::<MenuData>();

// And add our systems.
session
.add_system_to_stage(Update, menu_system)
.add_startup_system(menu_startup);
.add_system_to_stage(CoreStage::Startup, menu_startup);
}

/// Setup the main menu.
Expand Down Expand Up @@ -280,10 +280,10 @@ fn menu_system(
}

/// Plugin for running the sprite demo.
fn sprite_demo_plugin(session: &mut SessionBuilder) {
fn sprite_demo_plugin(session: &mut Session) {
session
.install_plugin(DefaultSessionPlugin)
.add_startup_system(sprite_demo_startup)
.add_system_to_stage(CoreStage::Startup, sprite_demo_startup)
.add_system_to_stage(Update, back_to_menu_ui)
.add_system_to_stage(Update, move_sprite);
}
Expand Down Expand Up @@ -344,10 +344,10 @@ fn move_sprite(
}

/// Plugin for running the tilemap demo.
fn tilemap_demo_plugin(session: &mut SessionBuilder) {
fn tilemap_demo_plugin(session: &mut Session) {
session
.install_plugin(DefaultSessionPlugin)
.add_startup_system(tilemap_startup_system)
.add_system_to_stage(CoreStage::Startup, tilemap_startup_system)
.add_system_to_stage(Update, back_to_menu_ui);
}

Expand All @@ -365,10 +365,9 @@ fn tilemap_startup_system(

// Load our map and atlas info
let map_info = assets.get(meta.tilemap_demo);
let atlas = assets.get(map_info.atlas);

// Create a new map layer
let mut layer = TileLayer::new(map_info.map_size, atlas.tile_size, map_info.atlas);
let mut layer = TileLayer::new(map_info.map_size, map_info.atlas);

// Load the layer up with the tiles from our metadata
for tile in &map_info.tiles {
Expand All @@ -390,10 +389,10 @@ fn tilemap_startup_system(
}

/// Plugin for running the atlas demo.
fn atlas_demo_plugin(session: &mut SessionBuilder) {
fn atlas_demo_plugin(session: &mut Session) {
session
.install_plugin(DefaultSessionPlugin)
.add_startup_system(atlas_demo_startup)
.add_system_to_stage(CoreStage::Startup, atlas_demo_startup)
.add_system_to_stage(Update, back_to_menu_ui);
}

Expand Down Expand Up @@ -438,7 +437,7 @@ fn atlas_demo_startup(
);
}

fn audio_demo_plugin(session: &mut SessionBuilder) {
fn audio_demo_plugin(session: &mut Session) {
session
.install_plugin(DefaultSessionPlugin)
.add_system_to_stage(Update, back_to_menu_ui)
Expand All @@ -464,7 +463,7 @@ fn audio_demo_ui(
});
}

fn storage_demo_plugin(session: &mut SessionBuilder) {
fn storage_demo_plugin(session: &mut Session) {
session
.install_plugin(DefaultSessionPlugin)
.add_system_to_stage(Update, storage_demo_ui)
Expand Down Expand Up @@ -494,10 +493,10 @@ fn storage_demo_ui(
});
}

fn path2d_demo_plugin(session: &mut SessionBuilder) {
fn path2d_demo_plugin(session: &mut Session) {
session
.install_plugin(DefaultSessionPlugin)
.add_startup_system(path2d_demo_startup)
.add_system_to_stage(CoreStage::Startup, path2d_demo_startup)
.add_system_to_stage(Update, back_to_menu_ui);
}

Expand Down
12 changes: 5 additions & 7 deletions demos/hello_world/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ 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: &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);
});
.create("menu")
// 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
2 changes: 1 addition & 1 deletion demos/scripting/assets/plugin1.plugin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ local function update()
end
end

session:add_startup_system(startup)
session:add_system_to_stage(CoreStage.Startup, startup)
session:add_system_to_stage(CoreStage.Update, update)
25 changes: 12 additions & 13 deletions demos/scripting/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ fn main() {
game.install_plugin(DefaultGamePlugin);
game.shared_resource_mut::<AssetServer>()
.register_default_assets();
Transform::register_schema();
GameMeta::register_schema();

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

let mut renderer = BonesBevyRenderer::new(game);
renderer.app_namespace = (
Expand All @@ -42,16 +42,15 @@ fn launch_game_session(
) {
session_ops.delete = true;
// Build game session and add to `Sessions`
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
.install_plugin(LuaPluginLoaderSessionPlugin(
// Tell it to install the lua plugins specified in our game meta
Arc::new(meta.plugins.iter().copied().collect()),
))
.add_startup_system(game_startup);
});
sessions
.create("game")
.install_plugin(DefaultSessionPlugin)
// Install the plugin that will load our lua plugins and run them in the game session
.install_plugin(LuaPluginLoaderSessionPlugin(
// Tell it to install the lua plugins specified in our game meta
Arc::new(meta.plugins.iter().copied().collect()),
))
.add_system_to_stage(CoreStage::Startup, game_startup);
}

fn game_startup(
Expand Down
7 changes: 7 additions & 0 deletions framework_crates/bones_asset/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,13 @@ impl<T> From<Option<T>> for Maybe<T> {
}
}

impl<T> From<T> for Maybe<T> {
#[inline]
fn from(value: T) -> Self {
Maybe::Set(value)
}
}

fn maybe_loader(
ctx: &mut MetaAssetLoadCtx,
ptr: SchemaRefMut<'_>,
Expand Down
2 changes: 1 addition & 1 deletion framework_crates/bones_bevy_renderer/src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ pub fn extract_bones_tilemaps(
let tile = tiles.get(*tile_ent).unwrap();

let tile_pos = tile_layer.pos(tile_pos_idx as u32);
let tile_offset = tile_pos.as_vec2() * tile_layer.tile_size;
let tile_offset = tile_pos.as_vec2() * atlas.tile_size;

let sprite_idx = tile.idx;
let y = sprite_idx / atlas.columns;
Expand Down
9 changes: 3 additions & 6 deletions framework_crates/bones_ecs/examples/pos_vel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,14 @@ fn main() {
let mut world = World::new();

// Build SystemStages to store the systems that we will run more than once.
let mut stages_builder = SystemStagesBuilder::with_core_stages();
let mut stages = SystemStages::with_core_stages();

// Add our systems to the system stages
stages_builder
.add_startup_system(startup_system)
stages
.add_system_to_stage(CoreStage::Startup, startup_system)
.add_system_to_stage(CoreStage::Update, pos_vel_system)
.add_system_to_stage(CoreStage::PostUpdate, print_system);

// Finish build to get `SystemStages`.
let mut stages = stages_builder.finish();

// Run our game loop for 10 frames
for _ in 0..10 {
stages.run(&mut world);
Expand Down
43 changes: 37 additions & 6 deletions framework_crates/bones_ecs/src/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,40 @@ impl UntypedResources {
)
}

/// Iterates through owned and shared resource cells removing them if the predicate returns `false`.
///
/// See also: [`Self::retain_owned_resources`].
pub fn retain_resources<F>(&self, mut predicate: F)
where
F: FnMut(SchemaId) -> bool,
{
for (schema_id, resource_cell) in self.resources.read_only_view().iter() {
let is_retained = predicate(*schema_id);
if !is_retained {
resource_cell.remove();
}
}
}

/// Iterates through resource cells removing them if the predicate returns `false`.
///
/// Doesn't include shared resources. See also: [`Self::retain_resources`].
pub fn retain_owned_resources<F>(&self, mut predicate: F)
where
F: FnMut(SchemaId) -> bool,
{
for (schema_id, resource_cell) in self.resources.read_only_view().iter() {
let is_shared = self.shared_resources.contains_key(schema_id);
let is_retained = predicate(*schema_id);
if !is_shared && !is_retained {
resource_cell.remove();
}
}
}

/// Removes all resourcse that are not shared resources.
pub fn clear_owned_resources(&mut self) {
for (schema_id, resource_cell) in self.resources.iter_mut() {
pub fn clear_owned_resources(&self) {
for (schema_id, resource_cell) in self.resources.read_only_view().iter() {
let is_shared = self.shared_resources.contains_key(schema_id);
if !is_shared {
resource_cell.remove();
Expand Down Expand Up @@ -297,8 +328,8 @@ impl Resources {
}

/// Removes all resources that are not shared. Shared resources are preserved.
pub fn clear_owned_resources(&mut self) {
self.untyped.clear_owned_resources();
pub fn clear_owned_resources(&self) {
self.untyped().clear_owned_resources();
}
}

Expand Down Expand Up @@ -547,7 +578,7 @@ impl UntypedResourceSet {
///
/// If `remove_empty` is set, if resource cell is empty, it will remove the
/// resource from cell on world.
pub fn insert_on_world(&self, world: &mut World, remove_empty: bool) {
pub fn insert_on_world(&self, world: &World, remove_empty: bool) {
for resource in self.resources.iter() {
let resource_cell = world.resources.untyped().get_cell(resource.schema());

Expand Down Expand Up @@ -604,7 +635,7 @@ mod test {

#[test]
fn resources_clear_owned_values() {
let mut r = Resources::new();
let r = Resources::new();

// insert A as non-shared resource
r.insert(A(String::from("foo")));
Expand Down
Loading
Loading