3 unstable releases
0.7.0-alpha.2 | Aug 16, 2024 |
---|---|
0.7.0-alpha.1 | Jul 30, 2024 |
0.6.0 | Jul 30, 2024 |
#2023 in Game dev
105KB
1K
SLoC
aeronet_replicon
Implementation of a bevy_replicon
backend
using aeronet.
Replicon provides component-level replication for the Bevy game engine, and this crate provides the types and Bevy plugins to integrate any aeronet transport with Replicon. The transport does not necessarily even have to be networked.
Getting started
Plugins
First, you must set up a transport implementation. See the aeronet
crate for an overview of what
transports are available.
Then add the following plugins depending on if you want to use a client or a server:
- Replicon's
ClientPlugin
and this crate'sRepliconClientPlugin
- Replicon's
ServerPlugin
and this crate'sRepliconServerPlugin
After setting up and connecting your transport, you can use Replicon as normal.
use aeronet::client::ClientTransport;
use aeronet_replicon::client::RepliconClientPlugin;
use bevy::prelude::*;
use bevy_replicon::prelude::*;
#[derive(Debug, Clone, Component, serde::Serialize, serde::Deserialize)]
pub struct MyComponent { /* .. */ }
fn configure<T: ClientTransport + Resource>(app: &mut App) {
app.add_plugins((ClientPlugin, RepliconClientPlugin::<T>::default()))
.replicate::<MyComponent>()
.add_systems(Startup, setup::<T>);
}
fn setup<T: ClientTransport + Resource>(mut commands: Commands) {
let client = create_client::<T>();
commands.insert_resource(client);
}
# fn create_client<T>() -> T { unimplemented!() }
Connecting and disconnecting
All higher-level interactions with a client/server (i.e. connecting, disconnecting; anything apart from just sending data) must be done through aeronet. Replicon doesn't handle this.
Lanes and channels
Replicon's channels are analogous to our lanes. In fact, the Replicon channel ID is mapped directly to a lane index during encoding and decoding.
Client keys
On the server side, your transport's T::ClientKey
type is mapped to a Replicon ClientId
via
the ClientKeys
resource. Use this resource to map between the two.
Dependencies
~44–80MB
~1.5M SLoC