mirror of
https://github.com/CapsAdmin/wowozela.git
synced 2025-03-04 03:13:27 -05:00
Slight optimization maybe?
This commit is contained in:
parent
2f9ff1909b
commit
8458cf508d
@ -336,15 +336,17 @@ do -- sample meta
|
||||
if button then
|
||||
local wep = self.Player:GetActiveWeapon()
|
||||
local get = "GetNoteIndex" .. button
|
||||
if wep:IsWeapon() and wep:GetClass() == "wowozela" and wep[get] then
|
||||
if IsValid(wep) and wep:GetClass() == "wowozela" and wep[get] then
|
||||
return wep[get](wep)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function META:CanPlay()
|
||||
if not IsValid(self.Player) then return false end
|
||||
|
||||
local wep = self.Player:GetActiveWeapon()
|
||||
if wep:IsWeapon() and wep:GetClass() == "wowozela" then
|
||||
if IsValid(wep) and wep:GetClass() == "wowozela" then
|
||||
return true
|
||||
end
|
||||
|
||||
@ -590,16 +592,18 @@ do -- sample meta
|
||||
return -pitch / 89
|
||||
end
|
||||
|
||||
function META:StopPlaying()
|
||||
if not self.WasPlaying then return end
|
||||
for _, csp in pairs(self.Samples) do
|
||||
if not csp.paused then
|
||||
stop_sound(csp, self)
|
||||
end
|
||||
end
|
||||
self.WasPlaying = nil
|
||||
end
|
||||
|
||||
function META:Think()
|
||||
if not self:CanPlay() or wowozela.disabled then
|
||||
if self.WasPlaying then
|
||||
for _, csp in pairs(self.Samples) do
|
||||
if not csp.paused then
|
||||
stop_sound(csp, self)
|
||||
end
|
||||
end
|
||||
self.WasPlaying = nil
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
@ -735,15 +739,8 @@ do -- hooks
|
||||
end
|
||||
|
||||
function wowozela.Think()
|
||||
if not wowozela.KnownSamples[1] then
|
||||
return
|
||||
end
|
||||
|
||||
for k, sampler in next, wowozela.Samplers do
|
||||
if not IsValid(sampler.Player) then
|
||||
sampler:Destroy()
|
||||
wowozela.Samplers[k] = nil
|
||||
else
|
||||
if sampler:CanPlay() then
|
||||
sampler:Think()
|
||||
end
|
||||
end
|
||||
@ -765,9 +762,18 @@ do -- hooks
|
||||
wowozela.CreateSampler(ply)
|
||||
end
|
||||
end
|
||||
|
||||
for k, sampler in next, wowozela.Samplers do
|
||||
if not IsValid(sampler.Player) then
|
||||
sampler:Destroy()
|
||||
wowozela.Samplers[k] = nil
|
||||
elseif not sampler:CanPlay() then
|
||||
sampler:StopPlaying()
|
||||
end
|
||||
end
|
||||
end
|
||||
hook.Add("Think", "wowozela_think", wowozela.Think)
|
||||
timer.Create("WowozelaSlowThink", 0.1, 0, wowozela.SlowThink)
|
||||
timer.Create("WowozelaSlowThink", 0.2, 0, wowozela.SlowThink)
|
||||
|
||||
--[=[function wowozela.Draw()
|
||||
if not wowozela.KnownSamples[1] then
|
||||
|
@ -242,6 +242,12 @@ if CLIENT then
|
||||
end
|
||||
end
|
||||
end
|
||||
function SWEP:_Think()
|
||||
if self:GetOwner() and self:GetOwner():IsValid() and self:GetOwner():GetViewModel():IsValid() then
|
||||
self:GetOwner():GetViewModel():SetNoDraw(true)
|
||||
self.Think = nil
|
||||
end
|
||||
end
|
||||
|
||||
function SWEP:Deploy()
|
||||
self.Think = self._Think
|
||||
@ -253,16 +259,13 @@ function SWEP:Deploy()
|
||||
end
|
||||
|
||||
function SWEP:Holster()
|
||||
if CLIENT then
|
||||
if not self:GetOwner():KeyDown(IN_RELOAD) then
|
||||
local ply = self:GetOwner()
|
||||
|
||||
if ply.wowozela_head_cb then
|
||||
if CLIENT and ply.wowozela_head_cb then
|
||||
ply:RemoveCallback("BuildBonePositions", ply.wowozela_head_cb)
|
||||
ply.wowozela_head_cb = nil
|
||||
end
|
||||
end
|
||||
|
||||
if not self:GetOwner():KeyDown(IN_RELOAD) then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
@ -283,12 +286,7 @@ function SWEP:OnKeyEvent(key, press)
|
||||
end
|
||||
end
|
||||
|
||||
function SWEP:_Think()
|
||||
if self:GetOwner() and self:GetOwner():IsValid() and self:GetOwner():GetViewModel():IsValid() then
|
||||
self:GetOwner():GetViewModel():SetNoDraw(true)
|
||||
self.Think = nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function SWEP:GetViewModelPosition(pos, ang)
|
||||
pos.x = 35575
|
||||
|
Loading…
Reference in New Issue
Block a user