Rework networking interface
All checks were successful
CI / Formatting (push) Successful in 1m6s

Add Bevy event queues for inbound and outbound packets, and use Bevy change detection for consumer new Peer handling.
This commit is contained in:
Michael Bradley 2025-07-05 15:01:33 -04:00
parent cceca83dac
commit c10f6cfb82
Signed by: MichaelBradley
SSH key fingerprint: SHA256:o/aaeYtRubILK7OYYjYP12DmU7BsPUhKji1AgaQ+ge4
9 changed files with 348 additions and 72 deletions

View file

@ -3,9 +3,10 @@ use std::net::SocketAddr;
use avian2d::PhysicsPlugins;
use bevy::{input::common_conditions::input_pressed, prelude::*};
use crate::net::NetIOPlugin;
use crate::net::prelude::*;
use super::{
net::{handle_deleted_peer, handle_incoming_packets, handle_new_peer},
runtime::{move_camera, move_player, quit, zoom_camera},
seed::Seed,
setup::{check_for_seed, setup_balls, setup_from_seed, setup_player, setup_ui, setup_walls},
@ -65,7 +66,15 @@ impl Plugin for GamePlugin {
)
.add_systems(
FixedUpdate,
check_for_seed.run_if(in_state(AppState::Loading)),
(
check_for_seed.run_if(in_state(AppState::Loading)),
(
handle_new_peer,
handle_deleted_peer,
handle_incoming_packets,
)
.run_if(in_state(NetworkState::MultiPlayer)),
),
)
.add_systems(
Update,