@@ -72,13 +72,19 @@ This also automatically registers the specified type, so you don't need to call
7272If your component contains [`Entity`] then it cannot be deserialized as is
7373because entity IDs are different on server and client. The client should do the
7474mapping. Therefore, to replicate such components properly, they need implement
75- [`bevy::ecs::entity::MapEntities`] and have `#[reflect(MapEntity )]`:
75+ [`bevy::ecs::entity::MapEntities`] and have `#[reflect(MapEntities )]`:
7676
7777```rust
78- # use bevy::{prelude::*, ecs::entity::{EntityMap, MapEntities, MapEntitiesError}};
78+ # use bevy::{
79+ # ecs::{
80+ # entity::{EntityMap, MapEntities, MapEntitiesError},
81+ # reflect::ReflectMapEntities,
82+ # },
83+ # prelude::*,
84+ # };
7985# use bevy_replicon::prelude::*;
8086#[derive(Component, Reflect)]
81- #[reflect(Component, MapEntity )]
87+ #[reflect(Component, MapEntities )]
8288struct MappedComponent(Entity);
8389
8490impl MapEntities for MappedComponent {
@@ -229,8 +235,14 @@ map it before sending it to the server.
229235To do this, use [`ClientEventAppExt::add_mapped_client_event()`]:
230236
231237```rust
238+ # use bevy::{
239+ # ecs::{
240+ # entity::{EntityMap, MapEntities, MapEntitiesError},
241+ # reflect::ReflectMapEntities,
242+ # },
243+ # prelude::*,
244+ # };
232245# use bevy_replicon::prelude::*;
233- # use bevy::{prelude::*, ecs::entity::{EntityMap, MapEntities, MapEntitiesError}};
234246# use serde::{Deserialize, Serialize};
235247# let mut app = App::new();
236248# app.add_plugins(ReplicationPlugins);
@@ -343,7 +355,7 @@ mod world_diff;
343355
344356pub mod prelude {
345357 pub use super :: {
346- client:: { map_entity :: ReflectMapEntity , ClientPlugin , ClientState } ,
358+ client:: { ClientPlugin , ClientState } ,
347359 network_event:: {
348360 client_event:: { ClientEventAppExt , FromClient } ,
349361 server_event:: { SendMode , ServerEventAppExt , ToClients } ,
@@ -378,14 +390,17 @@ impl PluginGroup for ReplicationPlugins {
378390#[ cfg( test) ]
379391mod tests {
380392 use bevy:: {
381- ecs:: entity:: { EntityMap , MapEntities , MapEntitiesError } ,
393+ ecs:: {
394+ entity:: { EntityMap , MapEntities , MapEntitiesError } ,
395+ reflect:: ReflectMapEntities ,
396+ } ,
382397 utils:: HashMap ,
383398 } ;
384399 use bevy_renet:: renet:: RenetClient ;
385400
386401 use super :: * ;
387402 use crate :: {
388- client:: map_entity :: { NetworkEntityMap , ReflectMapEntity } ,
403+ client:: NetworkEntityMap ,
389404 replication_core:: { AppReplicationExt , Replication } ,
390405 server:: { despawn_tracker:: DespawnTracker , removal_tracker:: RemovalTracker , AckedTicks } ,
391406 test_network:: TestNetworkPlugin ,
@@ -608,7 +623,7 @@ mod tests {
608623 }
609624
610625 #[ derive( Component , Reflect ) ]
611- #[ reflect( Component , MapEntity ) ]
626+ #[ reflect( Component , MapEntities ) ]
612627 struct MappedComponent ( Entity ) ;
613628
614629 impl MapEntities for MappedComponent {
0 commit comments