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:
@@ -1,23 +1,23 @@
|
||||
use crate::{
|
||||
cash::Cash, loading_assets::GameAssets, physics_layers::GameLayer, protocol::TbMapIdCounter,
|
||||
utils::global_observer,
|
||||
GameState, cash::Cash, loading_assets::GameAssets, physics_layers::GameLayer,
|
||||
protocol::TbMapIdCounter, utils::global_observer,
|
||||
};
|
||||
use avian3d::{
|
||||
parry::{na::SVector, shape::SharedShape},
|
||||
prelude::*,
|
||||
};
|
||||
use avian3d::prelude::*;
|
||||
use bevy::{
|
||||
ecs::{component::HookContext, world::DeferredWorld},
|
||||
ecs::{lifecycle::HookContext, world::DeferredWorld},
|
||||
math::*,
|
||||
prelude::*,
|
||||
};
|
||||
use bevy_trenchbroom::prelude::*;
|
||||
use happy_feet::prelude::PhysicsMover;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::f32::consts::PI;
|
||||
|
||||
#[derive(PointClass, Component, Reflect, Default)]
|
||||
#[reflect(QuakeClass, Component)]
|
||||
#[base(Transform)]
|
||||
#[point_class(base(Transform), model({ "path": "models/spawn.glb" }))]
|
||||
#[derive(Default)]
|
||||
#[component(on_add = Self::on_add)]
|
||||
#[model({ "path": "models/spawn.glb" })]
|
||||
pub struct SpawnPoint {}
|
||||
|
||||
impl SpawnPoint {
|
||||
@@ -37,85 +37,70 @@ impl SpawnPoint {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(SolidClass, Component, Reflect, Default)]
|
||||
#[reflect(QuakeClass, Component)]
|
||||
#[spawn_hooks(SpawnHooks::new().convex_collider())]
|
||||
#[solid_class(
|
||||
hooks(SpawnHooks::new().convex_collider())
|
||||
)]
|
||||
#[derive(Default)]
|
||||
pub struct Worldspawn;
|
||||
|
||||
#[derive(SolidClass, Component, Reflect, Default)]
|
||||
#[reflect(QuakeClass, Component)]
|
||||
#[spawn_hooks(SpawnHooks::new())]
|
||||
#[base(Transform)]
|
||||
#[solid_class(base(Transform), hooks(SpawnHooks::new()))]
|
||||
#[derive(Default)]
|
||||
pub struct Water;
|
||||
|
||||
#[derive(SolidClass, Component, Reflect, Default)]
|
||||
#[reflect(QuakeClass, Component)]
|
||||
#[base(Transform)]
|
||||
#[spawn_hooks(SpawnHooks::new().convex_collider())]
|
||||
#[solid_class(base(Transform), hooks(SpawnHooks::new().convex_collider()))]
|
||||
#[derive(Default)]
|
||||
pub struct Crates;
|
||||
|
||||
#[derive(SolidClass, Component, Reflect, Default)]
|
||||
#[reflect(QuakeClass, Component)]
|
||||
#[base(Transform)]
|
||||
#[spawn_hooks(SpawnHooks::new().convex_collider())]
|
||||
#[solid_class(base(Transform), hooks(SpawnHooks::new().convex_collider()))]
|
||||
#[derive(Default)]
|
||||
pub struct NamedEntity {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(SolidClass, Component, Reflect, Default)]
|
||||
#[reflect(QuakeClass, Component)]
|
||||
#[base(Transform, Target)]
|
||||
#[spawn_hooks(SpawnHooks::new().convex_collider())]
|
||||
#[require(PhysicsMover = PhysicsMover, TransformInterpolation)]
|
||||
#[solid_class(base(Transform, Target), hooks(SpawnHooks::new().convex_collider()))]
|
||||
#[derive(Default)]
|
||||
#[require(RigidBody = RigidBody::Kinematic)]
|
||||
pub struct Platform;
|
||||
|
||||
#[derive(PointClass, Component, Reflect, Default)]
|
||||
#[reflect(QuakeClass, Component)]
|
||||
#[base(Transform)]
|
||||
#[point_class(base(Transform))]
|
||||
#[derive(Default)]
|
||||
pub struct PlatformTarget {
|
||||
pub targetname: String,
|
||||
}
|
||||
|
||||
#[derive(SolidClass, Component, Reflect, Default, Serialize, Deserialize, PartialEq)]
|
||||
#[reflect(QuakeClass, Component)]
|
||||
#[base(Transform, Target)]
|
||||
#[spawn_hooks(SpawnHooks::new().convex_collider())]
|
||||
#[solid_class(base(Transform, Target), hooks(SpawnHooks::new().convex_collider()))]
|
||||
#[derive(Default, Serialize, Deserialize, PartialEq)]
|
||||
#[require(RigidBody = RigidBody::Kinematic)]
|
||||
pub struct Movable {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(PointClass, Component, Reflect, Default)]
|
||||
#[reflect(QuakeClass, Component)]
|
||||
#[base(Transform)]
|
||||
#[point_class(base(Transform))]
|
||||
#[derive(Default)]
|
||||
pub struct MoveTarget {
|
||||
pub targetname: String,
|
||||
}
|
||||
|
||||
#[derive(PointClass, Component, Reflect, Default)]
|
||||
#[reflect(QuakeClass, Component)]
|
||||
#[base(Transform)]
|
||||
#[point_class(base(Transform))]
|
||||
#[derive(Default)]
|
||||
pub struct CameraTarget {
|
||||
pub targetname: String,
|
||||
}
|
||||
|
||||
#[derive(PointClass, Component, Reflect, Default)]
|
||||
#[reflect(QuakeClass, Component)]
|
||||
#[base(Transform, Target)]
|
||||
#[point_class(base(Transform, Target))]
|
||||
#[derive(Default)]
|
||||
pub struct CutsceneCamera {
|
||||
pub name: String,
|
||||
pub targetname: String,
|
||||
}
|
||||
|
||||
#[derive(PointClass, Component, Reflect, Default)]
|
||||
#[reflect(QuakeClass, Component)]
|
||||
#[base(Transform, Target)]
|
||||
#[point_class(base(Transform, Target))]
|
||||
#[derive(Default)]
|
||||
pub struct CutsceneCameraMovementEnd;
|
||||
|
||||
#[derive(PointClass, Component, Reflect, Default)]
|
||||
#[reflect(QuakeClass, Component)]
|
||||
#[base(Transform)]
|
||||
#[point_class(base(Transform), model({ "path": "models/alien_naked.glb" }))]
|
||||
#[derive(Default)]
|
||||
#[component(on_add = Self::on_add)]
|
||||
#[model({ "path": "models/alien_naked.glb" })]
|
||||
pub struct EnemySpawn {
|
||||
pub head: String,
|
||||
pub key: String,
|
||||
@@ -151,15 +136,15 @@ impl EnemySpawn {
|
||||
Collider::capsule(0.6, 2.),
|
||||
CollisionLayers::new(LayerMask(GameLayer::Npc.to_bits()), LayerMask::ALL),
|
||||
LockedAxes::new().lock_rotation_z().lock_rotation_x(),
|
||||
#[cfg(feature = "server")]
|
||||
lightyear::prelude::Replicate::to_clients(lightyear::prelude::NetworkTarget::All),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PointClass, Component, Reflect, Default)]
|
||||
#[reflect(QuakeClass, Component)]
|
||||
#[base(Transform)]
|
||||
#[point_class(base(Transform), model({ "path": "models/cash.glb" }))]
|
||||
#[derive(Default)]
|
||||
#[component(on_add = Self::on_add)]
|
||||
#[model({ "path": "models/cash.glb" })]
|
||||
pub struct CashSpawn {}
|
||||
|
||||
impl CashSpawn {
|
||||
@@ -182,17 +167,34 @@ impl CashSpawn {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PointClass, Component, Reflect, Default)]
|
||||
#[reflect(QuakeClass, Component)]
|
||||
#[base(Transform)]
|
||||
#[model({ "path": "models/head_drop.glb" })]
|
||||
#[point_class(base(Transform), model({ "path": "models/head_drop.glb" }))]
|
||||
#[derive(Default)]
|
||||
pub struct SecretHead {
|
||||
pub head_id: usize,
|
||||
}
|
||||
|
||||
fn fix_target_tb_entities(
|
||||
mut commands: Commands,
|
||||
mut entities: Query<(Entity, &Transform, &Collider), With<Target>>,
|
||||
) {
|
||||
for (entity, tf, coll) in entities.iter_mut() {
|
||||
if let Some(shape) = coll.shape().as_compound() {
|
||||
let mut shapes: Vec<_> = shape.shapes().to_vec();
|
||||
|
||||
for shape in shapes.iter_mut() {
|
||||
shape.0.translation.vector -= SVector::<f32, 3>::from(tf.translation.to_array());
|
||||
}
|
||||
|
||||
commands
|
||||
.entity(entity)
|
||||
.insert(Collider::from(SharedShape::compound(shapes)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn plugin(app: &mut App) {
|
||||
app.register_type::<SpawnPoint>();
|
||||
app.register_type::<Worldspawn>();
|
||||
app.override_class::<Worldspawn>();
|
||||
app.register_type::<Water>();
|
||||
app.register_type::<Crates>();
|
||||
app.register_type::<NamedEntity>();
|
||||
@@ -207,14 +209,20 @@ pub fn plugin(app: &mut App) {
|
||||
app.register_type::<CashSpawn>();
|
||||
app.register_type::<SecretHead>();
|
||||
|
||||
app.add_systems(OnExit(GameState::MapLoading), fix_target_tb_entities);
|
||||
|
||||
global_observer!(app, tb_component_setup::<CashSpawn>);
|
||||
global_observer!(app, tb_component_setup::<Movable>);
|
||||
global_observer!(app, tb_component_setup::<Platform>);
|
||||
global_observer!(app, tb_component_setup::<PlatformTarget>);
|
||||
global_observer!(app, tb_component_setup::<Movable>);
|
||||
}
|
||||
|
||||
fn tb_component_setup<C: Component>(trigger: Trigger<OnAdd, C>, world: &mut World) {
|
||||
fn tb_component_setup<C: Component>(
|
||||
trigger: On<Add, C>,
|
||||
mut commands: Commands,
|
||||
mut world: DeferredWorld,
|
||||
) {
|
||||
let id = world.resource_mut::<TbMapIdCounter>().alloc();
|
||||
|
||||
world.entity_mut(trigger.target()).insert_if_new(id);
|
||||
commands.entity(trigger.event().entity).insert_if_new(id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user