From 845d08c197c46b2eaf0caad16413a1f768c60f75 Mon Sep 17 00:00:00 2001 From: thecraftianman <64441307+thecraftianman@users.noreply.github.com> Date: Fri, 1 Nov 2024 20:24:07 -0400 Subject: [PATCH] Move SoundToolSupport table to its own file --- .../core/utilities/sounds/tool_support_sh.lua | 121 +++++++++++++++++ lua/weapons/gmod_tool/stools/acfsound.lua | 122 +----------------- 2 files changed, 122 insertions(+), 121 deletions(-) create mode 100644 lua/acf/core/utilities/sounds/tool_support_sh.lua diff --git a/lua/acf/core/utilities/sounds/tool_support_sh.lua b/lua/acf/core/utilities/sounds/tool_support_sh.lua new file mode 100644 index 000000000..ed6ac9dde --- /dev/null +++ b/lua/acf/core/utilities/sounds/tool_support_sh.lua @@ -0,0 +1,121 @@ +ACF.SoundToolSupport = ACF.SoundToolSupport or {} + +local Sounds = ACF.SoundToolSupport + +Sounds.acf_gun = { + GetSound = function(Ent) + return { + Sound = Ent.SoundPath, + Pitch = Ent.SoundPitch, + Volume = Ent.SoundVolume + } + end, + SetSound = function(Ent, SoundData) + Ent.SoundPath = SoundData.Sound + Ent.SoundPitch = SoundData.Pitch + Ent.SoundVolume = SoundData.Volume + + Ent:SetNWString("Sound", SoundData.Sound) + Ent:SetNWFloat("SoundPitch", SoundData.Pitch) + Ent:SetNWFloat("SoundVolume", SoundData.Volume) + end, + ResetSound = function(Ent) + Ent.SoundPath = Ent.DefaultSound + Ent.SoundPitch = 1 + Ent.SoundVolume = 1 + + Ent:SetNWString("Sound", Ent.DefaultSound) + Ent:SetNWFloat("SoundPitch", 1) + Ent:SetNWFloat("SoundVolume", 1) + end +} + +Sounds.acf_engine = { + GetSound = function(Ent) + return { + Sound = Ent.SoundPath, + Pitch = Ent.SoundPitch, + Volume = Ent.SoundVolume + } + end, + SetSound = function(Ent, SoundData) + local Sound = SoundData.Sound:Trim():lower() + + Ent.SoundPath = Sound + Ent.SoundPitch = SoundData.Pitch + Ent.SoundVolume = SoundData.Volume + + Ent:UpdateSound() + end, + ResetSound = function(Ent) + Ent.SoundPath = Ent.DefaultSound + Ent.SoundPitch = 1 + Ent.SoundVolume = 1 + + Ent:UpdateSound() + end +} + +Sounds.acf_gearbox = { + GetSound = function(Ent) + return { + Sound = Ent.SoundPath, + Pitch = Ent.SoundPitch, + Volume = Ent.SoundVolume, + } + end, + SetSound = function(Ent, SoundData) + Ent.SoundPath = SoundData.Sound + Ent.SoundPitch = SoundData.Pitch + Ent.SoundVolume = SoundData.Volume + end, + ResetSound = function(Ent) + Ent.SoundPath = Ent.DefaultSound + Ent.SoundPitch = nil + Ent.SoundVolume = nil + end +} + +Sounds.acf_piledriver = { + GetSound = function(Ent) + return { + Sound = Ent.SoundPath or "", + Pitch = Ent.SoundPitch or 1, + Volume = Ent.SoundVolume or 0.5, + } + end, + SetSound = function(Ent, SoundData) + Ent.SoundPath = SoundData.Sound + Ent.SoundPitch = SoundData.Pitch + Ent.SoundVolume = SoundData.Volume + end, + ResetSound = function(Ent) + Ent.SoundPath = nil + Ent.SoundPitch = nil + Ent.SoundVolume = nil + end +} + +Sounds.acf_turret_motor = { + GetSound = function(Ent) + return { + Sound = Ent.SoundPath or Ent.DefaultSound, + Pitch = Ent.SoundPitch or 0.7, + Volume = Ent.SoundVolume or 0.1, + } + end, + SetSound = function(Ent, SoundData) + Ent.SoundPath = SoundData.Sound + Ent.SoundPitch = SoundData.Pitch + Ent.SoundVolume = SoundData.Volume + + if IsValid(Ent.Turret) then Ent.Turret:UpdateSound() end + end, + ResetSound = function(Ent) + Ent.SoundPath = Ent.DefaultSound + Ent.SoundPitch = nil + Ent.SoundVolume = nil + + if IsValid(Ent.Turret) then Ent.Turret:UpdateSound() end + end +} \ No newline at end of file diff --git a/lua/weapons/gmod_tool/stools/acfsound.lua b/lua/weapons/gmod_tool/stools/acfsound.lua index 6adbfc766..19d1ed859 100644 --- a/lua/weapons/gmod_tool/stools/acfsound.lua +++ b/lua/weapons/gmod_tool/stools/acfsound.lua @@ -12,127 +12,7 @@ TOOL.Information = { { name = "info" } } -ACF.SoundToolSupport = ACF.SoundToolSupport or {} - -local Sounds = ACF.SoundToolSupport - -Sounds.acf_gun = { - GetSound = function(ent) - return { - Sound = ent.SoundPath, - Pitch = ent.SoundPitch, - Volume = ent.SoundVolume - } - end, - SetSound = function(ent, soundData) - ent.SoundPath = soundData.Sound - ent.SoundPitch = soundData.Pitch - ent.SoundVolume = soundData.Volume - - ent:SetNWString("Sound", soundData.Sound) - ent:SetNWFloat("SoundPitch", soundData.Pitch) - ent:SetNWFloat("SoundVolume", soundData.Volume) - end, - ResetSound = function(ent) - ent.SoundPath = ent.DefaultSound - ent.SoundPitch = 1 - ent.SoundVolume = 1 - - ent:SetNWString("Sound", ent.DefaultSound) - ent:SetNWFloat("SoundPitch", 1) - ent:SetNWFloat("SoundVolume", 1) - end -} - -Sounds.acf_engine = { - GetSound = function(ent) - return { - Sound = ent.SoundPath, - Pitch = ent.SoundPitch, - Volume = ent.SoundVolume - } - end, - SetSound = function(ent, soundData) - local Sound = soundData.Sound:Trim():lower() - - ent.SoundPath = Sound - ent.SoundPitch = soundData.Pitch - ent.SoundVolume = soundData.Volume - - ent:UpdateSound() - end, - ResetSound = function(ent) - ent.SoundPath = ent.DefaultSound - ent.SoundPitch = 1 - ent.SoundVolume = 1 - - ent:UpdateSound() - end -} - -Sounds.acf_gearbox = { - GetSound = function(Ent) - return { - Sound = Ent.SoundPath, - Pitch = Ent.SoundPitch, - Volume = Ent.SoundVolume, - } - end, - SetSound = function(Ent, SoundData) - Ent.SoundPath = SoundData.Sound - Ent.SoundPitch = SoundData.Pitch - Ent.SoundVolume = SoundData.Volume - end, - ResetSound = function(Ent) - Ent.SoundPath = Ent.DefaultSound - Ent.SoundPitch = nil - Ent.SoundVolume = nil - end -} - -Sounds.acf_piledriver = { - GetSound = function(Ent) - return { - Sound = Ent.SoundPath or "", - Pitch = Ent.SoundPitch or 1, - Volume = Ent.SoundVolume or 0.5, - } - end, - SetSound = function(Ent, SoundData) - Ent.SoundPath = SoundData.Sound - Ent.SoundPitch = SoundData.Pitch - Ent.SoundVolume = SoundData.Volume - end, - ResetSound = function(Ent) - Ent.SoundPath = nil - Ent.SoundPitch = nil - Ent.SoundVolume = nil - end -} - -Sounds.acf_turret_motor = { - GetSound = function(Ent) - return { - Sound = Ent.SoundPath or Ent.DefaultSound, - Pitch = Ent.SoundPitch or 0.7, - Volume = Ent.SoundVolume or 0.1, - } - end, - SetSound = function(Ent, SoundData) - Ent.SoundPath = SoundData.Sound - Ent.SoundPitch = SoundData.Pitch - Ent.SoundVolume = SoundData.Volume - - if IsValid(Ent.Turret) then Ent.Turret:UpdateSound() end - end, - ResetSound = function(Ent) - Ent.SoundPath = Ent.DefaultSound - Ent.SoundPitch = nil - Ent.SoundVolume = nil - - if IsValid(Ent.Turret) then Ent.Turret:UpdateSound() end - end -} +local Sounds = ACF.SoundToolSupport local function ReplaceSound(_, Entity, Data) if not IsValid(Entity) then return end