mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-17 21:53:46 +03:00
Upload
This commit is contained in:
43
lua/pac3/core/client/parts/shake.lua
Normal file
43
lua/pac3/core/client/parts/shake.lua
Normal file
@@ -0,0 +1,43 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
local BUILDER, PART = pac.PartTemplate("base_movable")
|
||||
|
||||
PART.ClassName = "shake"
|
||||
PART.Group = 'effects'
|
||||
PART.Icon = 'icon16/transmit.png'
|
||||
|
||||
BUILDER:StartStorableVars()
|
||||
BUILDER:SetPropertyGroup("generic")
|
||||
BUILDER:SetPropertyGroup("shake")
|
||||
BUILDER:GetSet("Amplitude", 1)
|
||||
BUILDER:GetSet("Falloff", false)
|
||||
BUILDER:GetSet("Frequency", 1)
|
||||
BUILDER:GetSet("Duration", 0.5)
|
||||
BUILDER:GetSet("Radius", 100)
|
||||
BUILDER:EndStorableVars()
|
||||
|
||||
function PART:OnShow(from_rendering)
|
||||
if not from_rendering then
|
||||
local position = self:GetDrawPosition()
|
||||
local eyedistance = position:Distance(pac.EyePos)
|
||||
local radius = math.Clamp(self.Radius, 0.0001, 500)
|
||||
|
||||
if eyedistance < radius then
|
||||
local amplitude = self.Amplitude
|
||||
if self.Falloff then
|
||||
amplitude = amplitude * (1 - (eyedistance / radius))
|
||||
end
|
||||
util.ScreenShake(position, amplitude, self.Frequency, math.Clamp(self.Duration, 0.0001, 2), 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
BUILDER:Register()
|
||||
Reference in New Issue
Block a user