333
This commit is contained in:
1 parent
82eecfda06
commit
bdf5eca81f
10 files changed
+287
-94
No files matched your search
@@ -0,0 +1,116 @@
|
||||
--!strict
|
||||
local Players = game:GetService("Players")
|
||||
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
||||
local RunService = game:GetService("RunService")
|
||||
local Modes = require(ReplicatedStorage:WaitForChild("ArenaModes") :: ModuleScript)
|
||||
|
||||
local player = Players.LocalPlayer
|
||||
local playerGui = player:WaitForChild("PlayerGui")
|
||||
local arena = Modes.geometry(Modes.Procedural)
|
||||
type Arrow = {gui: BillboardGui, model: Model, faces: {BasePart}, edges: {BasePart}, glow: {BasePart}, color: Color3?, phase: number}
|
||||
local arrows: {[BasePart]: Arrow} = {}
|
||||
|
||||
local function build(marker: BasePart)
|
||||
if arrows[marker] then return end
|
||||
local gui = Instance.new("BillboardGui")
|
||||
gui.Name = "ObjectiveArrow"
|
||||
gui.Adornee = marker
|
||||
gui.AlwaysOnTop = true
|
||||
gui.LightInfluence = 0
|
||||
gui.MaxDistance = 710
|
||||
gui.Size = UDim2.fromOffset(108, 108)
|
||||
gui.StudsOffsetWorldSpace = Vector3.yAxis * 10
|
||||
gui.Enabled = false
|
||||
|
||||
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 = 29
|
||||
camera.CFrame = CFrame.lookAt(Vector3.new(0, 0, 9.5), Vector3.zero)
|
||||
camera.Parent = viewport
|
||||
viewport.CurrentCamera = camera
|
||||
|
||||
local model = Instance.new("Model")
|
||||
model.Name = "Arrow"
|
||||
model.Parent = viewport
|
||||
local arrow: Arrow = {gui = gui, model = model, faces = {}, edges = {}, glow = {}, color = nil, phase = marker.Position.X * .03}
|
||||
local function piece(name: string, size: Vector3, pose: CFrame, parent: {BasePart})
|
||||
local part = Instance.new("Part")
|
||||
part.Name = name
|
||||
part.Size = size
|
||||
part.CFrame = pose
|
||||
part.Anchored = true
|
||||
part.CanCollide, part.CanQuery, part.CanTouch = false, false, false
|
||||
part.Parent = model
|
||||
table.insert(parent, part)
|
||||
end
|
||||
local function segment(position: Vector3, angle: number, size: Vector3)
|
||||
local pose = CFrame.new(position) * CFrame.Angles(0, 0, angle)
|
||||
piece("Halo", Vector3.new(size.X * 1.42, size.Y + .23, .1),
|
||||
pose * CFrame.new(0, 0, -size.Z * .55), arrow.glow)
|
||||
piece("LitEdge", size, pose, arrow.edges)
|
||||
piece("BrightFace", Vector3.new(size.X * .54, size.Y - .13, .09),
|
||||
pose * CFrame.new(0, 0, size.Z * .5), arrow.faces)
|
||||
end
|
||||
segment(Vector3.new(0, .38, 0), 0, Vector3.new(.64, 2.13, .68))
|
||||
segment(Vector3.new(-.51, -.53, 0), math.rad(45), Vector3.new(.64, 1.56, .68))
|
||||
segment(Vector3.new(.51, -.53, 0), math.rad(-45), Vector3.new(.64, 1.56, .68))
|
||||
|
||||
arrows[marker] = arrow
|
||||
gui.Parent = playerGui
|
||||
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
|
||||
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 render = RunService.RenderStepped:Connect(function()
|
||||
local camera = workspace.CurrentCamera
|
||||
local active = player:GetAttribute("InArena") == true and camera ~= nil
|
||||
local now = os.clock()
|
||||
for marker, arrow in arrows do
|
||||
arrow.gui.Enabled = active and marker:GetAttribute("ObjectiveArrowHidden") ~= true
|
||||
if not arrow.gui.Enabled or not camera then continue end
|
||||
local distance = (camera.CFrame.Position - marker.Position).Magnitude
|
||||
if distance > arrow.gui.MaxDistance then continue end
|
||||
local phase = now * 3 + arrow.phase
|
||||
local size = math.clamp(math.floor(124 - distance * .08), 76, 124)
|
||||
arrow.gui.Size = UDim2.fromOffset(size, size)
|
||||
arrow.gui.StudsOffsetWorldSpace = Vector3.yAxis * (10.5 + math.sin(phase) * .95)
|
||||
arrow.model:PivotTo(CFrame.fromOrientation(math.rad(-8), .24 + math.sin(phase * .72) * .36, math.sin(phase) * .07))
|
||||
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()
|
||||
render:Disconnect()
|
||||
for _, arrow in arrows do arrow.gui:Destroy() end
|
||||
end)
|
||||
Reference in new issue
Block a user