* 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>
44 lines
1.3 KiB
Rust
44 lines
1.3 KiB
Rust
use bevy::prelude::*;
|
|
use lightyear::prelude::{Connected, MessageSender};
|
|
use shared::{
|
|
GameState, global_observer,
|
|
protocol::{TbMapEntityId, channels::UnorderedReliableChannel, messages::DespawnTbMapEntity},
|
|
};
|
|
|
|
pub fn plugin(app: &mut App) {
|
|
app.register_type::<DespawnedTbEntityCache>();
|
|
|
|
app.init_resource::<DespawnedTbEntityCache>();
|
|
|
|
app.add_systems(
|
|
OnEnter(GameState::MapLoading),
|
|
|mut cache: ResMut<DespawnedTbEntityCache>| cache.0.clear(),
|
|
);
|
|
|
|
global_observer!(app, add_despawned_entities_to_cache);
|
|
global_observer!(app, send_new_client_despawned_cache);
|
|
}
|
|
|
|
fn add_despawned_entities_to_cache(
|
|
trigger: On<Remove, TbMapEntityId>,
|
|
id: Query<&TbMapEntityId>,
|
|
mut cache: ResMut<DespawnedTbEntityCache>,
|
|
) {
|
|
cache.0.push(id.get(trigger.event().entity).unwrap().id);
|
|
}
|
|
|
|
#[derive(Default, Resource, Reflect)]
|
|
#[reflect(Resource)]
|
|
pub struct DespawnedTbEntityCache(pub Vec<u64>);
|
|
|
|
fn send_new_client_despawned_cache(
|
|
trigger: On<Add, Connected>,
|
|
cache: Res<DespawnedTbEntityCache>,
|
|
mut send: Query<&mut MessageSender<DespawnTbMapEntity>>,
|
|
) {
|
|
let mut send = send.get_mut(trigger.event().entity).unwrap();
|
|
for &id in cache.0.iter() {
|
|
send.send::<UnorderedReliableChannel>(DespawnTbMapEntity(id));
|
|
}
|
|
}
|