Update Lightyear to 0.22.4 (#59)
This commit is contained in:
@@ -11,10 +11,7 @@ use crate::{
|
||||
player::{Player, PlayerBodyMesh},
|
||||
};
|
||||
use avian3d::{math::*, prelude::*};
|
||||
use bevy::{
|
||||
ecs::{component::HookContext, world::DeferredWorld},
|
||||
prelude::*,
|
||||
};
|
||||
use bevy::prelude::*;
|
||||
use happy_feet::prelude::{
|
||||
Character, CharacterDrag, CharacterGravity, CharacterMovement, CharacterPlugins,
|
||||
GroundFriction, Grounding, GroundingConfig, KinematicVelocity, MoveInput, SteppingBehaviour,
|
||||
@@ -47,6 +44,8 @@ pub fn plugin(app: &mut App) {
|
||||
FixedPreUpdate,
|
||||
decelerate.run_if(in_state(GameState::Playing)),
|
||||
);
|
||||
|
||||
app.add_systems(Update, add_controller_bundle);
|
||||
}
|
||||
|
||||
fn set_animation_flags(
|
||||
@@ -160,20 +159,24 @@ pub struct MovementSpeedFactor(pub f32);
|
||||
|
||||
#[derive(Component, Reflect, Default, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[reflect(Component)]
|
||||
#[component(on_add = add_controller_bundle)]
|
||||
pub struct PlayerCharacterController;
|
||||
|
||||
fn add_controller_bundle(mut world: DeferredWorld, ctx: HookContext) {
|
||||
let head = world
|
||||
.entity(ctx.entity)
|
||||
.get::<ActiveHead>()
|
||||
.expect("player must be spawned with an `ActiveHead`")
|
||||
.0;
|
||||
let controls = world.resource::<HeadsDatabase>().head_stats(head).controls;
|
||||
world
|
||||
.commands()
|
||||
.entity(ctx.entity)
|
||||
.insert(CharacterControllerBundle::new(controls));
|
||||
fn add_controller_bundle(
|
||||
mut commands: Commands,
|
||||
controllers: Query<
|
||||
(Entity, &ActiveHead),
|
||||
(With<PlayerCharacterController>, Without<Character>),
|
||||
>,
|
||||
db: Option<Res<HeadsDatabase>>,
|
||||
) {
|
||||
let Some(db) = db else { return };
|
||||
|
||||
for (controller, head) in controllers {
|
||||
let controls = db.head_stats(head.0).controls;
|
||||
commands
|
||||
.entity(controller)
|
||||
.insert(CharacterControllerBundle::new(controls));
|
||||
}
|
||||
}
|
||||
|
||||
/// A bundle that contains the components needed for a basic
|
||||
|
||||
Reference in New Issue
Block a user