use nightshade::prelude::*;
pub fn is_grounded(world: &World, entity: Entity) -> bool {
world
.core
.get_character_controller(entity)
.map(|controller| controller.grounded)
.unwrap_or(false)
}
pub fn controller_velocity(world: &World, entity: Entity) -> Vec3 {
world
.core
.get_character_controller(entity)
.map(|controller| controller.velocity)
.unwrap_or_else(Vec3::zeros)
}
pub fn set_controller_speed(world: &mut World, entity: Entity, speed: f32) {
if let Some(controller) = world.core.get_character_controller_mut(entity) {
controller.max_speed = speed;
}
}
pub fn set_controller_jump(world: &mut World, entity: Entity, jump_impulse: f32) {
if let Some(controller) = world.core.get_character_controller_mut(entity) {
controller.jump_impulse = jump_impulse;
}
}
pub fn move_character(world: &mut World, entity: Entity, movement: Vec2, jump: bool) {
if let Some(controller) = world.core.get_character_controller_mut(entity) {
controller.external_movement = movement;
controller.external_jump = jump;
}
}