Skip to content

Commit 91f4820

Browse files
authored
Update to Bevy 0.18 (#628)
1 parent c1383dc commit 91f4820

21 files changed

Lines changed: 79 additions & 63 deletions

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.38.0] - 2025-12-17
11+
12+
### Changed
13+
14+
- Update to Bevy 0.18.
15+
1016
## [0.37.2] - 2026-01-11
1117

1218
### Fixed
@@ -978,7 +984,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
978984

979985
Initial release after separation from [Project Harmonia](https://github.com/simgine/project_harmonia).
980986

981-
[unreleased]: https://github.com/simgine/bevy_replicon/compare/v0.37.2...HEAD
987+
[unreleased]: https://github.com/simgine/bevy_replicon/compare/v0.38.0...HEAD
988+
[0.38.0]: https://github.com/simgine/bevy_replicon/compare/v0.37.2...v0.38.0
982989
[0.37.2]: https://github.com/simgine/bevy_replicon/compare/v0.37.1...v0.37.2
983990
[0.37.1]: https://github.com/simgine/bevy_replicon/compare/v0.37.0...v0.37.1
984991
[0.37.0]: https://github.com/simgine/bevy_replicon/compare/v0.36.1...v0.37.0

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bevy_replicon"
3-
version = "0.37.2"
3+
version = "0.38.0"
44
authors = [
55
"Hennadii Chernyshchyk <genaloner@gmail.com>",
66
"koe <ukoe@protonmail.com>",
@@ -28,7 +28,7 @@ all-features = true
2828
members = ["example_backend"]
2929

3030
[dependencies]
31-
bevy = { version = "0.17", default-features = false, features = ["bevy_state"] }
31+
bevy = { version = "0.18", default-features = false, features = ["bevy_state"] }
3232
log = "0.4" # Directly depend on `log` like other `no_std` Bevy crates, since `bevy_log` currently requires `std`.
3333
petgraph = { version = "0.8", default-features = false, features = [
3434
"stable_graph",
@@ -51,7 +51,8 @@ bytes = { version = "1.10", default-features = false, features = [
5151
] }
5252

5353
[dev-dependencies]
54-
bevy = { version = "0.17", default-features = false, features = [
54+
ron = { version = "0.12", default-features = false }
55+
bevy = { version = "0.18", default-features = false, features = [
5556
"bevy_log",
5657
"bevy_sprite_render",
5758
"debug",

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ Depending on your game, you may need additional features. We provide an API that
7676

7777
| bevy | bevy_replicon |
7878
| ------ | ------------- |
79+
| 0.18.0 | 0.38 |
7980
| 0.17.0 | 0.36-0.37 |
8081
| 0.16.0 | 0.33-0.35 |
8182
| 0.15.0 | 0.29-0.32 |

example_backend/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bevy_replicon_example_backend"
3-
version = "0.37.0"
3+
version = "0.38.0"
44
authors = [
55
"Hennadii Chernyshchyk <genaloner@gmail.com>",
66
"koe <ukoe@protonmail.com>",
@@ -21,20 +21,20 @@ license = "MIT OR Apache-2.0"
2121
include = ["/src", "../LICENSE*"]
2222

2323
[dependencies]
24-
bevy = { version = "0.17", default-features = false, features = ["bevy_log"] }
25-
bevy_replicon = { path = "..", version = "0.37.0", default-features = false }
24+
bevy = { version = "0.18", default-features = false, features = ["bevy_log"] }
25+
bevy_replicon = { path = "..", version = "0.38.0", default-features = false }
2626
fastrand = "2.3"
2727

2828
[dev-dependencies]
29-
bevy = { version = "0.17", default-features = false, features = [
29+
bevy = { version = "0.18", default-features = false, features = [
3030
"bevy_gizmos",
3131
"bevy_text",
32-
"bevy_ui_picking_backend",
3332
"bevy_ui_render",
3433
"bevy_window",
3534
"default_font",
3635
"debug",
3736
"serialize",
37+
"ui_picking",
3838
"x11",
3939
] }
4040
clap = { version = "4.1", features = ["derive"] }

example_backend/examples/simple_button.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,10 @@ struct UiRoot;
200200
border: UiRect::all(Val::Px(5.0)),
201201
justify_content: JustifyContent::Center,
202202
align_items: AlignItems::Center,
203+
border_radius: BorderRadius::MAX,
203204
..Default::default()
204205
},
205206
BorderColor::all(Color::WHITE),
206-
BorderRadius::MAX,
207207
)]
208208
struct ToggleButton(bool);
209209

src/client.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use crate::{
2020
mutate_index::MutateIndex,
2121
registry::{
2222
ReplicationRegistry,
23-
ctx::{DespawnCtx, RemoveCtx, WriteCtx},
23+
ctx::{DespawnCtx, EntitySpawner, RemoveCtx, WriteCtx},
2424
},
2525
signature::SignatureMap,
2626
track_mutate_messages::TrackMutateMessages,
@@ -523,9 +523,9 @@ fn apply_changes(
523523
let data_size: usize = postcard_utils::from_buf(message)?;
524524

525525
let world_cell = world.as_unsafe_world_cell();
526-
let entities = world_cell.entities();
527-
// SAFETY: split into `Entities` and `DeferredEntity`.
528-
// The latter won't apply any structural changes until `flush`, and `Entities` won't be used afterward.
526+
// SAFETY: split into `EntitySpawner` and `DeferredEntity`.
527+
// The latter won't apply any structural changes until `flush`, and `EntitySpawner` won't be used afterward.
528+
let mut spawner = EntitySpawner::new(unsafe { world_cell.world_mut() });
529529
let world = unsafe { world_cell.world_mut() };
530530

531531
let mut client_entity = match params.entity_map.server_entry(server_entity) {
@@ -562,7 +562,7 @@ fn apply_changes(
562562
type_registry: params.type_registry,
563563
component_id,
564564
message_tick,
565-
entities,
565+
spawner: &mut spawner,
566566
ignore_mapping: false,
567567
};
568568
trace!(
@@ -653,9 +653,9 @@ fn apply_mutations(
653653
};
654654

655655
let world_cell = world.as_unsafe_world_cell();
656-
let entities = world_cell.entities();
657-
// SAFETY: split into `Entities` and `DeferredEntity`.
658-
// The latter won't apply any structural changes until `flush`, and `Entities` won't be used afterward.
656+
// SAFETY: split into `EntitySpawner` and `DeferredEntity`.
657+
// The latter won't apply any structural changes until `flush`, and `EntitySpawner` won't be used afterward.
658+
let mut spawner = EntitySpawner::new(unsafe { world_cell.world_mut() });
659659
let world = unsafe { world_cell.world_mut() };
660660

661661
let Ok(mut client_entity) = world
@@ -716,7 +716,7 @@ fn apply_mutations(
716716
type_registry: params.type_registry,
717717
component_id,
718718
message_tick,
719-
entities,
719+
spawner: &mut spawner,
720720
ignore_mapping: false,
721721
};
722722
trace!(

src/compact_entity.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use core::fmt::{self, Formatter};
1919

2020
use bevy::{
21-
ecs::entity::{EntityGeneration, EntityRow},
21+
ecs::entity::{EntityGeneration, EntityIndex},
2222
prelude::*,
2323
};
2424
use serde::{
@@ -36,7 +36,7 @@ use serde::{
3636
///
3737
/// See also [`deserialize`] and [`postcard_utils::entity_to_extend_mut`](crate::postcard_utils::entity_to_extend_mut).
3838
pub fn serialize<S: Serializer>(entity: &Entity, serializer: S) -> Result<S::Ok, S::Error> {
39-
let mut index = entity.index() << 1;
39+
let mut index = entity.index_u32() << 1;
4040
let has_generation = entity.generation() != EntityGeneration::FIRST;
4141
index |= has_generation as u32;
4242

@@ -79,9 +79,9 @@ impl<'de> Visitor<'de> for EntityVisitor {
7979
};
8080

8181
// SAFETY: `index` is non-max after shift.
82-
let row = unsafe { EntityRow::from_raw_u32(index >> 1).unwrap_unchecked() };
82+
let row = unsafe { EntityIndex::from_raw_u32(index >> 1).unwrap_unchecked() };
8383
let generation = EntityGeneration::from_bits(generation);
8484

85-
Ok(Entity::from_row_and_generation(row, generation))
85+
Ok(Entity::from_index_and_generation(row, generation))
8686
}
8787
}

src/postcard_utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ impl<'a, T: Buf> DeFlavor<'a> for BufFlavor<'a, T> {
212212

213213
#[cfg(test)]
214214
mod tests {
215-
use bevy::ecs::entity::{EntityGeneration, EntityRow};
215+
use bevy::ecs::entity::{EntityGeneration, EntityIndex};
216216

217217
use super::*;
218218

@@ -229,8 +229,8 @@ mod tests {
229229

230230
#[test]
231231
fn entity_with_generation() {
232-
let expected_entity = Entity::from_row_and_generation(
233-
EntityRow::from_raw_u32(1).unwrap(),
232+
let expected_entity = Entity::from_index_and_generation(
233+
EntityIndex::from_raw_u32(1).unwrap(),
234234
EntityGeneration::from_bits(1),
235235
);
236236
let mut buffer = Vec::new();

src/scene.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ So on deserialization you need to insert it back if you want entities to continu
1515
# Examples
1616
1717
```
18-
use bevy::{asset::ron, prelude::*, state::app::StatesPlugin, scene::serde::SceneDeserializer};
18+
use bevy::{prelude::*, state::app::StatesPlugin, scene::serde::SceneDeserializer};
1919
use bevy_replicon::{prelude::*, scene};
2020
use serde::de::DeserializeSeed;
2121
# let mut app = App::new();

src/server.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use core::{mem, time::Duration};
1313
use bevy::{
1414
ecs::{
1515
archetype::Archetypes,
16-
component::{CheckChangeTicks, Tick},
16+
change_detection::{CheckChangeTicks, Tick},
1717
entity::{Entities, EntityHash, EntityHashMap},
1818
intern::Interned,
1919
schedule::ScheduleLabel,
@@ -247,7 +247,7 @@ fn buffer_removals(
247247
let registry = registry.expect("registry should always exist on the server");
248248

249249
replicated_archetypes.update(archetypes, &rules);
250-
let location = entities.get(remove.entity).unwrap();
250+
let location = entities.get_spawned(remove.entity).unwrap();
251251
let Some(archetype) = replicated_archetypes.get(location.archetype_id) else {
252252
// `Replicated` component is missing.
253253
trace!(
@@ -557,7 +557,7 @@ fn collect_removals(
557557
// The client didn't see this entity.
558558
continue;
559559
};
560-
let Some(location) = entities.get(entity) else {
560+
let Ok(location) = entities.get_spawned(entity) else {
561561
warn!(
562562
"`{entity}` was despawned after despawn processing but before sending, \
563563
so the despawn will be sent on the next tick; \

0 commit comments

Comments
 (0)