Input replication (#62)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user