flatten component configs
This commit is contained in:
@@ -90,7 +90,7 @@ impl State for PlayerFallingState
|
||||
};
|
||||
|
||||
world.movements.with_mut(self.entity, |movement| {
|
||||
movement.movement_config.movement_context.is_floored = is_grounded;
|
||||
movement.movement_context.is_floored = is_grounded;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -116,7 +116,7 @@ impl State for PlayerIdleState
|
||||
let current_velocity = *rigidbody.linvel();
|
||||
let idle_damping = world
|
||||
.movements
|
||||
.with(self.entity, |m| m.movement_config.idle_damping)
|
||||
.with(self.entity, |m| m.idle_damping)
|
||||
.unwrap_or(0.1);
|
||||
|
||||
let horizontal_velocity = Vec3::new(current_velocity.x, 0.0, current_velocity.z);
|
||||
@@ -171,7 +171,7 @@ impl State for PlayerIdleState
|
||||
});
|
||||
|
||||
world.movements.with_mut(self.entity, |movement| {
|
||||
movement.movement_config.movement_context.is_floored = true;
|
||||
movement.movement_context.is_floored = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -210,7 +210,7 @@ impl State for PlayerWalkingState
|
||||
.inputs
|
||||
.with(self.entity, |input| input.move_direction)
|
||||
.unwrap_or(Vec3::ZERO);
|
||||
(input, movement.movement_config.clone())
|
||||
(input, movement.clone())
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
@@ -301,7 +301,7 @@ impl State for PlayerWalkingState
|
||||
});
|
||||
|
||||
world.movements.with_mut(self.entity, |movement| {
|
||||
movement.movement_config.movement_context.is_floored = terrain_height.is_some();
|
||||
movement.movement_context.is_floored = terrain_height.is_some();
|
||||
});
|
||||
|
||||
if movement_input.length_squared() > 0.1
|
||||
@@ -334,11 +334,11 @@ impl State for PlayerJumpingState
|
||||
let current_position = world.transforms.get(self.entity).unwrap().position;
|
||||
|
||||
world.jumps.with_mut(self.entity, |jump| {
|
||||
jump.jump_config.jump_context.in_progress = true;
|
||||
jump.jump_config.jump_context.execution_time = self.enter_time_stamp;
|
||||
jump.jump_config.jump_context.origin_height = current_position.y;
|
||||
jump.jump_config.jump_context.duration = 0.0;
|
||||
jump.jump_config.jump_context.normal = Vec3::Y;
|
||||
jump.jump_context.in_progress = true;
|
||||
jump.jump_context.execution_time = self.enter_time_stamp;
|
||||
jump.jump_context.origin_height = current_position.y;
|
||||
jump.jump_context.duration = 0.0;
|
||||
jump.jump_context.normal = Vec3::Y;
|
||||
});
|
||||
|
||||
println!("entered jumping");
|
||||
@@ -347,8 +347,8 @@ impl State for PlayerJumpingState
|
||||
fn on_state_exit(&mut self, world: &mut World)
|
||||
{
|
||||
world.jumps.with_mut(self.entity, |jump| {
|
||||
jump.jump_config.jump_context.in_progress = false;
|
||||
jump.jump_config.jump_context.duration = 0.0;
|
||||
jump.jump_context.in_progress = false;
|
||||
jump.jump_context.duration = 0.0;
|
||||
});
|
||||
|
||||
println!("exited jumping");
|
||||
@@ -361,21 +361,21 @@ impl State for PlayerJumpingState
|
||||
let current_time = Time::get_time_elapsed();
|
||||
|
||||
world.jumps.with_mut(self.entity, |jump| {
|
||||
jump.jump_config.jump_context.duration =
|
||||
current_time - jump.jump_config.jump_context.execution_time;
|
||||
jump.jump_context.duration =
|
||||
current_time - jump.jump_context.execution_time;
|
||||
});
|
||||
|
||||
let jump_config = world
|
||||
let jump = world
|
||||
.jumps
|
||||
.with_mut(self.entity, |jump| jump.jump_config.clone())
|
||||
.with(self.entity, |jump| jump.clone())
|
||||
.unwrap();
|
||||
|
||||
let elapsed_time = jump_config.jump_context.duration;
|
||||
let normalized_time = (elapsed_time / jump_config.jump_duration).min(1.0);
|
||||
let height_progress = jump_config.jump_curve.eval(normalized_time as f64).y as f32;
|
||||
let elapsed_time = jump.jump_context.duration;
|
||||
let normalized_time = (elapsed_time / jump.jump_duration).min(1.0);
|
||||
let height_progress = jump.jump_curve.eval(normalized_time as f64).y as f32;
|
||||
|
||||
let origin_height = jump_config.jump_context.origin_height;
|
||||
let target_height = origin_height + height_progress * jump_config.jump_height;
|
||||
let origin_height = jump.jump_context.origin_height;
|
||||
let target_height = origin_height + height_progress * jump.jump_height;
|
||||
|
||||
let current_translation = world
|
||||
.physics
|
||||
@@ -409,7 +409,7 @@ impl State for PlayerJumpingState
|
||||
});
|
||||
|
||||
world.movements.with_mut(self.entity, |movement| {
|
||||
movement.movement_config.movement_context.is_floored = false;
|
||||
movement.movement_context.is_floored = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user