#bevy #networking #gamedev #back-end

aeronet_replicon

bevy_replicon backend implementation using aeronet

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

#1843 in Game dev

Download history 221/week @ 2024-07-27 11/week @ 2024-08-03 52/week @ 2024-08-10 60/week @ 2024-08-17 2/week @ 2024-08-24

114 downloads per month

MIT/Apache

105KB
1K SLoC

aeronet_replicon

crates.io docs.rs

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:

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

~40–80MB
~1.5M SLoC