169 lines
5.9 KiB
Luau
169 lines
5.9 KiB
Luau
--!strict
|
|
local Players = game:GetService("Players")
|
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
|
local RunService = game:GetService("RunService")
|
|
local Modes = require(ReplicatedStorage:WaitForChild("ArenaModes") :: ModuleScript)
|
|
|
|
local Input = game:GetService("UserInputService")
|
|
local mobile = Input.TouchEnabled and not Input.KeyboardEnabled
|
|
local player = Players.LocalPlayer
|
|
local playerGui = player:WaitForChild("PlayerGui")
|
|
local arena = Modes.geometry(Modes.Procedural)
|
|
type Arrow = {gui: Frame, chevrons: {Model}, faces: {BasePart}, edges: {BasePart}, glow: {BasePart}, color: Color3?, phase: number}
|
|
local arrows: {[BasePart]: Arrow} = {}
|
|
local flatArrows: {[BasePart]: {TextLabel}} = {}
|
|
local SIZE = if mobile then 125 else 156
|
|
local HEIGHT = 105
|
|
local MAX_DISTANCE = 710
|
|
local ANIMATION_RATE = 2 * math.pi / 4.5
|
|
|
|
local overlay = Instance.new("ScreenGui")
|
|
overlay.Name = "ObjectiveArrows"
|
|
overlay.ResetOnSpawn = false
|
|
overlay.IgnoreGuiInset = true
|
|
overlay.ScreenInsets = Enum.ScreenInsets.None
|
|
overlay.DisplayOrder = 8
|
|
overlay.Parent = playerGui
|
|
|
|
local function build(marker: BasePart)
|
|
if arrows[marker] then return end
|
|
local gui = Instance.new("Frame")
|
|
gui.Name = "ObjectiveArrow"
|
|
gui.AnchorPoint = Vector2.new(.5, .5)
|
|
gui.Size = UDim2.fromOffset(SIZE, SIZE)
|
|
gui.BackgroundTransparency = 1
|
|
gui.Visible = false
|
|
|
|
if mobile then
|
|
local glyphs: {TextLabel} = {}
|
|
for index, size in {16, 25, 33} do
|
|
local glyph = Instance.new("TextLabel")
|
|
glyph.BackgroundTransparency = 1
|
|
glyph.AnchorPoint = Vector2.new(.5, .5)
|
|
glyph.Size = UDim2.fromOffset(90, 38)
|
|
glyph.Font = Enum.Font.GothamBlack
|
|
glyph.Text = "⌄"
|
|
glyph.TextSize = size
|
|
glyph.TextStrokeTransparency = .15
|
|
glyph.Parent = gui
|
|
glyphs[index] = glyph
|
|
end
|
|
flatArrows[marker] = glyphs
|
|
arrows[marker] = {gui = gui, chevrons = {}, faces = {}, edges = {}, glow = {}, color = nil, phase = marker.Position.X * .03}
|
|
gui.Parent = overlay
|
|
return
|
|
end
|
|
|
|
local viewport = Instance.new("ViewportFrame")
|
|
viewport.Name = "ArrowViewport"
|
|
viewport.BackgroundTransparency = 1
|
|
viewport.Size = UDim2.fromScale(1, 1)
|
|
viewport.Ambient = Color3.fromRGB(145, 155, 180)
|
|
viewport.LightColor = Color3.new(1, 1, 1)
|
|
viewport.LightDirection = Vector3.new(-1, -1, -2)
|
|
viewport.Parent = gui
|
|
|
|
local camera = Instance.new("Camera")
|
|
camera.FieldOfView = 31
|
|
camera.CFrame = CFrame.lookAt(Vector3.new(0, .8, 9.7), Vector3.zero)
|
|
camera.Parent = viewport
|
|
viewport.CurrentCamera = camera
|
|
|
|
local arrow: Arrow = {
|
|
gui = gui, chevrons = {}, faces = {}, edges = {}, glow = {}, color = nil, phase = marker.Position.X * .03,
|
|
}
|
|
for index, scale in {.58, .78, 1} do
|
|
local model = Instance.new("Model")
|
|
model.Name = "Chevron" .. index
|
|
model.Parent = viewport
|
|
table.insert(arrow.chevrons, model)
|
|
|
|
local function piece(name: string, size: Vector3, pose: CFrame, surfaces: {BasePart})
|
|
local part = Instance.new("Part")
|
|
part.Name = name
|
|
part.Size = size * scale
|
|
part.CFrame = pose.Rotation + pose.Position * scale
|
|
part.Anchored = true
|
|
part.CanCollide, part.CanQuery, part.CanTouch = false, false, false
|
|
part.Parent = model
|
|
table.insert(surfaces, part)
|
|
end
|
|
for _, side in {-1, 1} do
|
|
local pose = CFrame.new(.69 * side, 0, 0) * CFrame.Angles(0, 0, math.rad(-53 * side))
|
|
piece("Halo", Vector3.new(.64, 2, .12), pose * CFrame.new(0, 0, -.32), arrow.glow)
|
|
piece("LitEdge", Vector3.new(.43, 1.85, .58), pose, arrow.edges)
|
|
piece("BrightFace", Vector3.new(.23, 1.68, .07), pose * CFrame.new(0, 0, .29), arrow.faces)
|
|
end
|
|
model.WorldPivot = CFrame.identity
|
|
end
|
|
|
|
arrows[marker] = arrow
|
|
gui.Parent = overlay
|
|
end
|
|
|
|
local function add(instance: Instance)
|
|
if instance:IsA("BasePart") and instance:GetAttribute("ObjectiveArrow") == true then build(instance) end
|
|
end
|
|
|
|
local function remove(instance: Instance)
|
|
if not instance:IsA("BasePart") then return end
|
|
local arrow = arrows[instance]
|
|
if not arrow then return end
|
|
arrows[instance] = nil
|
|
flatArrows[instance] = nil
|
|
arrow.gui:Destroy()
|
|
end
|
|
|
|
local added = arena.DescendantAdded:Connect(add)
|
|
local removing = arena.DescendantRemoving:Connect(remove)
|
|
for _, instance in arena:GetDescendants() do add(instance) end
|
|
|
|
local renderName = "HunterObjectiveArrows"
|
|
RunService:BindToRenderStep(renderName, Enum.RenderPriority.Camera.Value + 3, function()
|
|
local camera = workspace.CurrentCamera
|
|
local active = player:GetAttribute("InArena") == true
|
|
local now = os.clock()
|
|
for marker, arrow in arrows do
|
|
if not active or not camera or marker:GetAttribute("ObjectiveArrowHidden") == true
|
|
or (camera.CFrame.Position - marker.Position).Magnitude > MAX_DISTANCE then
|
|
arrow.gui.Visible = false
|
|
continue
|
|
end
|
|
local projected = camera:WorldToViewportPoint(marker.Position)
|
|
local phase = now * ANIMATION_RATE + arrow.phase
|
|
local y = projected.Y - HEIGHT + math.sin(phase) * 7
|
|
local screen = camera.ViewportSize
|
|
arrow.gui.Visible = projected.Z > 0 and projected.X >= -SIZE / 2 and projected.X <= screen.X + SIZE / 2
|
|
and y >= -SIZE / 2 and y <= screen.Y + SIZE / 2
|
|
if not arrow.gui.Visible then continue end
|
|
|
|
arrow.gui.Position = UDim2.fromOffset(projected.X, y)
|
|
local spacing = 1.15 + math.sin(phase - .9) * .16
|
|
local flat = flatArrows[marker]
|
|
if flat then
|
|
for i, glyph in flat do
|
|
glyph.Position = UDim2.new(.5, 0, .5, (i - 2) * 18 * spacing)
|
|
glyph.TextColor3 = marker.Color:Lerp(Color3.new(1,1,1), .25)
|
|
end
|
|
end
|
|
for index, chevron in arrow.chevrons do
|
|
chevron:PivotTo(CFrame.new(0, (2 - index) * spacing, 0))
|
|
end
|
|
local color = marker.Color
|
|
if arrow.color ~= color then
|
|
arrow.color = color
|
|
for _, edge in arrow.edges do edge.Color = color end
|
|
for _, halo in arrow.glow do halo.Color = color end
|
|
for _, face in arrow.faces do face.Color = color:Lerp(Color3.new(1, 1, 1), .64) end
|
|
end
|
|
for _, halo in arrow.glow do halo.Transparency = .75 + math.sin(phase) * .09 end
|
|
end
|
|
end)
|
|
|
|
script.Destroying:Once(function()
|
|
added:Disconnect()
|
|
removing:Disconnect()
|
|
RunService:UnbindFromRenderStep(renderName)
|
|
overlay:Destroy()
|
|
end)
|