Skip to content

Commit 3fc3478

Browse files
authored
Merge pull request #254 from jspidal/feat-grid
feat(ox_lib): grid
2 parents 297f78c + 82b7a0c commit 3fc3478

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

pages/ox_lib/Modules/Grid/Shared.mdx

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Shared
2+
3+
A system that divides the map into smaller 2D cells. Entries in a cell can be added, removed, and listed.
4+
5+
## GridEntry Class
6+
7+
A table representing a grid entry with the following properties.
8+
9+
- coords: `vector`
10+
- length?: `number`
11+
- width?: `number`
12+
- radius?: `number`
13+
14+
## lib.grid.getCellPosition
15+
16+
Returns the position of the cell at the given point.
17+
18+
```lua
19+
lib.grid.getCellPosition(point)
20+
```
21+
22+
- point: `vector`
23+
24+
**Returns:**
25+
- x: `number`
26+
- y: `number`
27+
28+
## lib.grid.getCell
29+
30+
Returns all entries in the cell that belongs to the point.
31+
32+
```lua
33+
lib.grid.getCell(point)
34+
```
35+
36+
- point: `vector`
37+
38+
**Returns:**
39+
- entries: `GridEntry[]`
40+
41+
## lib.grid.getNearbyEntries
42+
43+
Returns all entries near the point with an optional filter
44+
45+
```lua
46+
lib.grid.getNearbyEntries(point, filter)
47+
```
48+
49+
- point: `vector`
50+
- filter: `function(entry: GridEntry): boolean`
51+
52+
**Returns:**
53+
54+
- entries: `Array<GridEntry>`
55+
56+
## lib.grid.addEntry
57+
58+
Adds an entry to the grid
59+
60+
61+
```lua
62+
lib.grid.addEntry(entry)
63+
```
64+
65+
- entry: `GridEntry`
66+
67+
## lib.grid.removeEntry
68+
69+
Removes and entry that was previously added to the grid
70+
71+
```lua
72+
lib.grid.removeEntry(entry)
73+
```
74+
75+
- entry: `GridEntry`
76+
77+
**Returns:**
78+
79+
- success: `boolean`

0 commit comments

Comments
 (0)