Merge branch 'main' of github.com:Back777space/among-me

This commit is contained in:
LorrensP-2158466
2025-04-06 23:18:14 +02:00
3 changed files with 54 additions and 41 deletions

View File

@@ -164,7 +164,7 @@ fn spawn_level(
pos.with_rotation(Quat::from_rotation_y(90.0_f32.to_radians())),
),
(
round_door.clone(),
door.clone(),
pos.with_rotation(Quat::from_rotation_y(180.0_f32.to_radians())),
),
(
@@ -180,7 +180,7 @@ fn spawn_level(
pos.with_rotation(Quat::from_rotation_y(90.0_f32.to_radians())),
),
(
round_door.clone(),
door.clone(),
pos.with_rotation(Quat::from_rotation_y(0.0_f32.to_radians())),
),
(
@@ -193,7 +193,7 @@ fn spawn_level(
vec![
(wall.clone(), pos),
(
round_door.clone(),
door.clone(),
pos.with_rotation(Quat::from_rotation_y(90.0_f32.to_radians())),
),
(
@@ -206,7 +206,7 @@ fn spawn_level(
vec![
(wall.clone(), pos),
(
round_door.clone(),
door.clone(),
pos.with_rotation(Quat::from_rotation_y(270.0_f32.to_radians())),
),
(

View File

@@ -295,23 +295,33 @@ fn play_monster_sounds(
if monster.footstep_timer.just_finished() {
match monster.state {
MonsterState::Hunting => {
monster.footstep_timer = Timer::from_seconds(1.5, TimerMode::Once);
monster.footstep_timer = Timer::from_seconds(10.0, TimerMode::Once);
monster.speed = 2.0
},
MonsterState::Lurking | MonsterState::Wandering => {
monster.footstep_timer = Timer::from_seconds(
rand.random_range(3.0..7.0),
10.0,
TimerMode::Once
);
monster.speed = 1.0
},
MonsterState::Dormant => {
monster.footstep_timer = Timer::from_seconds(
rand.random_range(10.0..20.0),
10.0,
TimerMode::Once
);
monster.speed = 0.0
}
}
play_footstep_segment(audio, &audio_assets, distance, &monster.state, monster.footstep_timer.duration().as_secs_f32());
play_footstep_segment(
audio,
&audio_assets,
distance,
&monster.state,
monster.footstep_timer.duration().as_secs_f32(),
monster.speed
);
if monster.state == MonsterState::Hunting && rand.random_bool(0.3) {
println!("Monster growl!");
@@ -325,7 +335,8 @@ fn play_footstep_segment(
audio_assets: &Res<AudioAssets>,
distance: f32,
state: &MonsterState,
dur: f32
dur: f32,
speed: f32
) {
let base_volume: f32 = match state {
MonsterState::Dormant => 0.6,
@@ -335,7 +346,7 @@ fn play_footstep_segment(
};
// adjust volume based on distance (closer = louder)
let distance_factor: f32 = 1.0 - (distance / 100.0).clamp(0.0, 1.0);
let distance_factor: f32 = (1.0 - distance / 30.0).clamp(0.0, 1.0);
let volume = base_volume * distance_factor;
// play only a short segment of the footstep sound
@@ -344,10 +355,12 @@ fn play_footstep_segment(
// let mut rand = rand::rng();
// start_time += rand.random_range(0.0..5.0);
audio.stop();
audio.play(audio_assets.monster_footsteps.clone())
.with_volume(volume as f64)
.start_from((start_time as f64).min(27.0))
.fade_in(AudioTween::linear(Duration::from_millis(100)))
.with_playback_rate(speed as f64)
.handle();
println!("Monster footstep: State={:?}, Distance={:.2}, Volume={:.2}, Dur={:1}, Start={:1}",

View File

@@ -457,9 +457,9 @@ pub fn handle_spotlight(
pub fn update_flashlight_charge(time: Res<Time>, mut flashlight_query: Query<&mut Flashlight>) {
for mut flashlight in flashlight_query.iter_mut() {
if flashlight.is_on {
flashlight.charge = flashlight.charge - time.delta_secs() * 0.1;
flashlight.charge = flashlight.charge - time.delta_secs() * 0.2;
} else {
flashlight.charge = flashlight.charge + time.delta_secs() * 0.1;
flashlight.charge = flashlight.charge + time.delta_secs() * 0.2;
}
flashlight.charge = flashlight.charge.clamp(0.0, 4.0);
if flashlight.charge <= 0.0 {