distributed_physics_test/src/game/net.rs
Michael Bradley 46f00e2047
Convert game loggers to observers
These functions don't really do anything, I just want to have the code in place for reference
2025-10-18 17:49:56 -04:00

21 lines
623 B
Rust

use bevy::prelude::*;
use crate::net::prelude::*;
pub fn handle_new_peer(add: On<Add, PeerID>, peers: Query<&PeerID>) -> Result {
let peer = peers.get(add.entity)?;
info!("Game: Peer {} was added", peer.id);
Ok(())
}
pub fn handle_deleted_peer(remove: On<Remove, PeerID>, peers: Query<&PeerID>) -> Result {
let peer = peers.get(remove.entity)?;
info!("Game: Peer {} was removed", peer.id);
Ok(())
}
pub fn handle_incoming_packets(mut packets: MessageReader<InboundPacket>) {
for InboundPacket(packet) in packets.read() {
info!("Game: Packet received: {:?}", packet.message);
}
}