Skip to content

Commit

Permalink
Move SoundToolSupport table to its own file
Browse files Browse the repository at this point in the history
  • Loading branch information
thecraftianman committed Nov 2, 2024
1 parent 2fae79c commit 845d08c
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 121 deletions.
121 changes: 121 additions & 0 deletions lua/acf/core/utilities/sounds/tool_support_sh.lua
Original file line number Diff line number Diff line change
@@ -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
}
122 changes: 1 addition & 121 deletions lua/weapons/gmod_tool/stools/acfsound.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 845d08c

Please sign in to comment.