34 lines
856 B
Luau
34 lines
856 B
Luau
--!strict
|
|
local Config = require(game.ReplicatedStorage.Hunter.EffectsConfig)
|
|
local Diagnostics = {}
|
|
local stepping = false
|
|
local rays = 0
|
|
local events = 0
|
|
local window = 0
|
|
|
|
function Diagnostics.begin()
|
|
stepping = Config.Debug
|
|
rays = 0
|
|
end
|
|
|
|
function Diagnostics.raycast(origin: Vector3, direction: Vector3, geometry: RaycastParams): RaycastResult?
|
|
if stepping then rays += 1 end
|
|
return workspace:Raycast(origin, direction, geometry)
|
|
end
|
|
|
|
function Diagnostics.event()
|
|
if Config.Debug then events += 1 end
|
|
end
|
|
|
|
function Diagnostics.finish(state: Instance, fighters: number, now: number)
|
|
stepping = false
|
|
if not Config.Debug then return end
|
|
state:SetAttribute("DebugRays", rays)
|
|
state:SetAttribute("DebugFighters", fighters)
|
|
if now - window >= 1 then
|
|
state:SetAttribute("DebugEvents", events)
|
|
window, events = now, 0
|
|
end
|
|
end
|
|
return Diagnostics
|