forked from FAForever/fa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNavGenerator.lua
122 lines (105 loc) · 2.71 KB
/
NavGenerator.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
---@alias NavLayers 'Land' | 'Water' | 'Amphibious' | 'Hover' | 'Air'
---@type NavLayers[]
Layers = {
'Land', 'Water', 'Amphibious', 'Hover', 'Air'
}
LayerColors = {
Land = '00ff00',
Water = '0000ff',
Amphibious = 'ffa500',
Hover = '008080',
Air = 'add8e6'
}
---@class NavDebugGetLabelState
---@field Position Vector
---@field Layer NavLayers
---@class NavDebugGetLabelMetadataState
---@field Id number
---@class NavDebugPathToState
---@field Origin Vector
---@field Destination Vector
---@field Layer NavLayers
---@class NavDebugCanPathToState
---@field Origin Vector
---@field Destination Vector
---@field Layer NavLayers
---@class NavLayerDataInstance
---@field Subdivisions number
---@field PathableLeafs number
---@field UnpathableLeafs number
---@field Neighbors number
---@field Labels number
---@class NavLayerData
---@field Land NavLayerDataInstance
---@field Naval NavLayerDataInstance
---@field Amph NavLayerDataInstance
---@field Hover NavLayerDataInstance
---@field Air NavLayerDataInstance
---@return NavLayerData
function CreateEmptyNavLayerData()
return {
Land = {
Subdivisions = 0,
PathableLeafs = 0,
UnpathableLeafs = 0,
Neighbors = 0,
Labels = 0
},
Amphibious = {
Subdivisions = 0,
PathableLeafs = 0,
UnpathableLeafs = 0,
Neighbors = 0,
Labels = 0
},
Hover = {
Subdivisions = 0,
PathableLeafs = 0,
UnpathableLeafs = 0,
Neighbors = 0,
Labels = 0
},
Water = {
Subdivisions = 0,
PathableLeafs = 0,
UnpathableLeafs = 0,
Neighbors = 0,
Labels = 0
},
Air = {
Subdivisions = 0,
PathableLeafs = 0,
UnpathableLeafs = 0,
Neighbors = 0,
Labels = 0
}
}
end
---@return NavProfileData
function CreateEmptyProfileData()
return {
TimeSetupCaches = 0,
TimeLabelTrees = 0,
}
end
--- Converts a label to a color, used for debugging
---@param label number
---@return string
function LabelToColor(label)
if label == -1 then
return 'ff0000'
end
local r = string.format("%x", math.mod(math.sin(label) * 256 + 512, 256) ^ 0)
local g = string.format("%x", math.mod(math.sin(label + 2) * 256 + 512, 256) ^ 0)
local b = string.format("%x", math.mod(math.cos(label) * 256 + 512, 256) ^ 0)
if string.len(r) == 1 then
r = '0' .. r
end
if string.len(g) == 1 then
g = '0' .. g
end
if string.len(b) == 1 then
b = '0' .. b
end
return r .. g .. b
end