From d4e3ff2e8be65c8bb73290c4ffdc67743ec41a57 Mon Sep 17 00:00:00 2001 From: Adrien B Date: Wed, 28 Aug 2024 00:17:06 -0400 Subject: [PATCH 01/39] Created packet and processors for footstep audio(not functional at all yet) --- .../Processors/FootstepPacketProcessor.cs | 22 ++++++++++++++++++ NitroxModel/Packets/FootstepPacket.cs | 20 ++++++++++++++++ .../Processors/FootstepPacketProcessor.cs | 23 +++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs create mode 100644 NitroxModel/Packets/FootstepPacket.cs create mode 100644 NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs diff --git a/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs new file mode 100644 index 0000000000..d2b2c81e8f --- /dev/null +++ b/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -0,0 +1,22 @@ +using NitroxClient.Communication.Packets.Processors.Abstract; +using NitroxClient.MonoBehaviours.Gui.HUD; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using NitroxModel.Packets; + +namespace NitroxClient.Communication.Packets.Processors; +public class FootstepPacketProcessor : ClientPacketProcessor +{ + private readonly float footstepAudioRange; + public FootstepPacketProcessor(float footstepAudioRange) + { + this.footstepAudioRange = footstepAudioRange; + } + public override void Process(FootstepPacket packet) + { + Log.Info("Processing footstep packet on client"); + } +} diff --git a/NitroxModel/Packets/FootstepPacket.cs b/NitroxModel/Packets/FootstepPacket.cs new file mode 100644 index 0000000000..4e24907f3a --- /dev/null +++ b/NitroxModel/Packets/FootstepPacket.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NitroxModel.Packets +{ + public class FootstepPacket : Packet + { + private ushort playerID; + byte assetIndex; + public FootstepPacket(ushort playerID, byte assetIndex) + { + Log.Info("Creating footstep packet"); + this.playerID = playerID; + this.assetIndex = assetIndex; + } + } +} diff --git a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs new file mode 100644 index 0000000000..b2636106c1 --- /dev/null +++ b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -0,0 +1,23 @@ +using NitroxModel.Packets; +using NitroxServer.Communication.Packets.Processors.Abstract; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NitroxServer.Communication.Packets.Processors +{ + public class FootstepPacketProcessor : AuthenticatedPacketProcessor + { + private readonly float footstepAudioRange; + public FootstepPacketProcessor(float footstepAudioRange) + { + this.footstepAudioRange = footstepAudioRange; + } + public override void Process(FootstepPacket packet, Player sendingPlayer) + { + Log.Info("Processing footstep packet on server from " + sendingPlayer.Name); + } + } +} From 7e0c624bd3f267a4536146237ab89eddc4963993 Mon Sep 17 00:00:00 2001 From: Adrien B Date: Thu, 29 Aug 2024 22:10:40 -0400 Subject: [PATCH 02/39] prototype client-side footstep packet processing --- .../Processors/FootstepPacketProcessor.cs | 80 ++++++++++++++++++- NitroxModel/Packets/FootstepPacket.cs | 4 +- 2 files changed, 81 insertions(+), 3 deletions(-) diff --git a/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs index d2b2c81e8f..88d8db4124 100644 --- a/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -6,17 +6,95 @@ using System.Text; using System.Threading.Tasks; using NitroxModel.Packets; +using NitroxClient.MonoBehaviours; +using NitroxClient.GameLogic; +using UnityEngine; +using FMOD; +using FMOD.Studio; +using FMODUnity; +using NitroxClient.GameLogic.FMOD; +using NitroxClient.Unity.Helper; +using System.Collections; namespace NitroxClient.Communication.Packets.Processors; public class FootstepPacketProcessor : ClientPacketProcessor { private readonly float footstepAudioRange; - public FootstepPacketProcessor(float footstepAudioRange) + private readonly PlayerManager remotePlayerManager; + private FootstepSounds localFootstepSounds; + private PARAMETER_ID fmodIndexSpeed = FMODUWE.invalidParameterId; + private float footstepAudioRadius = 20f; + private float footstepAudioMaxVolume = 1f; + private Dictionary playerPositions = new(); + public FootstepPacketProcessor(float footstepAudioRange, PlayerManager remotePlayerManager) { this.footstepAudioRange = footstepAudioRange; + this.remotePlayerManager = remotePlayerManager; + this.localFootstepSounds = Player.mainObject.GetComponent(); + UWE.CoroutineHost.StartCoroutine(UpdatePlayerPositions()); } public override void Process(FootstepPacket packet) { Log.Info("Processing footstep packet on client"); + var player = remotePlayerManager.Find(packet.playerID); + if (!player.HasValue) + { + Log.Warn("Could not find player for footstep audio"); + return; + } + else + { + Log.Info("Player found for footstep packet on client " + player.Value.PlayerName); + FMODAsset asset; + switch (packet.assetIndex) + { + case 1: + // Precursor footstep sound + Log.Info("Precursor footstep sound identified"); + asset = localFootstepSounds.precursorInteriorSound; + break; + case 2: + // Metal footstep sound + Log.Info("Metal footstep sound identified"); + asset = localFootstepSounds.metalSound; + break; + case 3: + // Land footstep sound + Log.Info("Land footstep sound identified"); + asset = localFootstepSounds.landSound; + break; + default: + asset = null; + Log.Warn("Weird asset index for footstep audio"); + break; + } + EventInstance @event = FMODUWE.GetEvent(asset); + if (@event.isValid()) + { + if (FMODUWE.IsInvalidParameterId(fmodIndexSpeed)) + { + fmodIndexSpeed = FMODUWE.GetEventInstanceParameterIndex(@event, "speed"); + } + ATTRIBUTES_3D attributes = player.Value.Body.To3DAttributes(); + @event.set3DAttributes(attributes); + var playerVelocity = (player.Value.Body.transform.position - playerPositions[player.Value.PlayerId]) / Time.deltaTime; + @event.setParameterValueByIndex(fmodIndexSpeed, playerVelocity.magnitude); + @event.setVolume(FMODSystem.CalculateVolume(Player.mainObject.transform.position, player.Value.Body.transform.position, footstepAudioRadius, footstepAudioMaxVolume)); + @event.start(); + @event.release(); + } + } + } + IEnumerator UpdatePlayerPositions() + { + while (true) + { + var players = remotePlayerManager.GetAll(); + foreach(RemotePlayer player in players) + { + playerPositions[player.PlayerId] = player.Body.transform.position; + } + yield return new WaitForEndOfFrame(); + } } } diff --git a/NitroxModel/Packets/FootstepPacket.cs b/NitroxModel/Packets/FootstepPacket.cs index 4e24907f3a..0d72a009b9 100644 --- a/NitroxModel/Packets/FootstepPacket.cs +++ b/NitroxModel/Packets/FootstepPacket.cs @@ -8,8 +8,8 @@ namespace NitroxModel.Packets { public class FootstepPacket : Packet { - private ushort playerID; - byte assetIndex; + public readonly ushort playerID; + public readonly byte assetIndex; public FootstepPacket(ushort playerID, byte assetIndex) { Log.Info("Creating footstep packet"); From 380d9ba79e35f4cbfe68842b19f4c55216ed7caf Mon Sep 17 00:00:00 2001 From: Adrien B Date: Fri, 30 Aug 2024 07:08:08 -0400 Subject: [PATCH 03/39] Switch to using player's AnimationController to find velocity --- .../Processors/FootstepPacketProcessor.cs | 23 ++++--------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs index 88d8db4124..04ea67e9fa 100644 --- a/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -23,15 +23,13 @@ public class FootstepPacketProcessor : ClientPacketProcessor private readonly PlayerManager remotePlayerManager; private FootstepSounds localFootstepSounds; private PARAMETER_ID fmodIndexSpeed = FMODUWE.invalidParameterId; - private float footstepAudioRadius = 20f; - private float footstepAudioMaxVolume = 1f; - private Dictionary playerPositions = new(); + private readonly float footstepAudioRadius = 20f; + private readonly float footstepAudioMaxVolume = 1f; public FootstepPacketProcessor(float footstepAudioRange, PlayerManager remotePlayerManager) { this.footstepAudioRange = footstepAudioRange; this.remotePlayerManager = remotePlayerManager; this.localFootstepSounds = Player.mainObject.GetComponent(); - UWE.CoroutineHost.StartCoroutine(UpdatePlayerPositions()); } public override void Process(FootstepPacket packet) { @@ -44,7 +42,7 @@ public override void Process(FootstepPacket packet) } else { - Log.Info("Player found for footstep packet on client " + player.Value.PlayerName); + Log.Info($"Player found for footstep packet on client {player.Value.PlayerName}"); FMODAsset asset; switch (packet.assetIndex) { @@ -77,24 +75,11 @@ public override void Process(FootstepPacket packet) } ATTRIBUTES_3D attributes = player.Value.Body.To3DAttributes(); @event.set3DAttributes(attributes); - var playerVelocity = (player.Value.Body.transform.position - playerPositions[player.Value.PlayerId]) / Time.deltaTime; - @event.setParameterValueByIndex(fmodIndexSpeed, playerVelocity.magnitude); + @event.setParameterValueByIndex(fmodIndexSpeed, player.Value.AnimationController.Velocity.magnitude); @event.setVolume(FMODSystem.CalculateVolume(Player.mainObject.transform.position, player.Value.Body.transform.position, footstepAudioRadius, footstepAudioMaxVolume)); @event.start(); @event.release(); } } } - IEnumerator UpdatePlayerPositions() - { - while (true) - { - var players = remotePlayerManager.GetAll(); - foreach(RemotePlayer player in players) - { - playerPositions[player.PlayerId] = player.Body.transform.position; - } - yield return new WaitForEndOfFrame(); - } - } } From e07a5c30a9988ddf19a5b13b812df599bd1d1c04 Mon Sep 17 00:00:00 2001 From: Adrien B Date: Sun, 1 Sep 2024 20:38:38 -0400 Subject: [PATCH 04/39] Footstep packets are forwarded from server to players within hearing range(20f) --- .../Processors/FootstepPacketProcessor.cs | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs index b2636106c1..5a4f0f9e5a 100644 --- a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -1,23 +1,32 @@ +using NitroxModel.DataStructures.Unity; using NitroxModel.Packets; using NitroxServer.Communication.Packets.Processors.Abstract; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using NitroxServer.GameLogic; +using System.Numerics; namespace NitroxServer.Communication.Packets.Processors { public class FootstepPacketProcessor : AuthenticatedPacketProcessor { private readonly float footstepAudioRange; - public FootstepPacketProcessor(float footstepAudioRange) + private readonly PlayerManager playerManager; + public FootstepPacketProcessor(float footstepAudioRange, PlayerManager playerManager) { this.footstepAudioRange = footstepAudioRange; + this.playerManager = playerManager; } - public override void Process(FootstepPacket packet, Player sendingPlayer) + public override void Process(FootstepPacket footstepPacket, Player sendingPlayer) { Log.Info("Processing footstep packet on server from " + sendingPlayer.Name); + var players = playerManager.GetAllPlayers(); + foreach(Player player in players) + { + if(NitroxVector3.Distance(player.Position, sendingPlayer.Position) <= footstepAudioRange) + { + // Forward footstep packet to players if they are within range to hear it + playerManager.SendPacketToOtherPlayers(footstepPacket, sendingPlayer); + } + } } } } From 180bb35322aab94123b07e023bd413f2d204b394 Mon Sep 17 00:00:00 2001 From: Adrien B Date: Sun, 1 Sep 2024 21:30:37 -0400 Subject: [PATCH 05/39] Fixed FootstepPacket class to fit format(was crashing) --- NitroxModel/Packets/FootstepPacket.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/NitroxModel/Packets/FootstepPacket.cs b/NitroxModel/Packets/FootstepPacket.cs index 0d72a009b9..dee294d6b9 100644 --- a/NitroxModel/Packets/FootstepPacket.cs +++ b/NitroxModel/Packets/FootstepPacket.cs @@ -3,13 +3,13 @@ using System.Linq; using System.Text; using System.Threading.Tasks; - namespace NitroxModel.Packets { + [Serializable] public class FootstepPacket : Packet { - public readonly ushort playerID; - public readonly byte assetIndex; + public ushort playerID { get; } + public byte assetIndex { get; } public FootstepPacket(ushort playerID, byte assetIndex) { Log.Info("Creating footstep packet"); From 26db96c7911f4263be3956513a33a356d52867bb Mon Sep 17 00:00:00 2001 From: Adrien B Date: Sun, 1 Sep 2024 21:31:42 -0400 Subject: [PATCH 06/39] Removed duplicate var --- .../Packets/Processors/FootstepPacketProcessor.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs index 5a4f0f9e5a..3741fc59ff 100644 --- a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -2,17 +2,15 @@ using NitroxModel.Packets; using NitroxServer.Communication.Packets.Processors.Abstract; using NitroxServer.GameLogic; -using System.Numerics; namespace NitroxServer.Communication.Packets.Processors { public class FootstepPacketProcessor : AuthenticatedPacketProcessor { - private readonly float footstepAudioRange; + private readonly float footstepAudioRange = 20f; private readonly PlayerManager playerManager; - public FootstepPacketProcessor(float footstepAudioRange, PlayerManager playerManager) + public FootstepPacketProcessor(PlayerManager playerManager) { - this.footstepAudioRange = footstepAudioRange; this.playerManager = playerManager; } public override void Process(FootstepPacket footstepPacket, Player sendingPlayer) From a772c16e5bbb433cbdde25a3a66b0a8237fae510 Mon Sep 17 00:00:00 2001 From: Adrien B Date: Sun, 1 Sep 2024 21:32:20 -0400 Subject: [PATCH 07/39] cleanup --- .../Packets/Processors/FootstepPacketProcessor.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs index 04ea67e9fa..4673df5d1f 100644 --- a/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -19,15 +19,13 @@ namespace NitroxClient.Communication.Packets.Processors; public class FootstepPacketProcessor : ClientPacketProcessor { - private readonly float footstepAudioRange; private readonly PlayerManager remotePlayerManager; - private FootstepSounds localFootstepSounds; + private readonly FootstepSounds localFootstepSounds; private PARAMETER_ID fmodIndexSpeed = FMODUWE.invalidParameterId; private readonly float footstepAudioRadius = 20f; private readonly float footstepAudioMaxVolume = 1f; - public FootstepPacketProcessor(float footstepAudioRange, PlayerManager remotePlayerManager) + public FootstepPacketProcessor(PlayerManager remotePlayerManager) { - this.footstepAudioRange = footstepAudioRange; this.remotePlayerManager = remotePlayerManager; this.localFootstepSounds = Player.mainObject.GetComponent(); } From eaf112222f7f2797aaffa2d585b38a5114f66a84 Mon Sep 17 00:00:00 2001 From: Adrien B Date: Mon, 2 Sep 2024 10:36:48 -0400 Subject: [PATCH 08/39] Added transpiler to send packets when local client plays footstep sound(TYSM for the help Jannify) Co-authored-by: Jannify <24827220+Jannify@users.noreply.github.com> --- .../Processors/FootstepPacketProcessor.cs | 22 +++------ NitroxModel/Packets/FootstepPacket.cs | 14 +++--- .../Dynamic/FootstepSounds_OnStep_Patch.cs | 45 +++++++++++++++++-- 3 files changed, 55 insertions(+), 26 deletions(-) diff --git a/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs index 4673df5d1f..f88547209f 100644 --- a/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -1,20 +1,13 @@ using NitroxClient.Communication.Packets.Processors.Abstract; -using NitroxClient.MonoBehaviours.Gui.HUD; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using NitroxModel.Packets; -using NitroxClient.MonoBehaviours; using NitroxClient.GameLogic; -using UnityEngine; using FMOD; using FMOD.Studio; using FMODUnity; using NitroxClient.GameLogic.FMOD; -using NitroxClient.Unity.Helper; -using System.Collections; +using NitroxModel.Helper; +using System.Collections.Generic; +using System.Reflection.Emit; namespace NitroxClient.Communication.Packets.Processors; public class FootstepPacketProcessor : ClientPacketProcessor @@ -44,18 +37,15 @@ public override void Process(FootstepPacket packet) FMODAsset asset; switch (packet.assetIndex) { - case 1: - // Precursor footstep sound + case FootstepPacket.StepSounds.PRECURSOR_STEP_SOUND: Log.Info("Precursor footstep sound identified"); asset = localFootstepSounds.precursorInteriorSound; break; - case 2: - // Metal footstep sound + case FootstepPacket.StepSounds.METAL_STEP_SOUND: Log.Info("Metal footstep sound identified"); asset = localFootstepSounds.metalSound; break; - case 3: - // Land footstep sound + case FootstepPacket.StepSounds.LAND_STEP_SOUND: Log.Info("Land footstep sound identified"); asset = localFootstepSounds.landSound; break; diff --git a/NitroxModel/Packets/FootstepPacket.cs b/NitroxModel/Packets/FootstepPacket.cs index dee294d6b9..9e6cfda023 100644 --- a/NitroxModel/Packets/FootstepPacket.cs +++ b/NitroxModel/Packets/FootstepPacket.cs @@ -1,20 +1,22 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace NitroxModel.Packets { [Serializable] public class FootstepPacket : Packet { public ushort playerID { get; } - public byte assetIndex { get; } - public FootstepPacket(ushort playerID, byte assetIndex) + public StepSounds assetIndex { get; } + public FootstepPacket(ushort playerID, StepSounds assetIndex) { Log.Info("Creating footstep packet"); this.playerID = playerID; this.assetIndex = assetIndex; } + public enum StepSounds : byte + { + PRECURSOR_STEP_SOUND, + METAL_STEP_SOUND, + LAND_STEP_SOUND + } } } diff --git a/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs b/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs index d14a8124f7..a4c785aab2 100644 --- a/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs @@ -1,19 +1,25 @@ -using System; +using System; using System.Collections.Generic; using System.Reflection; using System.Reflection.Emit; using FMOD.Studio; using HarmonyLib; +using NitroxClient.GameLogic; using NitroxClient.GameLogic.FMOD; using NitroxModel.GameLogic.FMOD; using NitroxModel.Helper; +using NitroxModel.Packets; +using NitroxPatcher.PatternMatching; using UnityEngine; - +using NitroxClient.Communication.Abstract; namespace NitroxPatcher.Patches.Dynamic; public sealed partial class FootstepSounds_OnStep_Patch : NitroxPatch, IDynamicPatch { private const string EXO_STEP_SOUND_PATH = "event:/sub/exo/step"; + private const string PRECURSOR_STEP_SOUND_PATH = "event:/player/footstep_precursor_base"; + private const string METAL_STEP_SOUND_PATH = "event:/player/footstep_metal"; + internal static readonly MethodInfo TARGET_METHOD = Reflect.Method((FootstepSounds t) => t.OnStep(default)); @@ -39,8 +45,16 @@ public static IEnumerable Transpiler(IEnumerable CalculateVolume(default, default, default, default))) - ) - .InstructionEnumeration(); + ).MatchEndForward(new CodeMatch(OpCodes.Call, Reflect.Method((FMOD.Studio.EventInstance t) => t.release())), + new CodeMatch(OpCodes.Pop)) + .Advance(1) + .InsertAndAdvance(new CodeInstruction(OpCodes.Ldloc_0)) + .Insert(new CodeInstruction(OpCodes.Call, Reflect.Method(() => SendFootstepPacket(default)))) + .InstructionEnumeration(); + /* event.release(); + * SendFootstepPacket(asset); + * asset in this case is the FMOD asset of the footstep sound that was played + * */ } // This method is called very often and should therefore be performant @@ -61,4 +75,27 @@ private static float CalculateVolume(float originalVolume, FootstepSounds instan Resolve().TryGetSoundData(EXO_STEP_SOUND_PATH, out SoundData soundData); return soundData.Radius; }); + public static void SendFootstepPacket(FMODAsset asset) + { + // Send footstep packet with the asset + var localPlayer = Resolve(); + if (localPlayer.PlayerId.HasValue) + { + FootstepPacket.StepSounds assetIndex; + if (asset.path == PRECURSOR_STEP_SOUND_PATH) + { + assetIndex = FootstepPacket.StepSounds.PRECURSOR_STEP_SOUND; + } + else if (asset.path == METAL_STEP_SOUND_PATH) + { + assetIndex = FootstepPacket.StepSounds.METAL_STEP_SOUND; + } + else + { + assetIndex = FootstepPacket.StepSounds.LAND_STEP_SOUND; + } + var footstepPacket = new FootstepPacket(localPlayer.PlayerId.Value, assetIndex); + Resolve().Send(footstepPacket); + } + } } From a8796569ef66de48c417e0cd881cd0c96c78afce Mon Sep 17 00:00:00 2001 From: Adrien B Date: Mon, 2 Sep 2024 17:14:05 -0400 Subject: [PATCH 09/39] Lower volume of other players' footsteps(suggested by NinjaPedroX) --- .../Communication/Packets/Processors/FootstepPacketProcessor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs index f88547209f..5bbe1efe32 100644 --- a/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -16,7 +16,7 @@ public class FootstepPacketProcessor : ClientPacketProcessor private readonly FootstepSounds localFootstepSounds; private PARAMETER_ID fmodIndexSpeed = FMODUWE.invalidParameterId; private readonly float footstepAudioRadius = 20f; - private readonly float footstepAudioMaxVolume = 1f; + private readonly float footstepAudioMaxVolume = 0.5f; public FootstepPacketProcessor(PlayerManager remotePlayerManager) { this.remotePlayerManager = remotePlayerManager; From 8ef98425d610fffc30ec66c0d169e5863eac090e Mon Sep 17 00:00:00 2001 From: Adrien B Date: Mon, 2 Sep 2024 17:58:25 -0400 Subject: [PATCH 10/39] Added same structure/submarine check for sending footstep packet to other player --- .../Packets/Processors/FootstepPacketProcessor.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs index 3741fc59ff..1169b6ec8d 100644 --- a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -17,12 +17,13 @@ public override void Process(FootstepPacket footstepPacket, Player sendingPlayer { Log.Info("Processing footstep packet on server from " + sendingPlayer.Name); var players = playerManager.GetAllPlayers(); - foreach(Player player in players) + foreach (Player player in players) { - if(NitroxVector3.Distance(player.Position, sendingPlayer.Position) <= footstepAudioRange) + if (NitroxVector3.Distance(player.Position, sendingPlayer.Position) <= footstepAudioRange && player.SubRootId.Equals(sendingPlayer.SubRootId.Value) + && player != sendingPlayer) { - // Forward footstep packet to players if they are within range to hear it - playerManager.SendPacketToOtherPlayers(footstepPacket, sendingPlayer); + // Forward footstep packet to players if they are within range to hear it and are in the same structure / submarine + player.SendPacket(footstepPacket); } } } From 092af1678a49c46f8af80f2bab01a5c20146ef9b Mon Sep 17 00:00:00 2001 From: Adrien B Date: Sat, 7 Sep 2024 10:32:09 -0400 Subject: [PATCH 11/39] Removed logs --- .../Processors/FootstepPacketProcessor.cs | 7 ---- NitroxModel/Packets/FootstepPacket.cs | 1 - .../Processors/FootstepPacketProcessor.cs | 32 +++++++++++++++---- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs index 5bbe1efe32..abedaa9985 100644 --- a/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -24,34 +24,27 @@ public FootstepPacketProcessor(PlayerManager remotePlayerManager) } public override void Process(FootstepPacket packet) { - Log.Info("Processing footstep packet on client"); var player = remotePlayerManager.Find(packet.playerID); if (!player.HasValue) { - Log.Warn("Could not find player for footstep audio"); return; } else { - Log.Info($"Player found for footstep packet on client {player.Value.PlayerName}"); FMODAsset asset; switch (packet.assetIndex) { case FootstepPacket.StepSounds.PRECURSOR_STEP_SOUND: - Log.Info("Precursor footstep sound identified"); asset = localFootstepSounds.precursorInteriorSound; break; case FootstepPacket.StepSounds.METAL_STEP_SOUND: - Log.Info("Metal footstep sound identified"); asset = localFootstepSounds.metalSound; break; case FootstepPacket.StepSounds.LAND_STEP_SOUND: - Log.Info("Land footstep sound identified"); asset = localFootstepSounds.landSound; break; default: asset = null; - Log.Warn("Weird asset index for footstep audio"); break; } EventInstance @event = FMODUWE.GetEvent(asset); diff --git a/NitroxModel/Packets/FootstepPacket.cs b/NitroxModel/Packets/FootstepPacket.cs index 9e6cfda023..e750218518 100644 --- a/NitroxModel/Packets/FootstepPacket.cs +++ b/NitroxModel/Packets/FootstepPacket.cs @@ -8,7 +8,6 @@ public class FootstepPacket : Packet public StepSounds assetIndex { get; } public FootstepPacket(ushort playerID, StepSounds assetIndex) { - Log.Info("Creating footstep packet"); this.playerID = playerID; this.assetIndex = assetIndex; } diff --git a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs index 1169b6ec8d..f3eb8a2e17 100644 --- a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -15,17 +15,37 @@ public FootstepPacketProcessor(PlayerManager playerManager) } public override void Process(FootstepPacket footstepPacket, Player sendingPlayer) { - Log.Info("Processing footstep packet on server from " + sendingPlayer.Name); var players = playerManager.GetAllPlayers(); foreach (Player player in players) { - if (NitroxVector3.Distance(player.Position, sendingPlayer.Position) <= footstepAudioRange && player.SubRootId.Equals(sendingPlayer.SubRootId.Value) - && player != sendingPlayer) + if (sendingPlayer.SubRootId.HasValue) { - // Forward footstep packet to players if they are within range to hear it and are in the same structure / submarine - player.SendPacket(footstepPacket); + if (player.SubRootId.HasValue) + { + // If both players have id's, check if they are the same + if (NitroxVector3.Distance(player.Position, sendingPlayer.Position) <= footstepAudioRange && player != sendingPlayer && player.SubRootId.Value == sendingPlayer.SubRootId.Value) + { + // Forward footstep packet to players if they are within range to hear it and are in the same structure / submarine + player.SendPacket(footstepPacket); + } + } + // If one player has an id and the other doesn't, automatically false + } + else + { + // if both player's don't have SubRootIds + if (!player.SubRootId.HasValue) + { + if (NitroxVector3.Distance(player.Position, sendingPlayer.Position) <= footstepAudioRange && player != sendingPlayer) + { + // Forward footstep packet to players if they are within range to hear it and are in the same structure / submarine + player.SendPacket(footstepPacket); + } + } + // If one player doesn't have an id and other does, automatically false + + } } - } } } } From c6814b3d1288867cd26df34cf0ebd1e70ee50775 Mon Sep 17 00:00:00 2001 From: Adrien B Date: Sat, 7 Sep 2024 12:41:35 -0400 Subject: [PATCH 12/39] Formatting changes --- NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs | 2 +- .../Packets/Processors/FootstepPacketProcessor.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs b/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs index a4c785aab2..3bcff7eb09 100644 --- a/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs @@ -19,7 +19,7 @@ public sealed partial class FootstepSounds_OnStep_Patch : NitroxPatch, IDynamicP private const string EXO_STEP_SOUND_PATH = "event:/sub/exo/step"; private const string PRECURSOR_STEP_SOUND_PATH = "event:/player/footstep_precursor_base"; private const string METAL_STEP_SOUND_PATH = "event:/player/footstep_metal"; - + internal static readonly MethodInfo TARGET_METHOD = Reflect.Method((FootstepSounds t) => t.OnStep(default)); diff --git a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs index f3eb8a2e17..1a5c2ea0f0 100644 --- a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -43,9 +43,9 @@ public override void Process(FootstepPacket footstepPacket, Player sendingPlayer } } // If one player doesn't have an id and other does, automatically false - - } + } + } } } } From 737028e4de617315c17a898544bce40a7a127c99 Mon Sep 17 00:00:00 2001 From: Adrien B Date: Sat, 7 Sep 2024 13:10:39 -0400 Subject: [PATCH 13/39] Formatting changes --- .../Packets/Processors/FootstepPacketProcessor.cs | 9 +++------ .../Patches/Dynamic/FootstepSounds_OnStep_Patch.cs | 11 +++++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs index abedaa9985..f92c00c17d 100644 --- a/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -1,13 +1,10 @@ -using NitroxClient.Communication.Packets.Processors.Abstract; -using NitroxModel.Packets; -using NitroxClient.GameLogic; using FMOD; using FMOD.Studio; using FMODUnity; +using NitroxClient.Communication.Packets.Processors.Abstract; +using NitroxClient.GameLogic; using NitroxClient.GameLogic.FMOD; -using NitroxModel.Helper; -using System.Collections.Generic; -using System.Reflection.Emit; +using NitroxModel.Packets; namespace NitroxClient.Communication.Packets.Processors; public class FootstepPacketProcessor : ClientPacketProcessor diff --git a/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs b/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs index 3bcff7eb09..c3b9f2bc38 100644 --- a/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs @@ -1,17 +1,16 @@ -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Reflection.Emit; using FMOD.Studio; using HarmonyLib; +using NitroxClient.Communication.Abstract; using NitroxClient.GameLogic; using NitroxClient.GameLogic.FMOD; using NitroxModel.GameLogic.FMOD; using NitroxModel.Helper; using NitroxModel.Packets; -using NitroxPatcher.PatternMatching; +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Reflection.Emit; using UnityEngine; -using NitroxClient.Communication.Abstract; namespace NitroxPatcher.Patches.Dynamic; public sealed partial class FootstepSounds_OnStep_Patch : NitroxPatch, IDynamicPatch From 103c14e46c28fde87325674fe705d110dc566e4d Mon Sep 17 00:00:00 2001 From: Adrien Bourdeaux Date: Wed, 18 Sep 2024 15:37:29 -0400 Subject: [PATCH 14/39] Newline changes --- .../Packets/Processors/FootstepPacketProcessor.cs | 3 +++ NitroxModel/Packets/FootstepPacket.cs | 3 +++ .../Packets/Processors/FootstepPacketProcessor.cs | 3 ++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs index f92c00c17d..6dd2fbcf9f 100644 --- a/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -7,6 +7,7 @@ using NitroxModel.Packets; namespace NitroxClient.Communication.Packets.Processors; + public class FootstepPacketProcessor : ClientPacketProcessor { private readonly PlayerManager remotePlayerManager; @@ -14,11 +15,13 @@ public class FootstepPacketProcessor : ClientPacketProcessor private PARAMETER_ID fmodIndexSpeed = FMODUWE.invalidParameterId; private readonly float footstepAudioRadius = 20f; private readonly float footstepAudioMaxVolume = 0.5f; + public FootstepPacketProcessor(PlayerManager remotePlayerManager) { this.remotePlayerManager = remotePlayerManager; this.localFootstepSounds = Player.mainObject.GetComponent(); } + public override void Process(FootstepPacket packet) { var player = remotePlayerManager.Find(packet.playerID); diff --git a/NitroxModel/Packets/FootstepPacket.cs b/NitroxModel/Packets/FootstepPacket.cs index e750218518..8cf14861fa 100644 --- a/NitroxModel/Packets/FootstepPacket.cs +++ b/NitroxModel/Packets/FootstepPacket.cs @@ -1,4 +1,5 @@ using System; + namespace NitroxModel.Packets { [Serializable] @@ -6,11 +7,13 @@ public class FootstepPacket : Packet { public ushort playerID { get; } public StepSounds assetIndex { get; } + public FootstepPacket(ushort playerID, StepSounds assetIndex) { this.playerID = playerID; this.assetIndex = assetIndex; } + public enum StepSounds : byte { PRECURSOR_STEP_SOUND, diff --git a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs index 1a5c2ea0f0..17f4cf4934 100644 --- a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -9,10 +9,12 @@ public class FootstepPacketProcessor : AuthenticatedPacketProcessor Date: Wed, 18 Sep 2024 16:23:38 -0400 Subject: [PATCH 15/39] newline changes --- .../Dynamic/FootstepSounds_OnStep_Patch.cs | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs b/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs index c3b9f2bc38..d236b0a21a 100644 --- a/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs @@ -1,3 +1,7 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Reflection.Emit; using FMOD.Studio; using HarmonyLib; using NitroxClient.Communication.Abstract; @@ -6,11 +10,8 @@ using NitroxModel.GameLogic.FMOD; using NitroxModel.Helper; using NitroxModel.Packets; -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Reflection.Emit; using UnityEngine; + namespace NitroxPatcher.Patches.Dynamic; public sealed partial class FootstepSounds_OnStep_Patch : NitroxPatch, IDynamicPatch @@ -19,19 +20,24 @@ public sealed partial class FootstepSounds_OnStep_Patch : NitroxPatch, IDynamicP private const string PRECURSOR_STEP_SOUND_PATH = "event:/player/footstep_precursor_base"; private const string METAL_STEP_SOUND_PATH = "event:/player/footstep_metal"; - internal static readonly MethodInfo TARGET_METHOD = Reflect.Method((FootstepSounds t) => t.OnStep(default)); public static IEnumerable Transpiler(IEnumerable instructions) { /* From: - evt.setVolume(volume); To: - evt.setVolume(CalculateVolume(volume, this, asset, xform)); + + + From: + event.release(); + + To: + event.release(); + SendFootstepPacket(asset); */ return new CodeMatcher(instructions) @@ -44,16 +50,15 @@ public static IEnumerable Transpiler(IEnumerable CalculateVolume(default, default, default, default))) - ).MatchEndForward(new CodeMatch(OpCodes.Call, Reflect.Method((FMOD.Studio.EventInstance t) => t.release())), - new CodeMatch(OpCodes.Pop)) - .Advance(1) - .InsertAndAdvance(new CodeInstruction(OpCodes.Ldloc_0)) - .Insert(new CodeInstruction(OpCodes.Call, Reflect.Method(() => SendFootstepPacket(default)))) - .InstructionEnumeration(); - /* event.release(); - * SendFootstepPacket(asset); - * asset in this case is the FMOD asset of the footstep sound that was played - * */ + ) + .MatchEndForward( + new CodeMatch(OpCodes.Call, Reflect.Method((EventInstance evt) => evt.release())), + new CodeMatch(OpCodes.Pop) + ) + .Advance(1) + .InsertAndAdvance(new CodeInstruction(OpCodes.Ldloc_0)) + .Insert(new CodeInstruction(OpCodes.Call, Reflect.Method(() => SendFootstepPacket(default)))) + .InstructionEnumeration(); } // This method is called very often and should therefore be performant @@ -74,6 +79,7 @@ private static float CalculateVolume(float originalVolume, FootstepSounds instan Resolve().TryGetSoundData(EXO_STEP_SOUND_PATH, out SoundData soundData); return soundData.Radius; }); + public static void SendFootstepPacket(FMODAsset asset) { // Send footstep packet with the asset From 91936ec866e7841446ad8a3a396f19e72645c985 Mon Sep 17 00:00:00 2001 From: Adrien B Date: Wed, 18 Sep 2024 16:47:12 -0400 Subject: [PATCH 16/39] Split long line into shorter lines Co-authored-by: Jannify <23176718+Jannify@users.noreply.github.com> --- .../Packets/Processors/FootstepPacketProcessor.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs index 17f4cf4934..594ea8d72c 100644 --- a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -25,7 +25,8 @@ public override void Process(FootstepPacket footstepPacket, Player sendingPlayer if (player.SubRootId.HasValue) { // If both players have id's, check if they are the same - if (NitroxVector3.Distance(player.Position, sendingPlayer.Position) <= footstepAudioRange && player != sendingPlayer && player.SubRootId.Value == sendingPlayer.SubRootId.Value) + if (NitroxVector3.Distance(player.Position, sendingPlayer.Position) <= footstepAudioRange && + player != sendingPlayer && player.SubRootId.Value == sendingPlayer.SubRootId.Value) { // Forward footstep packet to players if they are within range to hear it and are in the same structure / submarine player.SendPacket(footstepPacket); From 65455838bead2d97bca3a6d78c903288c72ef9a0 Mon Sep 17 00:00:00 2001 From: Adrien B Date: Wed, 18 Sep 2024 16:49:49 -0400 Subject: [PATCH 17/39] Remove unneeded this keyword Co-authored-by: Jannify <23176718+Jannify@users.noreply.github.com> --- .../Communication/Packets/Processors/FootstepPacketProcessor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs index 6dd2fbcf9f..0f617289b4 100644 --- a/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -19,7 +19,7 @@ public class FootstepPacketProcessor : ClientPacketProcessor public FootstepPacketProcessor(PlayerManager remotePlayerManager) { this.remotePlayerManager = remotePlayerManager; - this.localFootstepSounds = Player.mainObject.GetComponent(); + localFootstepSounds = Player.mainObject.GetComponent(); } public override void Process(FootstepPacket packet) From 33d249c4ea84f2297dc7782bbb2a9e00d2441e3e Mon Sep 17 00:00:00 2001 From: Adrien Bourdeaux Date: Wed, 18 Sep 2024 17:08:42 -0400 Subject: [PATCH 18/39] Applying suggestions from Jannify's review Co-authored-by: Jannify <23176718+Jannify@users.noreply.github.com> --- .../Processors/FootstepPacketProcessor.cs | 49 +++++++---------- NitroxModel/Packets/FootstepPacket.cs | 32 ++++++------ .../Dynamic/FootstepSounds_OnStep_Patch.cs | 28 +++++----- .../Processors/FootstepPacketProcessor.cs | 52 +++++++------------ 4 files changed, 64 insertions(+), 97 deletions(-) diff --git a/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs index 6dd2fbcf9f..ac4bb6fd82 100644 --- a/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -13,8 +13,8 @@ public class FootstepPacketProcessor : ClientPacketProcessor private readonly PlayerManager remotePlayerManager; private readonly FootstepSounds localFootstepSounds; private PARAMETER_ID fmodIndexSpeed = FMODUWE.invalidParameterId; - private readonly float footstepAudioRadius = 20f; - private readonly float footstepAudioMaxVolume = 0.5f; + private const float footstepAudioRadius = 20f; + private const float footstepAudioMaxVolume = 0.5f; public FootstepPacketProcessor(PlayerManager remotePlayerManager) { @@ -24,42 +24,29 @@ public FootstepPacketProcessor(PlayerManager remotePlayerManager) public override void Process(FootstepPacket packet) { - var player = remotePlayerManager.Find(packet.playerID); - if (!player.HasValue) + var player = remotePlayerManager.Find(packet.PlayerID); + if (player.HasValue) { - return; - } - else - { - FMODAsset asset; - switch (packet.assetIndex) + FMODAsset asset = packet.AssetIndex switch { - case FootstepPacket.StepSounds.PRECURSOR_STEP_SOUND: - asset = localFootstepSounds.precursorInteriorSound; - break; - case FootstepPacket.StepSounds.METAL_STEP_SOUND: - asset = localFootstepSounds.metalSound; - break; - case FootstepPacket.StepSounds.LAND_STEP_SOUND: - asset = localFootstepSounds.landSound; - break; - default: - asset = null; - break; - } - EventInstance @event = FMODUWE.GetEvent(asset); - if (@event.isValid()) + FootstepPacket.StepSounds.PRECURSOR_STEP_SOUND => localFootstepSounds.precursorInteriorSound, + FootstepPacket.StepSounds.METAL_STEP_SOUND => localFootstepSounds.metalSound, + FootstepPacket.StepSounds.LAND_STEP_SOUND => localFootstepSounds.landSound, + _ => null + }; + EventInstance evt = FMODUWE.GetEvent(asset); + if (evt.isValid()) { if (FMODUWE.IsInvalidParameterId(fmodIndexSpeed)) { - fmodIndexSpeed = FMODUWE.GetEventInstanceParameterIndex(@event, "speed"); + fmodIndexSpeed = FMODUWE.GetEventInstanceParameterIndex(evt, "speed"); } ATTRIBUTES_3D attributes = player.Value.Body.To3DAttributes(); - @event.set3DAttributes(attributes); - @event.setParameterValueByIndex(fmodIndexSpeed, player.Value.AnimationController.Velocity.magnitude); - @event.setVolume(FMODSystem.CalculateVolume(Player.mainObject.transform.position, player.Value.Body.transform.position, footstepAudioRadius, footstepAudioMaxVolume)); - @event.start(); - @event.release(); + evt.set3DAttributes(attributes); + evt.setParameterValueByIndex(fmodIndexSpeed, player.Value.AnimationController.Velocity.magnitude); + evt.setVolume(FMODSystem.CalculateVolume(Player.mainObject.transform.position, player.Value.Body.transform.position, footstepAudioRadius, footstepAudioMaxVolume)); + evt.start(); + evt.release(); } } } diff --git a/NitroxModel/Packets/FootstepPacket.cs b/NitroxModel/Packets/FootstepPacket.cs index 8cf14861fa..31d70c2a10 100644 --- a/NitroxModel/Packets/FootstepPacket.cs +++ b/NitroxModel/Packets/FootstepPacket.cs @@ -1,24 +1,22 @@ using System; -namespace NitroxModel.Packets +namespace NitroxModel.Packets; +[Serializable] +public class FootstepPacket : Packet { - [Serializable] - public class FootstepPacket : Packet - { - public ushort playerID { get; } - public StepSounds assetIndex { get; } + public ushort PlayerID { get; } + public StepSounds AssetIndex { get; } - public FootstepPacket(ushort playerID, StepSounds assetIndex) - { - this.playerID = playerID; - this.assetIndex = assetIndex; - } + public FootstepPacket(ushort playerID, StepSounds assetIndex) + { + this.PlayerID = playerID; + this.AssetIndex = assetIndex; + } - public enum StepSounds : byte - { - PRECURSOR_STEP_SOUND, - METAL_STEP_SOUND, - LAND_STEP_SOUND - } + public enum StepSounds : byte + { + PRECURSOR_STEP_SOUND, + METAL_STEP_SOUND, + LAND_STEP_SOUND } } diff --git a/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs b/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs index d236b0a21a..3eb67d1403 100644 --- a/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs @@ -80,26 +80,24 @@ private static float CalculateVolume(float originalVolume, FootstepSounds instan return soundData.Radius; }); - public static void SendFootstepPacket(FMODAsset asset) + private static void SendFootstepPacket(FMODAsset asset) { - // Send footstep packet with the asset - var localPlayer = Resolve(); - if (localPlayer.PlayerId.HasValue) + if (Resolve().PlayerId.HasValue) { FootstepPacket.StepSounds assetIndex; - if (asset.path == PRECURSOR_STEP_SOUND_PATH) + switch (asset.path) { - assetIndex = FootstepPacket.StepSounds.PRECURSOR_STEP_SOUND; + case PRECURSOR_STEP_SOUND_PATH: + assetIndex = FootstepPacket.StepSounds.PRECURSOR_STEP_SOUND; + break; + case METAL_STEP_SOUND_PATH: + assetIndex = FootstepPacket.StepSounds.METAL_STEP_SOUND; + break; + default: + assetIndex = FootstepPacket.StepSounds.LAND_STEP_SOUND; + break; } - else if (asset.path == METAL_STEP_SOUND_PATH) - { - assetIndex = FootstepPacket.StepSounds.METAL_STEP_SOUND; - } - else - { - assetIndex = FootstepPacket.StepSounds.LAND_STEP_SOUND; - } - var footstepPacket = new FootstepPacket(localPlayer.PlayerId.Value, assetIndex); + FootstepPacket footstepPacket = new(Resolve().PlayerId.Value, assetIndex); Resolve().Send(footstepPacket); } } diff --git a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs index 17f4cf4934..365624eadb 100644 --- a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -3,48 +3,32 @@ using NitroxServer.Communication.Packets.Processors.Abstract; using NitroxServer.GameLogic; -namespace NitroxServer.Communication.Packets.Processors +namespace NitroxServer.Communication.Packets.Processors; +public class FootstepPacketProcessor : AuthenticatedPacketProcessor { - public class FootstepPacketProcessor : AuthenticatedPacketProcessor - { - private readonly float footstepAudioRange = 20f; - private readonly PlayerManager playerManager; + private readonly float footstepAudioRange = 20f; + private readonly PlayerManager playerManager; - public FootstepPacketProcessor(PlayerManager playerManager) - { - this.playerManager = playerManager; - } + public FootstepPacketProcessor(PlayerManager playerManager) + { + this.playerManager = playerManager; + } - public override void Process(FootstepPacket footstepPacket, Player sendingPlayer) + public override void Process(FootstepPacket footstepPacket, Player sendingPlayer) + { + foreach (Player player in playerManager.GetAllPlayers()) { - var players = playerManager.GetAllPlayers(); - foreach (Player player in players) + if (NitroxVector3.Distance(player.Position, sendingPlayer.Position) <= footstepAudioRange && player != sendingPlayer) { - if (sendingPlayer.SubRootId.HasValue) + // Forward footstep packet to players if they are within range to hear it and are in the same structure / submarine + if (sendingPlayer.SubRootId.HasValue && player.SubRootId.HasValue && + sendingPlayer.SubRootId.Value == player.SubRootId.Value) { - if (player.SubRootId.HasValue) - { - // If both players have id's, check if they are the same - if (NitroxVector3.Distance(player.Position, sendingPlayer.Position) <= footstepAudioRange && player != sendingPlayer && player.SubRootId.Value == sendingPlayer.SubRootId.Value) - { - // Forward footstep packet to players if they are within range to hear it and are in the same structure / submarine - player.SendPacket(footstepPacket); - } - } - // If one player has an id and the other doesn't, automatically false + player.SendPacket(footstepPacket); } - else + else if (!sendingPlayer.SubRootId.HasValue && !player.SubRootId.HasValue) { - // if both player's don't have SubRootIds - if (!player.SubRootId.HasValue) - { - if (NitroxVector3.Distance(player.Position, sendingPlayer.Position) <= footstepAudioRange && player != sendingPlayer) - { - // Forward footstep packet to players if they are within range to hear it and are in the same structure / submarine - player.SendPacket(footstepPacket); - } - } - // If one player doesn't have an id and other does, automatically false + player.SendPacket(footstepPacket); } } } From c1d0ef34875c61ac347dc838fe851a5c432849c3 Mon Sep 17 00:00:00 2001 From: Adrien Bourdeaux Date: Wed, 18 Sep 2024 17:20:14 -0400 Subject: [PATCH 19/39] Added comment in packet processors to keep values updated, trying to implement fetching the value from .csv file --- .../Communication/Packets/Processors/FootstepPacketProcessor.cs | 2 +- .../Communication/Packets/Processors/FootstepPacketProcessor.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs index e006850fd9..ab1e5248b8 100644 --- a/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -13,7 +13,7 @@ public class FootstepPacketProcessor : ClientPacketProcessor private readonly PlayerManager remotePlayerManager; private readonly FootstepSounds localFootstepSounds; private PARAMETER_ID fmodIndexSpeed = FMODUWE.invalidParameterId; - private const float footstepAudioRadius = 20f; + private const float footstepAudioRadius = 20f; // Make sure this matches the value in the server packet processor FootstepPacketProcessor.cs private const float footstepAudioMaxVolume = 0.5f; public FootstepPacketProcessor(PlayerManager remotePlayerManager) diff --git a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs index 225f72cea6..f6ac0b68fe 100644 --- a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -6,7 +6,7 @@ namespace NitroxServer.Communication.Packets.Processors; public class FootstepPacketProcessor : AuthenticatedPacketProcessor { - private readonly float footstepAudioRange = 20f; + private const float footstepAudioRange = 20f; // Make sure this matches the value in the client-side packet processor FootstepPacketProcessor.cs private readonly PlayerManager playerManager; public FootstepPacketProcessor(PlayerManager playerManager) From c4c851fbe9d79c2e94a5918fa6acec7d3f484f5d Mon Sep 17 00:00:00 2001 From: Adrien Bourdeaux Date: Wed, 18 Sep 2024 18:26:53 -0400 Subject: [PATCH 20/39] Pull sound range from .csv file(UNTESTED) --- .../Resources/SoundWhitelist_Subnautica.csv | 6 +-- .../Processors/FootstepPacketProcessor.cs | 7 ++- .../Processors/FootstepPacketProcessor.cs | 48 ++++++++++--------- 3 files changed, 33 insertions(+), 28 deletions(-) diff --git a/Nitrox.Assets.Subnautica/Resources/SoundWhitelist_Subnautica.csv b/Nitrox.Assets.Subnautica/Resources/SoundWhitelist_Subnautica.csv index 8126ea99e7..865ae5be4a 100644 --- a/Nitrox.Assets.Subnautica/Resources/SoundWhitelist_Subnautica.csv +++ b/Nitrox.Assets.Subnautica/Resources/SoundWhitelist_Subnautica.csv @@ -281,9 +281,9 @@ event:/player/enzyme_cure;false;false;0 event:/player/food_critical;false;false;0 event:/player/food_low;false;false;0 event:/player/food_very_low;false;false;0 -event:/player/footstep_dirt;false;false;0 -event:/player/footstep_metal;false;false;0 -event:/player/footstep_precursor_base;false;false;0 +event:/player/footstep_dirt;false;false;20 +event:/player/footstep_metal;false;false;20 +event:/player/footstep_precursor_base;false;false;20 event:/player/goal_airsack;false;false;0 event:/player/goal_BiomeKelpForest;false;false;0 event:/player/goal_BiomePrecursorGunUpper;false;false;0 diff --git a/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs index ab1e5248b8..68d739b330 100644 --- a/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -4,6 +4,7 @@ using NitroxClient.Communication.Packets.Processors.Abstract; using NitroxClient.GameLogic; using NitroxClient.GameLogic.FMOD; +using NitroxModel.GameLogic.FMOD; using NitroxModel.Packets; namespace NitroxClient.Communication.Packets.Processors; @@ -13,13 +14,15 @@ public class FootstepPacketProcessor : ClientPacketProcessor private readonly PlayerManager remotePlayerManager; private readonly FootstepSounds localFootstepSounds; private PARAMETER_ID fmodIndexSpeed = FMODUWE.invalidParameterId; - private const float footstepAudioRadius = 20f; // Make sure this matches the value in the server packet processor FootstepPacketProcessor.cs + private readonly float footstepAudioRadius; // To modify this value, modify the last value in the SoundWhitelist_Subnautica.csv file private const float footstepAudioMaxVolume = 0.5f; - public FootstepPacketProcessor(PlayerManager remotePlayerManager) + public FootstepPacketProcessor(PlayerManager remotePlayerManager, FMODWhitelist whitelist) { this.remotePlayerManager = remotePlayerManager; localFootstepSounds = Player.mainObject.GetComponent(); + whitelist.TryGetSoundData("event:/player/footstep_precursor_base", out SoundData soundData); + footstepAudioRadius = soundData.Radius; } public override void Process(FootstepPacket packet) diff --git a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs index f6ac0b68fe..7b4a658e9c 100644 --- a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -1,4 +1,5 @@ using NitroxModel.DataStructures.Unity; +using NitroxModel.GameLogic.FMOD; using NitroxModel.Packets; using NitroxServer.Communication.Packets.Processors.Abstract; using NitroxServer.GameLogic; @@ -6,45 +7,46 @@ namespace NitroxServer.Communication.Packets.Processors; public class FootstepPacketProcessor : AuthenticatedPacketProcessor { - private const float footstepAudioRange = 20f; // Make sure this matches the value in the client-side packet processor FootstepPacketProcessor.cs + private readonly float footstepAudioRange; // To modify this value, modify the last value in the SoundWhitelist_Subnautica.csv file private readonly PlayerManager playerManager; - public FootstepPacketProcessor(PlayerManager playerManager) + public FootstepPacketProcessor(PlayerManager playerManager, FMODWhitelist whitelist) { this.playerManager = playerManager; + whitelist.TryGetSoundData("event:/player/footstep_precursor_base", out SoundData soundData); + footstepAudioRange = soundData.Radius; } - public override void Process(FootstepPacket footstepPacket, Player sendingPlayer) + public override void Process(FootstepPacket footstepPacket, Player sendingPlayer) + { + var players = playerManager.GetAllPlayers(); + foreach (Player player in players) { - var players = playerManager.GetAllPlayers(); - foreach (Player player in players) + if (sendingPlayer.SubRootId.HasValue) { - if (sendingPlayer.SubRootId.HasValue) + if (player.SubRootId.HasValue) { - if (player.SubRootId.HasValue) + // If both players have id's, check if they are the same + if (NitroxVector3.Distance(player.Position, sendingPlayer.Position) <= footstepAudioRange && player != sendingPlayer && player.SubRootId.Value == sendingPlayer.SubRootId.Value) { - // If both players have id's, check if they are the same - if (NitroxVector3.Distance(player.Position, sendingPlayer.Position) <= footstepAudioRange && player != sendingPlayer && player.SubRootId.Value == sendingPlayer.SubRootId.Value) - { - // Forward footstep packet to players if they are within range to hear it and are in the same structure / submarine - player.SendPacket(footstepPacket); - } + // Forward footstep packet to players if they are within range to hear it and are in the same structure / submarine + player.SendPacket(footstepPacket); } - // If one player has an id and the other doesn't, automatically false } - else + // If one player has an id and the other doesn't, automatically false + } + else + { + // if both player's don't have SubRootIds + if (!player.SubRootId.HasValue) { - // if both player's don't have SubRootIds - if (!player.SubRootId.HasValue) + if (NitroxVector3.Distance(player.Position, sendingPlayer.Position) <= footstepAudioRange && player != sendingPlayer) { - if (NitroxVector3.Distance(player.Position, sendingPlayer.Position) <= footstepAudioRange && player != sendingPlayer) - { - // Forward footstep packet to players if they are within range to hear it and are in the same structure / submarine - player.SendPacket(footstepPacket); - } + // Forward footstep packet to players if they are within range to hear it and are in the same structure / submarine + player.SendPacket(footstepPacket); } - // If one player doesn't have an id and other does, automatically false } + // If one player doesn't have an id and other does, automatically false } } } From 756beceb719d69b2b9449bba75ff979d031f3fc4 Mon Sep 17 00:00:00 2001 From: Adrien Bourdeaux Date: Tue, 24 Sep 2024 15:25:14 -0400 Subject: [PATCH 21/39] Add whitespace Co-authored-by: Jannify <23176718+Jannify@users.noreply.github.com> --- NitroxModel/Packets/FootstepPacket.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/NitroxModel/Packets/FootstepPacket.cs b/NitroxModel/Packets/FootstepPacket.cs index 31d70c2a10..fb4b1de947 100644 --- a/NitroxModel/Packets/FootstepPacket.cs +++ b/NitroxModel/Packets/FootstepPacket.cs @@ -1,6 +1,7 @@ using System; namespace NitroxModel.Packets; + [Serializable] public class FootstepPacket : Packet { From 30055b8542c355fea5204244ffae236373513638 Mon Sep 17 00:00:00 2001 From: Adrien Bourdeaux Date: Tue, 24 Sep 2024 15:25:25 -0400 Subject: [PATCH 22/39] Add whitespace Co-authored-by: Jannify <23176718+Jannify@users.noreply.github.com> --- .../Communication/Packets/Processors/FootstepPacketProcessor.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs index 7b4a658e9c..58b5f6ea50 100644 --- a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -5,6 +5,7 @@ using NitroxServer.GameLogic; namespace NitroxServer.Communication.Packets.Processors; + public class FootstepPacketProcessor : AuthenticatedPacketProcessor { private readonly float footstepAudioRange; // To modify this value, modify the last value in the SoundWhitelist_Subnautica.csv file From d26a1869ec80218941637f7763b2608ff9e90c0f Mon Sep 17 00:00:00 2001 From: Adrien Bourdeaux Date: Tue, 24 Sep 2024 17:13:03 -0400 Subject: [PATCH 23/39] Merged ifs and removed var type usage --- .../Processors/FootstepPacketProcessor.cs | 3 +- .../Processors/FootstepPacketProcessor.cs | 31 ++++++------------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs index 68d739b330..e7fdb51f24 100644 --- a/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -4,6 +4,7 @@ using NitroxClient.Communication.Packets.Processors.Abstract; using NitroxClient.GameLogic; using NitroxClient.GameLogic.FMOD; +using NitroxModel.DataStructures.Util; using NitroxModel.GameLogic.FMOD; using NitroxModel.Packets; @@ -27,7 +28,7 @@ public FootstepPacketProcessor(PlayerManager remotePlayerManager, FMODWhitelist public override void Process(FootstepPacket packet) { - var player = remotePlayerManager.Find(packet.PlayerID); + Optional player = remotePlayerManager.Find(packet.PlayerID); if (player.HasValue) { FMODAsset asset = packet.AssetIndex switch diff --git a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs index 7b4a658e9c..ffcea826a8 100644 --- a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -19,34 +19,23 @@ public FootstepPacketProcessor(PlayerManager playerManager, FMODWhitelist whitel public override void Process(FootstepPacket footstepPacket, Player sendingPlayer) { - var players = playerManager.GetAllPlayers(); - foreach (Player player in players) + foreach (Player player in playerManager.GetAllPlayers()) { - if (sendingPlayer.SubRootId.HasValue) + if (player.SubRootId.HasValue && sendingPlayer.SubRootId.HasValue && + NitroxVector3.Distance(player.Position, sendingPlayer.Position) <= footstepAudioRange && + player != sendingPlayer && + player.SubRootId.Value == sendingPlayer.SubRootId.Value) { - if (player.SubRootId.HasValue) - { - // If both players have id's, check if they are the same - if (NitroxVector3.Distance(player.Position, sendingPlayer.Position) <= footstepAudioRange && player != sendingPlayer && player.SubRootId.Value == sendingPlayer.SubRootId.Value) - { - // Forward footstep packet to players if they are within range to hear it and are in the same structure / submarine - player.SendPacket(footstepPacket); - } - } - // If one player has an id and the other doesn't, automatically false + player.SendPacket(footstepPacket); } else { - // if both player's don't have SubRootIds - if (!player.SubRootId.HasValue) + if (NitroxVector3.Distance(player.Position, sendingPlayer.Position) <= footstepAudioRange && + player != sendingPlayer && + !player.SubRootId.HasValue) { - if (NitroxVector3.Distance(player.Position, sendingPlayer.Position) <= footstepAudioRange && player != sendingPlayer) - { - // Forward footstep packet to players if they are within range to hear it and are in the same structure / submarine - player.SendPacket(footstepPacket); - } + player.SendPacket(footstepPacket); } - // If one player doesn't have an id and other does, automatically false } } } From 38c6161d6fbac6af58765ddb3e70f3746231621e Mon Sep 17 00:00:00 2001 From: Adrien Bourdeaux Date: Tue, 24 Sep 2024 17:15:00 -0400 Subject: [PATCH 24/39] Merged else + if into else if --- .../Packets/Processors/FootstepPacketProcessor.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs index 7bf7ad66c7..ae3850bebe 100644 --- a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -29,14 +29,11 @@ public override void Process(FootstepPacket footstepPacket, Player sendingPlayer { player.SendPacket(footstepPacket); } - else - { - if (NitroxVector3.Distance(player.Position, sendingPlayer.Position) <= footstepAudioRange && + else if (NitroxVector3.Distance(player.Position, sendingPlayer.Position) <= footstepAudioRange && player != sendingPlayer && !player.SubRootId.HasValue) - { - player.SendPacket(footstepPacket); - } + { + player.SendPacket(footstepPacket); } } } From 9a5927b39b8906d2427e676116c951d03653d7df Mon Sep 17 00:00:00 2001 From: Adrien Bourdeaux Date: Tue, 24 Sep 2024 17:23:24 -0400 Subject: [PATCH 25/39] Inverted if with early return condition --- .../Packets/Processors/FootstepPacketProcessor.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs index ae3850bebe..d304afa848 100644 --- a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -22,15 +22,20 @@ public override void Process(FootstepPacket footstepPacket, Player sendingPlayer { foreach (Player player in playerManager.GetAllPlayers()) { + if(NitroxVector3.Distance(player.Position, sendingPlayer.Position) >= footstepAudioRange) + { + continue; + } + if(player != sendingPlayer) + { + continue; + } if (player.SubRootId.HasValue && sendingPlayer.SubRootId.HasValue && - NitroxVector3.Distance(player.Position, sendingPlayer.Position) <= footstepAudioRange && - player != sendingPlayer && player.SubRootId.Value == sendingPlayer.SubRootId.Value) { player.SendPacket(footstepPacket); } else if (NitroxVector3.Distance(player.Position, sendingPlayer.Position) <= footstepAudioRange && - player != sendingPlayer && !player.SubRootId.HasValue) { player.SendPacket(footstepPacket); From 38c1aa72dad482a567b462165a0b12c8ee32db22 Mon Sep 17 00:00:00 2001 From: Adrien Bourdeaux Date: Wed, 25 Sep 2024 22:18:31 -0400 Subject: [PATCH 26/39] Compare subroot IDs using .Equals instead of 2 if statements --- .../Packets/Processors/FootstepPacketProcessor.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs index d304afa848..dda30feae1 100644 --- a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -30,13 +30,7 @@ public override void Process(FootstepPacket footstepPacket, Player sendingPlayer { continue; } - if (player.SubRootId.HasValue && sendingPlayer.SubRootId.HasValue && - player.SubRootId.Value == sendingPlayer.SubRootId.Value) - { - player.SendPacket(footstepPacket); - } - else if (NitroxVector3.Distance(player.Position, sendingPlayer.Position) <= footstepAudioRange && - !player.SubRootId.HasValue) + if(player.SubRootId.Equals(sendingPlayer.SubRootId)) { player.SendPacket(footstepPacket); } From 6d4dcbf95db5165bb354bd6e3544f649f8297199 Mon Sep 17 00:00:00 2001 From: Adrien Bourdeaux Date: Thu, 26 Sep 2024 17:37:31 -0400 Subject: [PATCH 27/39] Overriding .Equals in Optional<> for consistency and performance Co-authored-by: Jannify <23176718+Jannify@users.noreply.github.com> --- .../Model/DataStructures/Util/OptionalTest.cs | 21 ++++++++++++++- NitroxModel/DataStructures/Optional.cs | 26 ++++++++++++++++++- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/Nitrox.Test/Model/DataStructures/Util/OptionalTest.cs b/Nitrox.Test/Model/DataStructures/Util/OptionalTest.cs index efe88723b7..f0dce93dfd 100644 --- a/Nitrox.Test/Model/DataStructures/Util/OptionalTest.cs +++ b/Nitrox.Test/Model/DataStructures/Util/OptionalTest.cs @@ -1,4 +1,4 @@ -using System; +using System; using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -100,6 +100,25 @@ public void OptionalHasValueDynamicChecks() cAsObj.HasValue.Should().BeTrue(); ((C)cAsObj.Value).Threshold.Should().Be(203); } + [TestMethod] + public void OptionalEqualsCheck() + { + Optional op = Optional.OfNullable(null); + Optional op1 = Optional.OfNullable(null); + Optional op2 = Optional.Of("Test"); + Optional op3 = Optional.Of("Test2"); + Optional op4 = Optional.Of("Test"); + + Assert.IsFalse(op.Equals(op2)); + Assert.IsFalse(op.Equals(op3)); + Assert.IsFalse(op2.Equals(op3)); + + Assert.IsTrue(op.Equals(op1)); + Assert.IsTrue(op2.Equals(op4)); + + Assert.IsTrue(op != op2); + Assert.IsTrue(op2 == op4); + } private class Base { diff --git a/NitroxModel/DataStructures/Optional.cs b/NitroxModel/DataStructures/Optional.cs index 657b9e68f7..feb039c0e8 100644 --- a/NitroxModel/DataStructures/Optional.cs +++ b/NitroxModel/DataStructures/Optional.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Runtime.Serialization; using System.Security.Permissions; @@ -150,6 +150,30 @@ public static explicit operator T(Optional value) { return value.Value; } + public bool Equals(Optional other) + { + return EqualityComparer.Default.Equals(Value, other.Value); + } + + public override bool Equals(object obj) + { + return obj is Optional other && Equals(other); + } + + public override int GetHashCode() + { + return EqualityComparer.Default.GetHashCode(Value); + } + + public static bool operator ==(Optional left, Optional right) + { + return left.Equals(right); + } + + public static bool operator !=(Optional left, Optional right) + { + return !left.Equals(right); + } } From bef5717eefa1799221e02f952635cd0c3973306b Mon Sep 17 00:00:00 2001 From: Adrien Bourdeaux Date: Thu, 26 Sep 2024 17:40:32 -0400 Subject: [PATCH 28/39] Merged 2 if statements & fixed bad clause --- .../Packets/Processors/FootstepPacketProcessor.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs index dda30feae1..c1e4608cbc 100644 --- a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -22,11 +22,8 @@ public override void Process(FootstepPacket footstepPacket, Player sendingPlayer { foreach (Player player in playerManager.GetAllPlayers()) { - if(NitroxVector3.Distance(player.Position, sendingPlayer.Position) >= footstepAudioRange) - { - continue; - } - if(player != sendingPlayer) + if (NitroxVector3.Distance(player.Position, sendingPlayer.Position) >= footstepAudioRange || + player == sendingPlayer) { continue; } From 7e56f40756b8db31385769817990748cd501944e Mon Sep 17 00:00:00 2001 From: Adrien Bourdeaux Date: Sat, 28 Sep 2024 11:35:10 -0400 Subject: [PATCH 29/39] Fixed bug(was getting all players instead of only connected ones) --- .../Communication/Packets/Processors/FootstepPacketProcessor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs index c1e4608cbc..4f7d71b244 100644 --- a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -20,7 +20,7 @@ public FootstepPacketProcessor(PlayerManager playerManager, FMODWhitelist whitel public override void Process(FootstepPacket footstepPacket, Player sendingPlayer) { - foreach (Player player in playerManager.GetAllPlayers()) + foreach (Player player in playerManager.GetConnectedPlayers()) { if (NitroxVector3.Distance(player.Position, sendingPlayer.Position) >= footstepAudioRange || player == sendingPlayer) From 76c9b072aba86ed4d6d033af642667a7fbf06d4b Mon Sep 17 00:00:00 2001 From: Adrien Bourdeaux Date: Mon, 30 Sep 2024 18:48:04 -0400 Subject: [PATCH 30/39] Changed names of StepSound enum members Co-authored-by: tornac1234 --- .../Packets/Processors/FootstepPacketProcessor.cs | 6 +++--- NitroxModel/Packets/FootstepPacket.cs | 6 +++--- .../Patches/Dynamic/FootstepSounds_OnStep_Patch.cs | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs index e7fdb51f24..2083099c70 100644 --- a/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs +++ b/NitroxClient/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -33,9 +33,9 @@ public override void Process(FootstepPacket packet) { FMODAsset asset = packet.AssetIndex switch { - FootstepPacket.StepSounds.PRECURSOR_STEP_SOUND => localFootstepSounds.precursorInteriorSound, - FootstepPacket.StepSounds.METAL_STEP_SOUND => localFootstepSounds.metalSound, - FootstepPacket.StepSounds.LAND_STEP_SOUND => localFootstepSounds.landSound, + FootstepPacket.StepSounds.PRECURSOR => localFootstepSounds.precursorInteriorSound, + FootstepPacket.StepSounds.METAL => localFootstepSounds.metalSound, + FootstepPacket.StepSounds.LAND => localFootstepSounds.landSound, _ => null }; EventInstance evt = FMODUWE.GetEvent(asset); diff --git a/NitroxModel/Packets/FootstepPacket.cs b/NitroxModel/Packets/FootstepPacket.cs index fb4b1de947..3a5ee28a81 100644 --- a/NitroxModel/Packets/FootstepPacket.cs +++ b/NitroxModel/Packets/FootstepPacket.cs @@ -16,8 +16,8 @@ public FootstepPacket(ushort playerID, StepSounds assetIndex) public enum StepSounds : byte { - PRECURSOR_STEP_SOUND, - METAL_STEP_SOUND, - LAND_STEP_SOUND + PRECURSOR, + METAL, + LAND } } diff --git a/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs b/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs index 3eb67d1403..131fdf50f4 100644 --- a/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs @@ -88,13 +88,13 @@ private static void SendFootstepPacket(FMODAsset asset) switch (asset.path) { case PRECURSOR_STEP_SOUND_PATH: - assetIndex = FootstepPacket.StepSounds.PRECURSOR_STEP_SOUND; + assetIndex = FootstepPacket.StepSounds.PRECURSOR; break; case METAL_STEP_SOUND_PATH: - assetIndex = FootstepPacket.StepSounds.METAL_STEP_SOUND; + assetIndex = FootstepPacket.StepSounds.METAL; break; default: - assetIndex = FootstepPacket.StepSounds.LAND_STEP_SOUND; + assetIndex = FootstepPacket.StepSounds.LAND; break; } FootstepPacket footstepPacket = new(Resolve().PlayerId.Value, assetIndex); From 2bd2d9db76f6f02ce5fe8e3cfc4112187bb9e45d Mon Sep 17 00:00:00 2001 From: Adrien Bourdeaux Date: Mon, 30 Sep 2024 22:38:31 -0400 Subject: [PATCH 31/39] removed unneeded this keyword Co-authored-by: tornac1234 --- NitroxModel/Packets/FootstepPacket.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NitroxModel/Packets/FootstepPacket.cs b/NitroxModel/Packets/FootstepPacket.cs index 3a5ee28a81..8b21656b76 100644 --- a/NitroxModel/Packets/FootstepPacket.cs +++ b/NitroxModel/Packets/FootstepPacket.cs @@ -10,8 +10,8 @@ public class FootstepPacket : Packet public FootstepPacket(ushort playerID, StepSounds assetIndex) { - this.PlayerID = playerID; - this.AssetIndex = assetIndex; + PlayerID = playerID; + AssetIndex = assetIndex; } public enum StepSounds : byte From 7d81eaaeb21c8ef19a76b0b58102ef369c4e75a0 Mon Sep 17 00:00:00 2001 From: Adrien Bourdeaux Date: Mon, 30 Sep 2024 22:40:05 -0400 Subject: [PATCH 32/39] Reordered and cleaned usings Co-authored-by: tornac1234 --- .../Patches/Dynamic/FootstepSounds_OnStep_Patch.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs b/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs index 131fdf50f4..1e6d026a02 100644 --- a/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs @@ -1,7 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Reflection.Emit; using FMOD.Studio; using HarmonyLib; using NitroxClient.Communication.Abstract; @@ -10,6 +6,10 @@ using NitroxModel.GameLogic.FMOD; using NitroxModel.Helper; using NitroxModel.Packets; +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Reflection.Emit; using UnityEngine; namespace NitroxPatcher.Patches.Dynamic; From 5b17e1f6b580fe4af3091f1b5d1f4fc605d38ab0 Mon Sep 17 00:00:00 2001 From: Adrien Bourdeaux Date: Tue, 1 Oct 2024 20:23:41 -0400 Subject: [PATCH 33/39] Did sort and clean usings with correct setting Co-authored-by: tornac1234 --- .../Patches/Dynamic/FootstepSounds_OnStep_Patch.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs b/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs index 1e6d026a02..131fdf50f4 100644 --- a/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs @@ -1,3 +1,7 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Reflection.Emit; using FMOD.Studio; using HarmonyLib; using NitroxClient.Communication.Abstract; @@ -6,10 +10,6 @@ using NitroxModel.GameLogic.FMOD; using NitroxModel.Helper; using NitroxModel.Packets; -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Reflection.Emit; using UnityEngine; namespace NitroxPatcher.Patches.Dynamic; From 4d70262416f1ebbe704b2a3ddac791dc8fdeb335 Mon Sep 17 00:00:00 2001 From: Adrien Bourdeaux Date: Tue, 1 Oct 2024 20:46:53 -0400 Subject: [PATCH 34/39] added extra if check --- NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs b/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs index 131fdf50f4..7cbdbf4ed7 100644 --- a/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs @@ -19,6 +19,7 @@ public sealed partial class FootstepSounds_OnStep_Patch : NitroxPatch, IDynamicP private const string EXO_STEP_SOUND_PATH = "event:/sub/exo/step"; private const string PRECURSOR_STEP_SOUND_PATH = "event:/player/footstep_precursor_base"; private const string METAL_STEP_SOUND_PATH = "event:/player/footstep_metal"; + private const string LAND_STEP_SOUND_PATH = "event:/player/footstep_dirt"; internal static readonly MethodInfo TARGET_METHOD = Reflect.Method((FootstepSounds t) => t.OnStep(default)); @@ -93,9 +94,11 @@ private static void SendFootstepPacket(FMODAsset asset) case METAL_STEP_SOUND_PATH: assetIndex = FootstepPacket.StepSounds.METAL; break; - default: + case LAND_STEP_SOUND_PATH: assetIndex = FootstepPacket.StepSounds.LAND; break; + default: + return; } FootstepPacket footstepPacket = new(Resolve().PlayerId.Value, assetIndex); Resolve().Send(footstepPacket); From 80b4006b28a35b726d038f0b5bc6e224a895c720 Mon Sep 17 00:00:00 2001 From: Adrien Bourdeaux Date: Sat, 12 Oct 2024 18:31:53 -0400 Subject: [PATCH 35/39] Change number of added instructions in test class Co-authored-by: tornac1234 --- .../Patcher/Patches/Dynamic/FootstepSounds_OnStep_PatchTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Nitrox.Test/Patcher/Patches/Dynamic/FootstepSounds_OnStep_PatchTest.cs b/Nitrox.Test/Patcher/Patches/Dynamic/FootstepSounds_OnStep_PatchTest.cs index b3506a7701..fade24ca5e 100644 --- a/Nitrox.Test/Patcher/Patches/Dynamic/FootstepSounds_OnStep_PatchTest.cs +++ b/Nitrox.Test/Patcher/Patches/Dynamic/FootstepSounds_OnStep_PatchTest.cs @@ -15,6 +15,6 @@ public void InjectionSanity() IEnumerable beforeInstructions = PatchTestHelper.GetInstructionsFromMethod(FootstepSounds_OnStep_Patch.TARGET_METHOD); IEnumerable result = FootstepSounds_OnStep_Patch.Transpiler(beforeInstructions); - Assert.AreEqual(beforeInstructions.Count() + 4, result.Count()); + Assert.AreEqual(beforeInstructions.Count() + 6, result.Count()); } } From 33b52012e1ca49391b4292a48ec0e216910564b2 Mon Sep 17 00:00:00 2001 From: Adrien Bourdeaux Date: Tue, 15 Oct 2024 15:38:49 -0400 Subject: [PATCH 36/39] equality methods can be used by systems depending on the IEquatable abstraction Co-authored-by: Jannify <23176718+Jannify@users.noreply.github.com> --- NitroxModel/DataStructures/Optional.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NitroxModel/DataStructures/Optional.cs b/NitroxModel/DataStructures/Optional.cs index feb039c0e8..13933e0b6e 100644 --- a/NitroxModel/DataStructures/Optional.cs +++ b/NitroxModel/DataStructures/Optional.cs @@ -16,7 +16,7 @@ namespace NitroxModel.DataStructures.Util /// [Serializable] [DataContract] - public struct Optional : ISerializable where T : class + public struct Optional : ISerializable, IEquatable> where T : class { private delegate bool HasValueDelegate(T value); From 22e81130c68d34f07a93ee7094536aef0f09d12a Mon Sep 17 00:00:00 2001 From: Adrien Bourdeaux Date: Tue, 15 Oct 2024 15:41:57 -0400 Subject: [PATCH 37/39] Inverted if statement Co-authored-by: Jannify <23176718+Jannify@users.noreply.github.com> --- .../Dynamic/FootstepSounds_OnStep_Patch.cs | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs b/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs index 7cbdbf4ed7..f344cba440 100644 --- a/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs @@ -83,25 +83,26 @@ private static float CalculateVolume(float originalVolume, FootstepSounds instan private static void SendFootstepPacket(FMODAsset asset) { - if (Resolve().PlayerId.HasValue) + if (!Resolve().PlayerId.HasValue) { - FootstepPacket.StepSounds assetIndex; - switch (asset.path) - { - case PRECURSOR_STEP_SOUND_PATH: - assetIndex = FootstepPacket.StepSounds.PRECURSOR; - break; - case METAL_STEP_SOUND_PATH: - assetIndex = FootstepPacket.StepSounds.METAL; - break; - case LAND_STEP_SOUND_PATH: - assetIndex = FootstepPacket.StepSounds.LAND; - break; - default: - return; - } - FootstepPacket footstepPacket = new(Resolve().PlayerId.Value, assetIndex); - Resolve().Send(footstepPacket); + return; } + FootstepPacket.StepSounds assetIndex; + switch (asset.path) + { + case PRECURSOR_STEP_SOUND_PATH: + assetIndex = FootstepPacket.StepSounds.PRECURSOR; + break; + case METAL_STEP_SOUND_PATH: + assetIndex = FootstepPacket.StepSounds.METAL; + break; + case LAND_STEP_SOUND_PATH: + assetIndex = FootstepPacket.StepSounds.LAND; + break; + default: + return; + } + FootstepPacket footstepPacket = new(Resolve().PlayerId.Value, assetIndex); + Resolve().Send(footstepPacket); } } From 5a4b34a99475a40c5b32ad543ce01dadaa5f4cbb Mon Sep 17 00:00:00 2001 From: Adrien Bourdeaux Date: Sat, 19 Oct 2024 11:32:58 -0400 Subject: [PATCH 38/39] Updated sound levels Co-authored-by: gussandst <160942469+gussandst@users.noreply.github.com> Co-authored-by: WerewolfsX <160942469+WerewolfsX@users.noreply.github.com> --- .../Communication/Packets/Processors/FootstepPacketProcessor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs index 4f7d71b244..bff974a53d 100644 --- a/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs +++ b/NitroxServer/Communication/Packets/Processors/FootstepPacketProcessor.cs @@ -8,7 +8,7 @@ namespace NitroxServer.Communication.Packets.Processors; public class FootstepPacketProcessor : AuthenticatedPacketProcessor { - private readonly float footstepAudioRange; // To modify this value, modify the last value in the SoundWhitelist_Subnautica.csv file + private readonly float footstepAudioRange; // To modify this value, modify the last value of the event:/player/footstep_precursor_base sound in the SoundWhitelist_Subnautica.csv file private readonly PlayerManager playerManager; public FootstepPacketProcessor(PlayerManager playerManager, FMODWhitelist whitelist) From 7f2b288b60d1e12fd11e0ab4d2c9a97edf525c62 Mon Sep 17 00:00:00 2001 From: Adrien Bourdeaux Date: Sat, 19 Oct 2024 21:39:29 -0400 Subject: [PATCH 39/39] Change references of exosuit steps asset path to land asset path Co-authored-by: tornac1234 --- NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs b/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs index f344cba440..e7fffa1805 100644 --- a/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/FootstepSounds_OnStep_Patch.cs @@ -16,7 +16,6 @@ namespace NitroxPatcher.Patches.Dynamic; public sealed partial class FootstepSounds_OnStep_Patch : NitroxPatch, IDynamicPatch { - private const string EXO_STEP_SOUND_PATH = "event:/sub/exo/step"; private const string PRECURSOR_STEP_SOUND_PATH = "event:/player/footstep_precursor_base"; private const string METAL_STEP_SOUND_PATH = "event:/player/footstep_metal"; private const string LAND_STEP_SOUND_PATH = "event:/player/footstep_dirt"; @@ -66,7 +65,7 @@ public static IEnumerable Transpiler(IEnumerable stepSoundRadius = new(() => { - Resolve().TryGetSoundData(EXO_STEP_SOUND_PATH, out SoundData soundData); + Resolve().TryGetSoundData(LAND_STEP_SOUND_PATH, out SoundData soundData); return soundData.Radius; });