feat(client/points): add new getter functions

This commit is contained in:
Linden
2023-04-20 15:55:06 +10:00
parent 51da742138
commit 62a0a2fe0b

View File

@@ -1,18 +1,23 @@
---@class CPoint
---@field id number
---@class PointProperties
---@field coords vector3
---@field distance number
---@field currentDistance number
---@field isClosest? boolean
---@field remove fun()
---@field onEnter? fun(self: CPoint)
---@field onExit? fun(self: CPoint)
---@field nearby? fun(self: CPoint)
---@field [string] any
---@class CPoint : PointProperties
---@field id number
---@field currentDistance number
---@field isClosest? boolean
---@field remove fun()
---@type table<number, CPoint>
local points = {}
---@type CPoint[]
local nearbyPoints = {}
local nearbyCount = 0
---@type CPoint?
local closestPoint
local tick
@@ -107,6 +112,8 @@ end
lib.points = {
---@return CPoint
---@overload fun(data: PointProperties): CPoint
---@overload fun(coords: vector3, distance: number, data?: PointProperties): CPoint
new = function(...)
local args = {...}
local id = #points + 1
@@ -140,10 +147,15 @@ lib.points = {
return self
end,
---@return CPoint
closest = function()
return closestPoint
end
getAllPoints = function() return points end,
getNearbyPoints = function() return nearbyPoints end,
---@return CPoint?
getClosestPoint = function() return closestPoint end,
}
---@deprecated
lib.points.closest = lib.points.getClosestPoint
return lib.points