Files

113 lines
4.4 KiB
Luau

--!strict
local Players = game:GetService("Players")
local RS = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local Input = game:GetService("UserInputService")
local Config = require(RS.Hunter.EffectsConfig)
local Budget = require(RS.Hunter.EffectsBudget)
local profile = Budget.profile(Input.TouchEnabled, Input.KeyboardEnabled)
local localPlayer = Players.LocalPlayer
local root = Instance.new("Folder")
root.Name = "HunterClientVfx"
root.Parent = workspace
type Slot = {part: Part, tween: Tween?, effect: ParticleEmitter?}
local rotation = CFrame.Angles(0, 0, math.pi / 2)
local function pool(name: string, size: number, particles: boolean): () -> Slot
local slots: {Slot} = {}
local cursor = 0
for i = 1, size do
local part = Instance.new("Part")
part.Name = name
part.Anchored, part.CanCollide, part.CanQuery, part.CanTouch = true, false, false, false
part.CastShadow = false
part.Shape, part.Material, part.Transparency = Enum.PartType.Cylinder, Enum.Material.Neon, 1
part.Size = Vector3.one
part.Parent = root
local emitter: ParticleEmitter? = nil
if particles then
emitter = Instance.new("ParticleEmitter")
emitter.Texture = "rbxasset://textures/particles/sparkles_main.dds"
emitter.Rate = 0
emitter.Lifetime = NumberRange.new(.3, .65)
emitter.Speed = NumberRange.new(9, 24)
emitter.SpreadAngle = Vector2.new(145, 145)
emitter.Size = NumberSequence.new(.42, 0)
emitter.LightEmission, emitter.LightInfluence = 1, 0
emitter.Parent = part
end
slots[i] = {part = part, effect = emitter, tween = nil}
end
return function()
cursor = cursor % size + 1
local slot = slots[cursor]
if slot.tween then slot.tween:Cancel(); slot.tween = nil end
if slot.effect then slot.effect:Clear() end
slot.part.Transparency = 1
return slot
end
end
local rings = pool("Ring", profile.worldSlots, false)
local columns = pool("Column", profile.worldSlots, false)
local bursts = pool("Burst", math.min(profile.burstSlots, profile.maxEmitters), true)
local gui = Instance.new("ScreenGui")
gui.Name = "ArenaScreenVfx"
gui.DisplayOrder = 7
gui.ResetOnSpawn = false
gui.Parent = localPlayer:WaitForChild("PlayerGui")
local flash = Instance.new("Frame")
flash.BorderSizePixel = 0
flash.Size = UDim2.fromScale(1, 1)
flash.BackgroundTransparency = 1
flash.Parent = gui
local flashTween: Tween? = nil
local ArenaVfx = {}
local function animate(slot: Slot, seconds: number, props: {[string]: any})
local tween = TweenService:Create(slot.part, TweenInfo.new(math.clamp(seconds, .05, .6), Enum.EasingStyle.Quad, Enum.EasingDirection.Out), props)
slot.tween = tween
tween:Play()
end
function ArenaVfx.ring(at: Vector3, radius: number, color: Color3, seconds: number, inward: boolean?)
local slot = rings()
slot.part.CFrame = CFrame.new(at + Vector3.yAxis * .24) * rotation
local diameter = radius * 2
local start = if inward then diameter else diameter * .55
local finish = if inward then .1 else diameter * 1.6
slot.part.Size = Vector3.new(.1, start, start)
slot.part.Color, slot.part.Transparency = color, .7
animate(slot, seconds, {Size = Vector3.new(.1, finish, finish), Transparency = 1})
end
function ArenaVfx.burst(at: Vector3, color: Color3, count: number, smoke: boolean?)
local amount = Budget.particles(count, profile.scale)
if amount == 0 then return end
local slot = bursts()
slot.part.CFrame = CFrame.new(at + Vector3.yAxis)
local emitter = assert(slot.effect)
emitter.Texture = if smoke then "rbxasset://textures/particles/smoke_main.dds" else "rbxasset://textures/particles/sparkles_main.dds"
emitter.Size = if smoke then NumberSequence.new(2, 8) else NumberSequence.new(.42, 0)
emitter.Transparency = if smoke then NumberSequence.new(.35, 1) else NumberSequence.new(.06, 1)
emitter.Color = ColorSequence.new(color, Color3.new(1, 1, 1))
emitter:Emit(amount)
end
function ArenaVfx.column(at: Vector3, color: Color3)
local slot = columns()
slot.part.CFrame = CFrame.new(at + Vector3.yAxis) * rotation
slot.part.Size = Vector3.new(1, 3, 3)
slot.part.Color, slot.part.Transparency = color, .72
animate(slot, Config.FeedbackSeconds, {CFrame = CFrame.new(at + Vector3.yAxis * 22) * rotation,
Size = Vector3.new(44, 4, 4), Transparency = 1})
end
function ArenaVfx.flash(color: Color3)
if flashTween then flashTween:Cancel() end
flash.BackgroundColor3, flash.BackgroundTransparency = color, .93
flashTween = TweenService:Create(flash, TweenInfo.new(.32), {BackgroundTransparency = 1})
flashTween:Play()
end
return ArenaVfx