Skip to content

Commit 040bf03

Browse files
committed
Rename scene module and feature into world_serialization
1 parent d509b38 commit 040bf03

6 files changed

Lines changed: 24 additions & 22 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Changed
1111

1212
- `Replicated` is no longer automatically inserted on clients, only `Remote`. `scene::replicate_into` will serialize all entities that have either `Remote` or `Replicated`.
13+
- Rename `scene` module and feature into `world_serialization`.
1314

1415
## [0.39.3] - 2026-04-01
1516

Cargo.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ criterion = { version = "0.8", default-features = false, features = [
7171

7272

7373
[features]
74-
default = ["scene", "client", "server"]
74+
default = ["world_serialization", "client", "server"]
7575

7676
# Client-related logic.
7777
client = []
@@ -82,6 +82,9 @@ server = []
8282
# Integration with Bevy diagnostics for client.
8383
client_diagnostics = ["client"]
8484

85+
# State serialization based on replication rules.
86+
world_serialization = ["bevy/bevy_world_serialization"]
87+
8588
# Replication into a scene.
8689
scene = ["bevy/bevy_world_serialization"]
8790

@@ -126,8 +129,8 @@ name = "removal"
126129
required-features = ["client", "server"]
127130

128131
[[test]]
129-
name = "scene"
130-
required-features = ["scene", "client"]
132+
name = "world_serialization"
133+
required-features = ["world_serialization", "client"]
131134

132135
[[test]]
133136
name = "server_message"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ If you are new to networking, see [glossary](https://gist.github.com/maniwani/f9
1717
- Authorization support.
1818
- Control over client visibility of entities and components.
1919
- Specify which entities should be replicated in sync using ECS relationships.
20-
- Replication into scene to save server state.
20+
- State serialization based on replication rules.
2121
- Customizable serialization and deserialization even for types that don't implement `serde` traits (like `Box<dyn Reflect>`).
2222
- Abstracts game logic to support singleplayer, client, dedicated server, and listen server configurations simultaneously.
2323
- No builtin I/O, can be used with any messaging library. See [messaging backends](#messaging-backends) for already available integrations.

src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,13 +679,16 @@ extern crate alloc;
679679
pub mod client;
680680
pub mod compact_entity;
681681
pub mod postcard_utils;
682-
#[cfg(feature = "scene")]
683-
pub mod scene;
684682
#[cfg(feature = "server")]
685683
pub mod server;
686684
pub mod shared;
687685
#[cfg(all(feature = "server", feature = "client"))]
688686
pub mod test_app;
687+
#[cfg(any(feature = "scene", feature = "world_serialization"))]
688+
pub mod world_serialization;
689+
690+
#[cfg(feature = "scene")]
691+
compile_warning!("The `scene` feature is deprecated. Use `world_serialization` instead.");
689692

690693
pub mod prelude {
691694
pub use super::{

src/scene.rs renamed to src/world_serialization.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ start replicating them again.
1919
2020
```
2121
use bevy::{prelude::*, state::app::StatesPlugin, world_serialization::serde::WorldDeserializer};
22-
use bevy_replicon::{prelude::*, scene};
22+
use bevy_replicon::{prelude::*, world_serialization};
2323
use serde::de::DeserializeSeed;
2424
# let mut app = App::new();
2525
# app.add_plugins((StatesPlugin, AssetPlugin::default(), RepliconPlugins));
@@ -28,19 +28,14 @@ use serde::de::DeserializeSeed;
2828
let registry = app.world().resource::<AppTypeRegistry>();
2929
let type_registry = &*registry.read();
3030
let mut dyn_world = DynamicWorld::default();
31-
scene::replicate_into(&mut dyn_world, &app.world());
32-
let world_ron = dyn_world
33-
.serialize(type_registry)
34-
.expect("scene should be serialized");
31+
world_serialization::replicate_into(&mut dyn_world, &app.world());
32+
let world_ron = dyn_world.serialize(type_registry).unwrap();
3533
3634
// Deserialization
3735
let mut asset_server = app.world().resource::<AssetServer>().clone();
38-
let scene_deserializer = WorldDeserializer { type_registry, load_from_path: &mut asset_server };
39-
let mut deserializer =
40-
ron::Deserializer::from_str(&world_ron).expect("scene should be serialized as valid ron");
41-
let mut dyn_world = scene_deserializer
42-
.deserialize(&mut deserializer)
43-
.expect("ron should be convertible to scene");
36+
let world_deserializer = WorldDeserializer { type_registry, load_from_path: &mut asset_server };
37+
let mut deserializer = ron::Deserializer::from_str(&world_ron).unwrap();
38+
let mut dyn_world = world_deserializer.deserialize(&mut deserializer).unwrap();
4439
4540
// Re-insert `Replicated` component if you want to replicate them.
4641
for entity in &mut dyn_world.entities {
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use bevy::{prelude::*, state::app::StatesPlugin};
2-
use bevy_replicon::{prelude::*, scene};
2+
use bevy_replicon::{prelude::*, world_serialization};
33
use serde::{Deserialize, Serialize};
44
use test_log::test;
55

@@ -27,7 +27,7 @@ fn replicated() {
2727
let remote = app.world_mut().spawn((Remote, TestComponent)).id();
2828

2929
let mut dyn_world = DynamicWorld::default();
30-
scene::replicate_into(&mut dyn_world, app.world());
30+
world_serialization::replicate_into(&mut dyn_world, app.world());
3131

3232
let replicated_dyn = dyn_world
3333
.entities
@@ -61,7 +61,7 @@ fn empty() {
6161

6262
// Extend with replicated components.
6363
let mut dyn_world = DynamicWorld::default();
64-
scene::replicate_into(&mut dyn_world, app.world());
64+
world_serialization::replicate_into(&mut dyn_world, app.world());
6565

6666
assert!(dyn_world.resources.is_empty());
6767
assert_eq!(dyn_world.entities.len(), 1);
@@ -82,7 +82,7 @@ fn not_replicated() {
8282
app.world_mut().spawn(TestComponent);
8383

8484
let mut dyn_world = DynamicWorld::default();
85-
scene::replicate_into(&mut dyn_world, app.world());
85+
world_serialization::replicate_into(&mut dyn_world, app.world());
8686

8787
assert!(dyn_world.resources.is_empty());
8888
assert!(dyn_world.entities.is_empty());
@@ -110,7 +110,7 @@ fn update_existing() {
110110
.build();
111111

112112
// Update already extracted entity with replicated components.
113-
scene::replicate_into(&mut dyn_world, app.world());
113+
world_serialization::replicate_into(&mut dyn_world, app.world());
114114

115115
assert!(dyn_world.resources.is_empty());
116116
assert_eq!(dyn_world.entities.len(), 1);

0 commit comments

Comments
 (0)