mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-30 09:48:52 +00:00
Tab indent update
This commit is contained in:
+28
-33
@@ -25,55 +25,50 @@ OTHER DEALINGS IN THE SOFTWARE.
|
||||
]]
|
||||
|
||||
local entityEnumerator = {
|
||||
__gc = function(enum)
|
||||
if enum.destructor and enum.handle then
|
||||
enum.destructor(enum.handle)
|
||||
end
|
||||
enum.destructor = nil
|
||||
enum.handle = nil
|
||||
end
|
||||
__gc = function(enum)
|
||||
if enum.destructor and enum.handle then
|
||||
enum.destructor(enum.handle)
|
||||
end
|
||||
|
||||
enum.destructor = nil
|
||||
enum.handle = nil
|
||||
end
|
||||
}
|
||||
|
||||
local function EnumerateEntities(initFunc, moveFunc, disposeFunc)
|
||||
return coroutine.wrap(function()
|
||||
local iter, id = initFunc()
|
||||
if not id or id == 0 then
|
||||
disposeFunc(iter)
|
||||
return
|
||||
end
|
||||
return coroutine.wrap(function()
|
||||
local iter, id = initFunc()
|
||||
if not id or id == 0 then
|
||||
disposeFunc(iter)
|
||||
return
|
||||
end
|
||||
|
||||
local enum = {handle = iter, destructor = disposeFunc}
|
||||
setmetatable(enum, entityEnumerator)
|
||||
local enum = {handle = iter, destructor = disposeFunc}
|
||||
setmetatable(enum, entityEnumerator)
|
||||
|
||||
local next = true
|
||||
repeat
|
||||
coroutine.yield(id)
|
||||
next, id = moveFunc(iter)
|
||||
until not next
|
||||
local next = true
|
||||
repeat
|
||||
coroutine.yield(id)
|
||||
next, id = moveFunc(iter)
|
||||
until not next
|
||||
|
||||
enum.destructor, enum.handle = nil, nil
|
||||
disposeFunc(iter)
|
||||
end)
|
||||
enum.destructor, enum.handle = nil, nil
|
||||
disposeFunc(iter)
|
||||
end)
|
||||
end
|
||||
|
||||
function EnumerateObjects()
|
||||
return EnumerateEntities(FindFirstObject, FindNextObject, EndFindObject)
|
||||
return EnumerateEntities(FindFirstObject, FindNextObject, EndFindObject)
|
||||
end
|
||||
|
||||
function EnumeratePeds()
|
||||
return EnumerateEntities(FindFirstPed, FindNextPed, EndFindPed)
|
||||
return EnumerateEntities(FindFirstPed, FindNextPed, EndFindPed)
|
||||
end
|
||||
|
||||
function EnumerateVehicles()
|
||||
return EnumerateEntities(FindFirstVehicle, FindNextVehicle, EndFindVehicle)
|
||||
return EnumerateEntities(FindFirstVehicle, FindNextVehicle, EndFindVehicle)
|
||||
end
|
||||
|
||||
function EnumeratePickups()
|
||||
return EnumerateEntities(FindFirstPickup, FindNextPickup, EndFindPickup)
|
||||
return EnumerateEntities(FindFirstPickup, FindNextPickup, EndFindPickup)
|
||||
end
|
||||
|
||||
--[[Usage:
|
||||
for ped in EnumeratePeds() do
|
||||
<do something with 'ped'>
|
||||
end
|
||||
]]
|
||||
|
||||
Reference in New Issue
Block a user