enter vehicles with E instead of Q, make E the "interact" key

This commit is contained in:
yuni 2024-04-03 14:21:47 +02:00
parent 85a404e49a
commit d4ddead644
2 changed files with 16 additions and 17 deletions

View file

@ -21,10 +21,10 @@ Key features:
- AWSD: accelerate - AWSD: accelerate
- Shift and Ctrl: accelerate up and down - Shift and Ctrl: accelerate up and down
- JKLUIO: mouseless camera rotation - JKLUIO: mouseless camera rotation
- e: open communication channel to nearby astronauts - e: interact: talk to people, enter vehicles
- t: toggle music (NOTE: currently no music is included in the git repo) - t: toggle music (NOTE: currently no music is included in the git repo)
- m: mute sound effects - m: mute sound effects
- q: enter/exit vehicle - q: exit vehicle
- r: rotate (hold r while moving the mouse) - r: rotate (hold r while moving the mouse)
- f: toggle 3rd person view - f: toggle 3rd person view
- TAB: toggle augmented reality overlay (HUD, low-light amplifier) - TAB: toggle augmented reality overlay (HUD, low-light amplifier)

View file

@ -247,6 +247,7 @@ pub fn handle_input(
) { ) {
let mindist = MIN_INTERACT_DISTANCE * MIN_INTERACT_DISTANCE; let mindist = MIN_INTERACT_DISTANCE * MIN_INTERACT_DISTANCE;
if keyboard_input.just_pressed(settings.key_interact) { if keyboard_input.just_pressed(settings.key_interact) {
// Talking to people
if let Ok((_player_entity, _player_actor, player)) = player.get_single() { if let Ok((_player_entity, _player_actor, player)) = player.get_single() {
for (talker, transform) in &q_talker { for (talker, transform) in &q_talker {
if transform.translation.distance_squared(player.translation) <= mindist { if transform.translation.distance_squared(player.translation) <= mindist {
@ -255,8 +256,6 @@ pub fn handle_input(
} }
} }
} }
}
else if keyboard_input.just_pressed(settings.key_vehicle) {
// Entering Vehicles // Entering Vehicles
if q_player_drives.is_empty() { if q_player_drives.is_empty() {
if let Ok((player_entity, _player_actor, player)) = player.get_single_mut() { if let Ok((player_entity, _player_actor, player)) = player.get_single_mut() {
@ -275,20 +274,20 @@ pub fn handle_input(
} }
} }
} }
}
else if keyboard_input.just_pressed(settings.key_vehicle) {
// Exiting Vehicles // Exiting Vehicles
else { if let Ok((player_entity, _player_actor, _player)) = player.get_single_mut() {
if let Ok((player_entity, _player_actor, _player)) = player.get_single_mut() { for vehicle_entity in &q_player_drives {
for vehicle_entity in &q_player_drives { commands.entity(vehicle_entity).insert(ActorVehicleBeingEntered);
commands.entity(vehicle_entity).insert(ActorVehicleBeingEntered); commands.entity(player_entity).insert(ActorEnteringVehicle);
commands.entity(player_entity).insert(ActorEnteringVehicle); ew_vehicle.send(VehicleEnterExitEvent{
ew_vehicle.send(VehicleEnterExitEvent{ vehicle: vehicle_entity,
vehicle: vehicle_entity, driver: player_entity,
driver: player_entity, is_entering: false,
is_entering: false, is_player: true,
is_player: true, });
}); break;
break;
}
} }
} }
} }