* Get bevy 0.17 compiling and running (#72) * get bevy 0.17 compiling and running * try to fix CI breaking from const assertion for client/server features * fix `bin` -> `lib` for `shared` in CI * typo * fix some collider issues (#73) * Physics/controller improvements (#74) * trying to fix physics prediction * fixed prediction desync * substantial controller improvements * Finish off main bevy 0.17 migration (#75) * fix lookdir issues - airplane moving backwards - player model facing backwards - camera was technically backwards the whole time, and player models were facing the right way; camera is now facing forwards - firing without a target now respects lookdir * fix aim targeting * migrate to bevy_trenchbroom 0.10 crates release * fixed colliders not being adjusted out of worldspace * predict platforms to stop constant rollbacks while riding them * fix key/head drop visuals not working * Fix key/head drop random initial force * fixed static head drops duplicating * fix platform velocity inheritance * fix thrown projectiles not autorotating * fix inconsistent explosion animations * update avian3d to 0.4.1 * fix controller snapping to fixed angle upon switching heads * clean up commented code * fix broken physics positions * Clean comments, fix warnings (#77) * clean comments, fix warnings * fix missing import * steamworks 162 libs * fix mouselook --------- Co-authored-by: extrawurst <mail@rusticorn.com>
45 lines
1.4 KiB
Rust
45 lines
1.4 KiB
Rust
use bevy::ecs::{
|
|
entity::Entity,
|
|
event::{EntityEvent, Event},
|
|
system::{Commands, EntityCommands},
|
|
world::{EntityWorldMut, World},
|
|
};
|
|
use lightyear::prelude::Disconnected;
|
|
|
|
pub trait CommandExt {
|
|
fn trigger_server<'a, E: Event<Trigger<'a>: Default>>(&mut self, event: E) -> &mut Self;
|
|
}
|
|
|
|
impl<'w, 's> CommandExt for Commands<'w, 's> {
|
|
fn trigger_server<'a, E: Event<Trigger<'a>: Default>>(&mut self, event: E) -> &mut Self {
|
|
self.queue(|world: &mut World| {
|
|
let mut query_state = world.query::<&Disconnected>();
|
|
if cfg!(feature = "server") || !query_state.query(world).is_empty() {
|
|
world.trigger(event);
|
|
}
|
|
});
|
|
self
|
|
}
|
|
}
|
|
|
|
pub trait EntityCommandExt {
|
|
fn trigger_server<'a, E: EntityEvent<Trigger<'a>: Default>>(
|
|
&mut self,
|
|
event: impl FnOnce(Entity) -> E + Send + Sync + 'static,
|
|
) -> &mut Self;
|
|
}
|
|
|
|
impl<'w> EntityCommandExt for EntityCommands<'w> {
|
|
fn trigger_server<'a, E: EntityEvent<Trigger<'a>: Default>>(
|
|
&mut self,
|
|
event: impl FnOnce(Entity) -> E + Send + Sync + 'static,
|
|
) -> &mut Self {
|
|
self.queue(|mut entity: EntityWorldMut| {
|
|
let mut query_state = entity.world_scope(|world| world.query::<&Disconnected>());
|
|
if cfg!(feature = "server") || !query_state.query(entity.world()).is_empty() {
|
|
entity.trigger(event);
|
|
}
|
|
})
|
|
}
|
|
}
|