Bevy 0.17 Migration Final PR (#76)
* 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>
This commit is contained in:
@@ -10,7 +10,7 @@ use crate::{
|
||||
backpack::{Backpack, backpack_ui::BackpackUiState},
|
||||
camera::{CameraArmRotation, CameraTarget},
|
||||
cash::CashResource,
|
||||
character::{self, AnimatedCharacter},
|
||||
character::{AnimatedCharacter, HedzCharacter},
|
||||
control::{
|
||||
ControlState, ControllerSettings,
|
||||
controller_common::{MovementSpeedFactor, PlayerCharacterController},
|
||||
@@ -23,10 +23,13 @@ use crate::{
|
||||
platforms::ActivePlatform,
|
||||
player::{Player, PlayerBodyMesh},
|
||||
protocol::channels::UnorderedReliableChannel,
|
||||
utils::triggers::TriggerAppExt,
|
||||
utils::{
|
||||
auto_rotate::AutoRotation, billboards::Billboard, squish_animation::SquishAnimation,
|
||||
triggers::TriggerAppExt,
|
||||
},
|
||||
};
|
||||
use avian3d::prelude::{AngularVelocity, CollisionLayers, LinearVelocity};
|
||||
use bevy::prelude::*;
|
||||
use avian3d::prelude::{AngularVelocity, CollisionLayers, LinearVelocity, Position, Rotation};
|
||||
use bevy::{platform::collections::HashMap, prelude::*};
|
||||
pub use components::*;
|
||||
pub use events::*;
|
||||
use happy_feet::{
|
||||
@@ -38,17 +41,23 @@ use happy_feet::{
|
||||
};
|
||||
use lightyear::prelude::{
|
||||
AppChannelExt, AppComponentExt, AppMessageExt, AppTriggerExt, ChannelMode, ChannelSettings,
|
||||
NetworkDirection, PredictionMode, PredictionRegistrationExt, ReliableSettings,
|
||||
ComponentReplicationConfig, Confirmed, ConfirmedTick, InterpolationRegistrationExt,
|
||||
NetworkDirection, PredictionHistory, PredictionRegistrationExt, ReliableSettings,
|
||||
input::native::InputPlugin,
|
||||
};
|
||||
use lightyear_serde::{
|
||||
SerializationError, reader::ReadInteger, registry::SerializeFns, writer::WriteInteger,
|
||||
};
|
||||
use std::{collections::HashMap, time::Duration};
|
||||
use std::time::Duration;
|
||||
|
||||
pub fn plugin(app: &mut App) {
|
||||
app.add_plugins(InputPlugin::<ControlState>::default());
|
||||
|
||||
app.register_type::<ConfirmedTick>();
|
||||
app.register_type::<Confirmed<Position>>();
|
||||
app.register_type::<Confirmed<Rotation>>();
|
||||
app.register_type::<PredictionHistory<Position>>();
|
||||
|
||||
app.register_type::<PlayerId>();
|
||||
app.register_type::<TbMapEntityId>();
|
||||
app.register_type::<TbMapIdCounter>();
|
||||
@@ -64,9 +73,9 @@ pub fn plugin(app: &mut App) {
|
||||
})
|
||||
.add_direction(NetworkDirection::Bidirectional);
|
||||
|
||||
app.add_message::<messages::DespawnTbMapEntity>()
|
||||
app.register_message::<messages::DespawnTbMapEntity>()
|
||||
.add_direction(NetworkDirection::ServerToClient);
|
||||
app.add_message::<messages::AssignClientPlayer>()
|
||||
app.register_message::<messages::AssignClientPlayer>()
|
||||
.add_direction(NetworkDirection::ServerToClient);
|
||||
|
||||
app.register_component::<components::GltfSceneRoot>();
|
||||
@@ -75,39 +84,69 @@ pub fn plugin(app: &mut App) {
|
||||
app.register_component::<ActiveHead>();
|
||||
app.register_component::<ActiveHeads>();
|
||||
app.register_component::<ActivePlatform>();
|
||||
app.register_component::<AngularVelocity>();
|
||||
app.register_component::<AnimatedCharacter>();
|
||||
app.register_component::<AnimationFlags>();
|
||||
app.register_component::<AutoRotation>()
|
||||
.with_replication_config(ComponentReplicationConfig {
|
||||
replicate_once: true,
|
||||
..default()
|
||||
});
|
||||
app.register_component::<Backpack>();
|
||||
app.register_component::<BackpackUiState>();
|
||||
app.register_component::<Billboard>();
|
||||
app.register_component::<CameraArmRotation>();
|
||||
app.register_component::<CameraTarget>();
|
||||
app.register_component::<CashResource>();
|
||||
app.register_component::<happy_feet::prelude::Character>();
|
||||
app.register_component::<character::HedzCharacter>();
|
||||
app.register_component::<HedzCharacter>();
|
||||
app.register_component::<Healing>();
|
||||
app.register_component::<Hitpoints>();
|
||||
app.register_component::<Name>();
|
||||
app.register_component::<Player>();
|
||||
app.register_component::<PlayerBodyMesh>()
|
||||
.with_replication_config(ComponentReplicationConfig {
|
||||
replicate_once: true,
|
||||
..default()
|
||||
});
|
||||
app.register_component::<SquishAnimation>();
|
||||
|
||||
// Physics
|
||||
app.register_component::<AngularVelocity>()
|
||||
.add_prediction()
|
||||
.add_should_rollback(|this, that| this.0.distance_squared(that.0) >= 0.01f32.powf(2.0));
|
||||
app.register_component::<CollisionLayers>();
|
||||
app.register_component::<LinearVelocity>()
|
||||
.add_prediction()
|
||||
.add_should_rollback(|this, that| this.0.distance_squared(that.0) >= 0.01f32.powf(2.0));
|
||||
app.register_component::<Position>()
|
||||
.add_prediction()
|
||||
.add_should_rollback(|this, that| this.0.distance_squared(that.0) >= 0.01f32.powf(2.0))
|
||||
.add_linear_correction_fn()
|
||||
.add_linear_interpolation();
|
||||
app.register_component::<Rotation>()
|
||||
.add_prediction()
|
||||
.add_should_rollback(|this, that| this.angle_between(*that) >= 0.01)
|
||||
.add_linear_correction_fn()
|
||||
.add_linear_interpolation();
|
||||
|
||||
// Controller
|
||||
app.register_component::<CharacterDrag>();
|
||||
app.register_component::<CharacterGravity>();
|
||||
app.register_component::<CharacterMovement>();
|
||||
app.register_component::<CollisionLayers>();
|
||||
app.register_component::<ControllerSettings>();
|
||||
app.register_component::<GroundFriction>();
|
||||
app.register_component::<Grounding>();
|
||||
app.register_component::<GroundingConfig>();
|
||||
app.register_component::<GroundingState>();
|
||||
app.register_component::<Healing>();
|
||||
app.register_component::<Hitpoints>();
|
||||
app.register_component::<KinematicVelocity>();
|
||||
app.register_component::<LinearVelocity>();
|
||||
app.register_component::<MoveInput>();
|
||||
app.register_component::<MovementSpeedFactor>();
|
||||
app.register_component::<Name>();
|
||||
app.register_component::<Player>();
|
||||
app.register_component::<PlayerBodyMesh>();
|
||||
app.register_component::<PlayerCharacterController>();
|
||||
app.register_component::<PlayerCharacterController>()
|
||||
.with_replication_config(ComponentReplicationConfig {
|
||||
replicate_once: true,
|
||||
..default()
|
||||
});
|
||||
app.register_component::<SteppingConfig>();
|
||||
app.register_component::<Transform>()
|
||||
.add_prediction(PredictionMode::Full)
|
||||
.add_should_rollback(transform_should_rollback);
|
||||
|
||||
app.register_component::<UiActiveHeads>();
|
||||
// `Visibility` isn't `(De)Serialize`, so we have to provide custom serde for it.
|
||||
app.register_component_custom_serde::<Visibility>(SerializeFns {
|
||||
@@ -123,13 +162,13 @@ pub fn plugin(app: &mut App) {
|
||||
},
|
||||
});
|
||||
|
||||
app.replicate_trigger::<BuildExplosionSprite, UnorderedReliableChannel>();
|
||||
app.replicate_trigger::<StartCutscene, UnorderedReliableChannel>();
|
||||
app.replicate_event::<BuildExplosionSprite, UnorderedReliableChannel>();
|
||||
app.replicate_event::<StartCutscene, UnorderedReliableChannel>();
|
||||
|
||||
app.replicate_trigger::<events::ClientHeadChanged, UnorderedReliableChannel>();
|
||||
app.replicate_trigger::<events::PlaySound, UnorderedReliableChannel>();
|
||||
app.replicate_event::<events::ClientHeadChanged, UnorderedReliableChannel>();
|
||||
app.replicate_event::<events::PlaySound, UnorderedReliableChannel>();
|
||||
|
||||
app.add_trigger::<events::ClientEnteredPlaying>()
|
||||
app.register_event::<events::ClientEnteredPlaying>()
|
||||
.add_direction(NetworkDirection::ClientToServer);
|
||||
|
||||
app.add_systems(
|
||||
@@ -140,10 +179,6 @@ pub fn plugin(app: &mut App) {
|
||||
global_observer!(app, components::spawn_gltf_scene_roots);
|
||||
}
|
||||
|
||||
fn transform_should_rollback(this: &Transform, that: &Transform) -> bool {
|
||||
this.translation.distance_squared(that.translation) >= 0.01f32.powf(2.)
|
||||
}
|
||||
|
||||
/// A global allocator for `TbMapEntityId` values. Should be reset when a map begins loading.
|
||||
#[derive(Resource, Reflect, Default)]
|
||||
#[reflect(Resource)]
|
||||
|
||||
Reference in New Issue
Block a user