1
0
mirror of https://github.com/metrostroi-repo/MetrostroiAddon.git synced 2026-05-02 00:42:29 +00:00

Дебаг сигнализации.

Почистил мусор
Перенес всю отрисовку дебаг информации в ENT:Draw()
This commit is contained in:
kosmik641
2025-12-06 02:51:30 +03:00
parent e393387043
commit aca7d7aa0a
7 changed files with 245 additions and 243 deletions

View File

@@ -1,26 +1,19 @@
include("shared.lua")
local debug = GetConVar("metrostroi_drawsignaldebug")
local function enableDebug()
if debug:GetBool() then
hook.Add("PreDrawEffects","MetrostroiSwitchDebug",function()
for _,ent in pairs(ents.FindByClass("gmod_track_switch")) do
if IsValid(ent) and LocalPlayer():GetPos():DistToSqr(ent:GetPos()) < 262144 then
local pos = ent:LocalToWorld(Vector(30,0,75))
local ang = ent:LocalToWorldAngles(Angle(0,180,90))
cam.Start3D2D(pos, ang, 0.25)
surface.SetDrawColor(125, 125, 0, 255)
surface.DrawRect(0, 0, 160, 24)
local C_SignalDebug = GetConVar("metrostroi_drawsignaldebug")
draw.DrawText("SwitchID:"..ent:GetNW2String("ID"),"Trebuchet24",5,0,Color(0,0,0,255))
cam.End3D2D()
end
end
end)
else
hook.Remove("PreDrawEffects","MetrostroiSwitchDebug")
end
function ENT:Draw(flags)
self:DrawModel(flags)
if not C_SignalDebug:GetBool() then return end
if LocalPlayer():GetPos():DistToSqr(self:GetPos()) > 200000 then return end
local pos = self:LocalToWorld(Vector(30,0,75))
local ang = self:LocalToWorldAngles(Angle(0,180,90))
cam.Start3D2D(pos, ang, 0.25)
surface.SetDrawColor(125, 125, 0, 255)
surface.DrawRect(0, 0, 160, 24)
draw.DrawText("SwitchID:"..self:GetNW2String("ID"),"Trebuchet24",5,0,Color(0,0,0,255))
cam.End3D2D()
end
hook.Remove("PreDrawEffects","MetrostroiSwitchDebug")
cvars.AddChangeCallback( "metrostroi_drawsignaldebug", enableDebug)
enableDebug()