-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathareastore.lua
100 lines (85 loc) · 3.82 KB
/
areastore.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
---@meta
---AreaStore
------------
-- AreaStore is a data structure to calculate intersections of 3D cuboid volumes
-- and points.
--
-- Despite its name, mods must take care of persisting AreaStore data.
-- They may use the provided load and write functions for this.
---@class mt.AreaStore
---@field data string Mod-relevant information to the specified area.
---@operator call: fun(type_name:string|nil):mt.AreaStore
local AreaStore = {}
---@alias mt.AreaID string|number
---@class mt.AreaInfo
---@field min mt.Vector|nil Position (if `include_corners` == `true`).
---@field max mt.Vector|nil Position (if `include_corners` == `true`).
---@field data string|nil (if `include_data` == `true`)
-- * Returns the area information about the specified ID.
-- * Returns nil if area not found.
-- * Returns boolean if `include_corners` and `include_data` are not true.
---@param id mt.AreaID
---@param include_corners boolean|nil
---@param include_data boolean|nil
---@return nil|true|mt.AreaInfo
function AreaStore:get_area(id, include_corners, include_data) end
-- Returns all areas as table, indexed by the area ID.
---@param pos mt.Vector
---@param include_corners boolean|nil
---@param include_data boolean|nil
---@return table<mt.AreaID, mt.AreaInfo>
function AreaStore:get_areas_for_pos(pos, include_corners, include_data) end
-- Returns all areas that contain all nodes inside the area specified by
-- `corner1` and `corner2` (inclusive).
---@param corner1 mt.Vector
---@param corner2 mt.Vector
---@param accept_overlap boolean|nil If `true`, areas are returned that have nodes in common (intersect) with the specified area.
---@param include_corners boolean|nil
---@param include_data boolean|nil
---@return table<mt.AreaID, mt.AreaInfo>
function AreaStore:get_areas_in_area(corner1, corner2, accept_overlap, include_corners, include_data) end
-- * Returns the new area's ID, or nil if the insertion failed.
-- * The (inclusive) positions `corner1` and `corner2` describe the area.
---@param corner1 mt.Vector
---@param corner2 mt.Vector
---@param data string
---@param id mt.AreaID|nil Will be used as the internal area ID if it is an unique number between 0 and 2^32-2.
---@return mt.AreaID|nil
function insert_area(corner1, corner2, data, id) end
-- * Requires SpatialIndex, no-op function otherwise.
-- * Reserves resources for `count` many contained areas to improve efficiency
-- when working with many area entries. Additional areas can still be inserted
-- afterwards at the usual complexity.
---@param count number|function
function AreaStore:reserve(count) end
-- Removes the area with the given id from the store, returns success.
---@param id mt.AreaID
---@return boolean
function AreaStore:remove_area(id) end
---@class mt.AreaCacheParams
-- Whether to enable, default `true`.
---@field enabled boolean
-- The radius (in nodes) of the areas the cache enerates prefiltered lists for,
-- minimum 16, default 64.
---@field block_radius integer
-- The cache size, minimum 20, default 1000
---@field limit integer
-- Sets params for the included prefiltering cache.
-- Calling invalidates the cache, so that its elements have to be newly generated.
---@param params mt.AreaCacheParams
function AreaStore:set_cache_params(params) end
-- Experimental. Returns area store serialized as a (binary) string.
---@return string
function AreaStore:to_string() end
-- Experimental. Like `to_string()`, but writes the data to a file.
---@param filename string
function AreaStore:to_file(filename) end
-- Experimental. Deserializes string and loads it into the
-- AreaStore. Returns success and, optionally, an error message.
---@param str string
---@return boolean success, string|nil error
function AreaStore:from_string(str) end
-- Experimental. Like `from_string()`, but reads the data from a file.
---@param filename string
---@return unknown
function AreaStore:from_file(filename) end