fix(points): grid inconsistencies (#37)

This commit is contained in:
David Malchin
2025-08-10 03:20:46 +03:00
committed by GitHub
parent dec6caa63b
commit a9648fb45f

View File

@@ -39,10 +39,14 @@ local function removePoint(self)
points[self.id] = nil
end
local function hasRemovePoint(entry)
return entry.remove == removePoint
end
CreateThread(function()
while true do
local coords = GetEntityCoords(cache.ped)
local newPoints = lib.grid.getNearbyEntries(coords, function(entry) return entry.remove == removePoint end) --[[@as CPoint[] ]]
local newPoints = lib.grid.getNearbyEntries(coords, hasRemovePoint) --[[@as CPoint[] ]]
local cellX, cellY = lib.grid.getCellPosition(coords)
cache.coords = coords
closestPoint = nil
@@ -89,9 +93,11 @@ CreateThread(function()
nearbyCount += 1
nearbyPoints[nearbyCount] = point
if point.onEnter and not point.inside then
if not point.inside then
point.inside = true
point:onEnter()
if point.onEnter then
point:onEnter()
end
end
elseif point.currentDistance then
if point.onExit then point:onExit() end