lightyear_replication/receive.rs
1use crate::ReplicationSystems;
2use bevy_app::prelude::*;
3use bevy_ecs::prelude::*;
4use bevy_replicon::client::ClientSystems;
5// TODO: add special rules so that entities with Predicted/Interpolation apply components differently
6
7/// Replicated is used as a marker component to find entities that were replicated from a remote.
8///
9/// Replicon adds [`Remote`](bevy_replicon::prelude::Remote) on entities spawned
10/// from a remote, and Lightyear keeps `Replicated` as its receiver-side name.
11pub use bevy_replicon::prelude::Remote as Replicated;
12
13/// Marker component added to a link entity to enable incoming replication.
14///
15/// A link entity represents a connection to a remote peer. Adding
16/// `ReplicationReceiver` to it allows the replication systems to process
17/// entity data received through that connection.
18///
19/// On the server, this is only needed if you want to receive client-to-server
20/// entity replication (e.g. for [`PreSpawned`](crate::prespawn::PreSpawned)
21/// entities). For normal server-to-client replication, only
22/// [`ReplicationSender`](crate::send::ReplicationSender) is required on the
23/// server side.
24#[derive(Component, Default)]
25pub struct ReplicationReceiver;
26
27pub struct ReceivePlugin;
28impl Plugin for ReceivePlugin {
29 fn build(&self, app: &mut App) {
30 // make sure that any ordering relative to ReplicationSystems is also applied to ClientSystems
31 app.configure_sets(
32 PreUpdate,
33 ClientSystems::Receive.in_set(ReplicationSystems::Receive),
34 );
35 app.configure_sets(
36 PostUpdate,
37 ClientSystems::Receive.in_set(ReplicationSystems::Receive),
38 );
39 }
40}