This commit is contained in:
lifestorm
2024-08-05 18:40:29 +03:00
parent c4d91bf369
commit 324f19217d
8040 changed files with 1853423 additions and 21 deletions

View File

@@ -0,0 +1,58 @@
--[[
| 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/
--]]
function ents.FindByClassAndParent( classname, entity )
if ( !IsValid( entity ) ) then return end
local list = ents.FindByClass( classname )
if ( !list ) then return end
local out = {}
for k, v in ipairs( list ) do
if ( !IsValid(v) ) then continue end
local p = v:GetParent()
if ( !IsValid(p) ) then continue end
if ( p != entity ) then continue end
table.insert( out, v )
end
if ( #out == 0 ) then return end
return out
end
local inext = ipairs({})
local EntityCache = nil
function ents.Iterator()
if ( EntityCache == nil ) then EntityCache = ents.GetAll() end
return inext, EntityCache, 0
end
local function InvalidateEntityCache( ent )
EntityCache = nil
end
hook.Add( "OnEntityCreated", "ents.Iterator", InvalidateEntityCache )
hook.Add( "EntityRemoved", "ents.Iterator", InvalidateEntityCache )