Skip to content

Commit

Permalink
Reduce args in replicate_into_scene and hide ReplicationRules
Browse files Browse the repository at this point in the history
  • Loading branch information
Shatur committed Sep 30, 2023
1 parent c7f4a2e commit c497dae
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,6 @@ pub mod prelude {
replicon_core::{
replication_rules::{
AppReplicationExt, Ignored, MapNetworkEntities, Mapper, Replication,
ReplicationRules,
},
NetworkChannels, NetworkTick, RepliconCorePlugin,
},
Expand Down
16 changes: 6 additions & 10 deletions src/replicon_core/replication_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ComponentId, ReplicationId>,

Expand Down Expand Up @@ -242,12 +242,10 @@ fn remove_component<C: 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::<AppTypeRegistry>();
let replication_rules = world.resource::<ReplicationRules>();

let registry = registry.read();
for archetype in world
.archetypes()
Expand Down Expand Up @@ -322,10 +320,8 @@ mod tests {
))
.id();

let registry = app.world.resource::<AppTypeRegistry>();
let replication_rules = app.world.resource::<ReplicationRules>();
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());

Expand Down

0 comments on commit c497dae

Please sign in to comment.