flatten component configs
This commit is contained in:
@@ -6,9 +6,10 @@ use rapier3d::control::{CharacterAutostep, KinematicCharacterController};
|
||||
use rapier3d::prelude::{ColliderBuilder, RigidBodyBuilder};
|
||||
|
||||
use crate::bundles::Bundle;
|
||||
use crate::components::jump::JumpComponent;
|
||||
use crate::components::lights::spot::SpotlightComponent;
|
||||
use crate::components::{InputComponent, MeshComponent, MovementComponent, PhysicsComponent};
|
||||
use crate::components::{
|
||||
InputComponent, JumpComponent, MeshComponent, MovementComponent, PhysicsComponent,
|
||||
};
|
||||
use crate::entity::EntityHandle;
|
||||
use crate::loaders::mesh::Mesh;
|
||||
use crate::physics::PhysicsManager;
|
||||
@@ -70,7 +71,7 @@ impl Bundle for PlayerBundle
|
||||
state_machine.add_transition::<PlayerFallingState, PlayerIdleState>(move |world| {
|
||||
let is_grounded = world
|
||||
.movements
|
||||
.with(entity_id, |m| m.movement_config.movement_context.is_floored)
|
||||
.with(entity_id, |m| m.movement_context.is_floored)
|
||||
.unwrap_or(false);
|
||||
let has_input = world
|
||||
.inputs
|
||||
@@ -82,7 +83,7 @@ impl Bundle for PlayerBundle
|
||||
state_machine.add_transition::<PlayerFallingState, PlayerWalkingState>(move |world| {
|
||||
let is_grounded = world
|
||||
.movements
|
||||
.with(entity_id, |m| m.movement_config.movement_context.is_floored)
|
||||
.with(entity_id, |m| m.movement_context.is_floored)
|
||||
.unwrap_or(false);
|
||||
let has_input = world
|
||||
.inputs
|
||||
@@ -94,7 +95,7 @@ impl Bundle for PlayerBundle
|
||||
state_machine.add_transition::<PlayerIdleState, PlayerWalkingState>(move |world| {
|
||||
let is_grounded = world
|
||||
.movements
|
||||
.with(entity_id, |m| m.movement_config.movement_context.is_floored)
|
||||
.with(entity_id, |m| m.movement_context.is_floored)
|
||||
.unwrap_or(false);
|
||||
let has_input = world
|
||||
.inputs
|
||||
@@ -106,7 +107,7 @@ impl Bundle for PlayerBundle
|
||||
state_machine.add_transition::<PlayerWalkingState, PlayerIdleState>(move |world| {
|
||||
let is_grounded = world
|
||||
.movements
|
||||
.with(entity_id, |m| m.movement_config.movement_context.is_floored)
|
||||
.with(entity_id, |m| m.movement_context.is_floored)
|
||||
.unwrap_or(false);
|
||||
let has_input = world
|
||||
.inputs
|
||||
@@ -118,7 +119,7 @@ impl Bundle for PlayerBundle
|
||||
state_machine.add_transition::<PlayerIdleState, PlayerFallingState>(move |world| {
|
||||
let is_grounded = world
|
||||
.movements
|
||||
.with(entity_id, |m| m.movement_config.movement_context.is_floored)
|
||||
.with(entity_id, |m| m.movement_context.is_floored)
|
||||
.unwrap_or(false);
|
||||
!is_grounded
|
||||
});
|
||||
@@ -126,7 +127,7 @@ impl Bundle for PlayerBundle
|
||||
state_machine.add_transition::<PlayerWalkingState, PlayerFallingState>(move |world| {
|
||||
let is_grounded = world
|
||||
.movements
|
||||
.with(entity_id, |m| m.movement_config.movement_context.is_floored)
|
||||
.with(entity_id, |m| m.movement_context.is_floored)
|
||||
.unwrap_or(false);
|
||||
!is_grounded
|
||||
});
|
||||
@@ -134,7 +135,7 @@ impl Bundle for PlayerBundle
|
||||
state_machine.add_transition::<PlayerIdleState, PlayerJumpingState>(move |world| {
|
||||
let is_grounded = world
|
||||
.movements
|
||||
.with(entity_id, |m| m.movement_config.movement_context.is_floored)
|
||||
.with(entity_id, |m| m.movement_context.is_floored)
|
||||
.unwrap_or(false);
|
||||
let jump_pressed = world
|
||||
.inputs
|
||||
@@ -146,7 +147,7 @@ impl Bundle for PlayerBundle
|
||||
state_machine.add_transition::<PlayerWalkingState, PlayerJumpingState>(move |world| {
|
||||
let is_grounded = world
|
||||
.movements
|
||||
.with(entity_id, |m| m.movement_config.movement_context.is_floored)
|
||||
.with(entity_id, |m| m.movement_context.is_floored)
|
||||
.unwrap_or(false);
|
||||
let jump_pressed = world
|
||||
.inputs
|
||||
@@ -159,14 +160,14 @@ impl Bundle for PlayerBundle
|
||||
world
|
||||
.jumps
|
||||
.with(entity_id, |jump| {
|
||||
jump.jump_config.jump_context.duration >= jump.jump_config.jump_duration
|
||||
jump.jump_context.duration >= jump.jump_duration
|
||||
})
|
||||
.unwrap_or(true)
|
||||
});
|
||||
|
||||
world.transforms.insert(entity, spawn_transform);
|
||||
world.movements.insert(entity, MovementComponent::new());
|
||||
world.jumps.insert(entity, JumpComponent::new());
|
||||
world.jumps.insert(entity, JumpComponent::default());
|
||||
world.inputs.insert(entity, InputComponent::default());
|
||||
world.physics.insert(
|
||||
entity,
|
||||
@@ -189,6 +190,7 @@ impl Bundle for PlayerBundle
|
||||
);
|
||||
world.player_tags.insert(entity, ());
|
||||
world.state_machines.insert(entity, state_machine);
|
||||
world.names.insert(entity, "Player".to_string());
|
||||
|
||||
let outer_angle = PI / 2.0 * 0.9;
|
||||
world.spotlights.insert(
|
||||
|
||||
Reference in New Issue
Block a user