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_macros: This crate provides some helper macros.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
The Sendable type needs to implement From<&TComponent> and Into<Option<TComponent>> for every component you want to send.
The bevy_hookup_macros crate provides a simple macro to do this for single-field enum entries, which implement clone, just derive Sendable for the enum and add the sendable attribute to every field you want this to be implemented.
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
// The sendable macro is from the `bevy_hookup_macros` crate.
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.