BEVY HOOKUP
A simple library for syncing bevy components over arbitrary sessions.
This repo consists of multiple crates:
bevy_hookup_core: The core part of the syncing logic, not very useful without a session implementation.bevy_hookup_messenger_self: The simplest implementation of a session, which just hooks into the same world. This can be used for singleplayer implementations. With this implementation the Entity IDs will be changed for the shared entities, so you don't have collisions of Entity IDs with the shared components.bevy_hookup_messenger_websocket: A websocket implementation for the session. It has a server and client part, but they are only different when building the connection, the sharing of entities and components works in both directions the same way.
Examples
For sharing a component you need a struct that implements the SendableComponent<TSendables> trait. You will also need to define the TSendables type, this is used to Serialize the shared components to one common type, this makes it easy for serialization and deserialization.
The following example shows how to implement a SyncName component which syncs the name of entites.
This works over all sessions, for simplicity the SelfSession is used here.
sendables.rs
sync_name.rs
// The derive of reflect is optional, makes it useful for inspecting the component in the bevy_inspector
main.rs
// This system inserts the `Owner<SyncName>` component for your owned entities.
// This systems sets the Name component from the `Shared<SyncName>` components.