From 516a172a875b6c2d7f0e69b974ed59aabc530392 Mon Sep 17 00:00:00 2001 From: Angelo Fallaria Date: Sat, 3 Aug 2024 15:21:42 +0800 Subject: [PATCH] feat(traits): reduce audio distance for Light Step --- .../Movement/Systems/SharedMoverController.cs | 7 +++++++ .../Components/FootstepVolumeModifierComponent.cs | 12 ++++++++++++ Resources/Prototypes/Traits/skills.yml | 2 ++ 3 files changed, 21 insertions(+) diff --git a/Content.Shared/Movement/Systems/SharedMoverController.cs b/Content.Shared/Movement/Systems/SharedMoverController.cs index ea9772b0439..e17103682e6 100644 --- a/Content.Shared/Movement/Systems/SharedMoverController.cs +++ b/Content.Shared/Movement/Systems/SharedMoverController.cs @@ -427,6 +427,13 @@ private bool TryGetSound( var coordinates = xform.Coordinates; var distanceNeeded = mover.Sprinting ? StepSoundMoveDistanceRunning : StepSoundMoveDistanceWalking; + if (_entities.TryGetComponent(uid, out FootstepVolumeModifierComponent? volumeModifier)) + { + distanceNeeded *= mover.Sprinting + ? volumeModifier.SprintDistanceMultiplier + : volumeModifier.WalkDistanceMultiplier; + } + // Handle footsteps. if (!weightless) { diff --git a/Content.Shared/Traits/Assorted/Components/FootstepVolumeModifierComponent.cs b/Content.Shared/Traits/Assorted/Components/FootstepVolumeModifierComponent.cs index 3756ba4296f..8e0b33529ad 100644 --- a/Content.Shared/Traits/Assorted/Components/FootstepVolumeModifierComponent.cs +++ b/Content.Shared/Traits/Assorted/Components/FootstepVolumeModifierComponent.cs @@ -19,4 +19,16 @@ public sealed partial class FootstepVolumeModifierComponent : Component /// [DataField, AutoNetworkedField] public float WalkingModifier { get; set; } = 0f; + + /// + /// What to multiply the distance needed to hear sprinting by. + /// + [DataField, AutoNetworkedField] + public float SprintDistanceMultiplier { get; set; } = 1f; + + /// + /// What to multiply the distance needed to hear walking by. + /// + [DataField, AutoNetworkedField] + public float WalkDistanceMultiplier { get; set; } = 1f; } diff --git a/Resources/Prototypes/Traits/skills.yml b/Resources/Prototypes/Traits/skills.yml index fa0228ceb4a..92aa664078c 100644 --- a/Resources/Prototypes/Traits/skills.yml +++ b/Resources/Prototypes/Traits/skills.yml @@ -40,3 +40,5 @@ - type: FootstepVolumeModifier sprintingModifier: -10 walkingModifier: -10 + sprintDistanceMultiplier: 0.85 + walkDistanceMultiplier: 0.85