Input replication (#62)

This commit is contained in:
PROMETHIA-27
2025-08-25 03:41:28 -04:00
committed by GitHub
parent c650924d68
commit 7f6c00b5d6
20 changed files with 345 additions and 280 deletions

View File

@@ -5,6 +5,7 @@ use bevy::ecs::{
system::{Commands, EntityCommands},
world::{EntityWorldMut, World},
};
use lightyear::prelude::Disconnected;
#[derive(Default, Resource)]
pub struct IsServer;
@@ -16,7 +17,8 @@ pub trait CommandExt {
impl<'w, 's> CommandExt for Commands<'w, 's> {
fn trigger_server(&mut self, event: impl Event) -> &mut Self {
self.queue(|world: &mut World| {
if world.contains_resource::<IsServer>() {
let mut query_state = world.query::<&Disconnected>();
if world.contains_resource::<IsServer>() || !query_state.query(world).is_empty() {
world.trigger(event);
}
});