1
This commit is contained in:
1 parent
1a6f73ace2
commit
ce2ccfccdb
6 files changed
+93
-29
No files matched your search
@@ -42,32 +42,49 @@ function Sites.resolve(id: string): Map
|
||||
}
|
||||
end
|
||||
|
||||
local function fits(center: Vector3, geometry: RaycastParams, radius: number): boolean
|
||||
for index = 0, 15 do
|
||||
local angle = index * math.pi / 8
|
||||
local offset = Vector3.new(math.cos(angle), 0, math.sin(angle)) * (radius + .4)
|
||||
for _, distance in {0.5, 1} do
|
||||
local at = center + offset * distance
|
||||
local floor = workspace:Raycast(at + Vector3.yAxis * 1.2, -Vector3.yAxis * 2.4, geometry)
|
||||
if not floor or floor.Normal.Y < .95 or math.abs(floor.Position.Y - center.Y) > .35 then return false end
|
||||
if workspace:Raycast(at + Vector3.yAxis * .25, Vector3.yAxis * 9, geometry) then return false end
|
||||
end
|
||||
for _, height in {1, 4, 8} do
|
||||
if workspace:Raycast(center + Vector3.yAxis * height, offset, geometry) then return false end
|
||||
end
|
||||
end
|
||||
return workspace:Raycast(center + Vector3.yAxis * .25, Vector3.yAxis * 9, geometry) == nil
|
||||
end
|
||||
|
||||
function Sites.clearCircle(center: Vector3, geometry: RaycastParams, radius: number): Vector3
|
||||
if fits(center, geometry, radius) then return center end
|
||||
for distance = 3, 48, 3 do
|
||||
for index = 0, 15 do
|
||||
local angle = index * math.pi / 8
|
||||
local at = center + Vector3.new(math.cos(angle), 0, math.sin(angle)) * distance
|
||||
local floor = workspace:Raycast(at + Vector3.yAxis * 1.2, -Vector3.yAxis * 2.4, geometry)
|
||||
if floor and floor.Normal.Y >= .95 and math.abs(floor.Position.Y - center.Y) <= .35
|
||||
and fits(floor.Position, geometry, radius) then
|
||||
return floor.Position
|
||||
end
|
||||
end
|
||||
end
|
||||
return center
|
||||
end
|
||||
|
||||
function Sites.hotPath(id: string, map: Map, radius: number): {Site}
|
||||
local origin = Modes.geometry(id):GetPivot().Position
|
||||
local geometry = Modes.collision(id)
|
||||
local function fits(center: Vector3): boolean
|
||||
for index = 0, 15 do
|
||||
local angle = index * math.pi / 8
|
||||
local offset = Vector3.new(math.cos(angle), 0, math.sin(angle)) * (radius + .4)
|
||||
for _, distance in {0.5, 1} do
|
||||
local at = center + offset * distance
|
||||
local floor = workspace:Raycast(at + Vector3.yAxis * 1.2, -Vector3.yAxis * 2.4, geometry)
|
||||
if not floor or floor.Normal.Y < .95 or math.abs(floor.Position.Y - center.Y) > .35 then return false end
|
||||
if workspace:Raycast(at + Vector3.yAxis * .25, Vector3.yAxis * 9, geometry) then return false end
|
||||
end
|
||||
for _, height in {1, 4, 8} do
|
||||
if workspace:Raycast(center + Vector3.yAxis * height, offset, geometry) then return false end
|
||||
end
|
||||
end
|
||||
return workspace:Raycast(center + Vector3.yAxis * .25, Vector3.yAxis * 9, geometry) == nil
|
||||
end
|
||||
local path: {Site} = {}
|
||||
local function insert(site: Site, alternatives: {Vector3})
|
||||
local candidates = {site.position}
|
||||
for _, offset in alternatives do table.insert(candidates, origin + offset) end
|
||||
for _, candidate in candidates do
|
||||
local floor = workspace:Raycast(candidate + Vector3.yAxis * 1.2, -Vector3.yAxis * 2.4, geometry)
|
||||
if floor and floor.Normal.Y >= .95 and math.abs(floor.Position.Y - candidate.Y) <= .35 and fits(floor.Position) then
|
||||
if floor and floor.Normal.Y >= .95 and math.abs(floor.Position.Y - candidate.Y) <= .35 and fits(floor.Position, geometry, radius) then
|
||||
table.insert(path, {name = site.name, position = floor.Position})
|
||||
return
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user