diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cad2cfb..39e85ca7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [0.11.0] - 2023-09-25 - Add high-level API to extract replicated entities into `DynamicScene`. -- Hide `ReplicationRules` low-level IDs API. +- Hide `ReplicationRules` from public API. - Move logic related to replication rules to `replicon_core::replication_rules` module. ### Changed diff --git a/src/lib.rs b/src/lib.rs index dba15718..cdcdf235 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -380,7 +380,6 @@ pub mod prelude { replicon_core::{ replication_rules::{ AppReplicationExt, Ignored, MapNetworkEntities, Mapper, Replication, - ReplicationRules, }, NetworkChannels, NetworkTick, RepliconCorePlugin, }, diff --git a/src/replicon_core/replication_rules.rs b/src/replicon_core/replication_rules.rs index 8971855b..adbfd883 100644 --- a/src/replicon_core/replication_rules.rs +++ b/src/replicon_core/replication_rules.rs @@ -81,7 +81,7 @@ impl AppReplicationExt for App { /// /// See also [`replicate_into_scene`]. #[derive(Resource)] -pub struct ReplicationRules { +pub(crate) struct ReplicationRules { /// Maps component IDs to their replication IDs. ids: HashMap, @@ -242,12 +242,10 @@ fn remove_component(entity: &mut EntityMut) { /// /// Panics if any replicated component is not registered using `register_type()` /// or missing `#[reflect(Component)]`. -pub fn replicate_into_scene( - scene: &mut DynamicScene, - world: &World, - registry: &AppTypeRegistry, - replication_rules: &ReplicationRules, -) { +pub fn replicate_into_scene(scene: &mut DynamicScene, world: &World) { + let registry = world.resource::(); + let replication_rules = world.resource::(); + let registry = registry.read(); for archetype in world .archetypes() @@ -322,10 +320,8 @@ mod tests { )) .id(); - let registry = app.world.resource::(); - let replication_rules = app.world.resource::(); let mut scene = DynamicScene::default(); - replicate_into_scene(&mut scene, &app.world, registry, replication_rules); + replicate_into_scene(&mut scene, &app.world); assert!(scene.resources.is_empty());