mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-17 21:53:46 +03:00
Upload
This commit is contained in:
55
gamemodes/sandbox/gamemode/prop_tools.lua
Normal file
55
gamemodes/sandbox/gamemode/prop_tools.lua
Normal file
@@ -0,0 +1,55 @@
|
||||
--[[
|
||||
| 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/
|
||||
--]]
|
||||
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
If the entity is colliding with something this function
|
||||
will make it non solid and call a timer to itself.
|
||||
|
||||
If it isn't colliding with anything it will make it solid
|
||||
and the timer will end.
|
||||
-----------------------------------------------------------]]
|
||||
function CheckPropSolid( e, solidtype, nonsolidtype, SolidCallback )
|
||||
|
||||
if ( !IsValid( e ) ) then return end
|
||||
|
||||
-- Trace our entity to check for collisions
|
||||
local trace = { start = e:GetPos(), endpos = e:GetPos(), filter = e }
|
||||
local tr = util.TraceEntity( trace, e )
|
||||
|
||||
-- If it collides mark it non solid and test again in 0.5 seconds
|
||||
if ( tr.Hit ) then
|
||||
|
||||
e:SetCollisionGroup( nonsolidtype )
|
||||
|
||||
-- Check later and later every time.
|
||||
--timerlast = timerlast + 0.1
|
||||
timer.Simple( 0.5, function() CheckPropSolid( e, solidtype, nonsolidtype, SolidCallback ) end )
|
||||
|
||||
else
|
||||
|
||||
e:SetCollisionGroup( solidtype )
|
||||
|
||||
-- If we have a solid callback function call it
|
||||
if ( SolidCallback ) then
|
||||
SolidCallback( e )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function DoPropSpawnedEffect( e )
|
||||
|
||||
if ( DisablePropCreateEffect ) then return end
|
||||
|
||||
e:SetSpawnEffect( true );
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user