mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 15:36:02 +01:00
@@ -98,20 +98,22 @@ end
|
|||||||
|
|
||||||
---@type table<number, CZone>
|
---@type table<number, CZone>
|
||||||
local insideZones = {}
|
local insideZones = {}
|
||||||
---@type table<number, CZone>
|
|
||||||
local enteringZones = {}
|
---@type CZone[] | Array
|
||||||
---@type table<number, CZone>
|
local exitingZones = lib.array:new()
|
||||||
local exitingZones = {}
|
|
||||||
local enteringSize = 0
|
---@type CZone[] | Array
|
||||||
local exitingSize = 0
|
local enteringZones = lib.array:new()
|
||||||
|
|
||||||
local tick
|
local tick
|
||||||
local glm_polygon_contains = glm.polygon.contains
|
local glm_polygon_contains = glm.polygon.contains
|
||||||
|
|
||||||
local function removeZone(self)
|
local function removeZone(zone)
|
||||||
Zones[self.id] = nil
|
Zones[zone.id] = nil
|
||||||
insideZones[self.id] = nil
|
insideZones[zone.id] = nil
|
||||||
enteringZones[self.id] = nil
|
|
||||||
exitingZones[self.id] = nil
|
table.remove(exitingZones, exitingZones:indexOf(zone))
|
||||||
|
table.remove(enteringZones, enteringZones:indexOf(zone))
|
||||||
end
|
end
|
||||||
|
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
@@ -134,8 +136,7 @@ CreateThread(function()
|
|||||||
zone.insideZone = true
|
zone.insideZone = true
|
||||||
|
|
||||||
if zone.onEnter then
|
if zone.onEnter then
|
||||||
enteringSize += 1
|
enteringZones:push(zone)
|
||||||
enteringZones[enteringSize] = zone
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if zone.inside or zone.debug then
|
if zone.inside or zone.debug then
|
||||||
@@ -148,8 +149,7 @@ CreateThread(function()
|
|||||||
insideZones[zone.id] = nil
|
insideZones[zone.id] = nil
|
||||||
|
|
||||||
if zone.onExit then
|
if zone.onExit then
|
||||||
exitingSize += 1
|
exitingZones:push(zone)
|
||||||
exitingZones[exitingSize] = zone
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -159,6 +159,9 @@ CreateThread(function()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local exitingSize = #exitingZones
|
||||||
|
local enteringSize = #enteringZones
|
||||||
|
|
||||||
if exitingSize > 0 then
|
if exitingSize > 0 then
|
||||||
table.sort(exitingZones, function(a, b)
|
table.sort(exitingZones, function(a, b)
|
||||||
return a.distance > b.distance
|
return a.distance > b.distance
|
||||||
@@ -168,7 +171,6 @@ CreateThread(function()
|
|||||||
exitingZones[i]:onExit()
|
exitingZones[i]:onExit()
|
||||||
end
|
end
|
||||||
|
|
||||||
exitingSize = 0
|
|
||||||
table.wipe(exitingZones)
|
table.wipe(exitingZones)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -181,7 +183,6 @@ CreateThread(function()
|
|||||||
enteringZones[i]:onEnter()
|
enteringZones[i]:onEnter()
|
||||||
end
|
end
|
||||||
|
|
||||||
enteringSize = 0
|
|
||||||
table.wipe(enteringZones)
|
table.wipe(enteringZones)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user