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:
@@ -1,46 +1,26 @@
|
||||
include("shared.lua")
|
||||
|
||||
local debug = GetConVar("metrostroi_drawsignaldebug")
|
||||
local function enableDebug()
|
||||
if debug:GetBool() then
|
||||
hook.Add("PostDrawTranslucentRenderables","MetrostroiAutoDebug",function(bDrawingDepth,bDrawingSkybox)
|
||||
for _,ent in pairs(ents.FindByClass("gmod_track_autodrive_plate")) do
|
||||
if bDrawingDepth and LocalPlayer():GetPos():DistToSqr(sig:GetPos()) < 262144 then
|
||||
local pos = sig:LocalToWorld(Vector(0,0,0))
|
||||
local ang = sig:LocalToWorldAngles(Angle(0,90,90))
|
||||
cam.Start3D2D(pos, ang, 0.25)
|
||||
surface.SetDrawColor(125, 125, 0, 255)
|
||||
surface.DrawRect(-40, -20, 80, 20)
|
||||
cam.End3D2D()
|
||||
end
|
||||
end
|
||||
end)
|
||||
else
|
||||
hook.Remove("PostDrawTranslucentRenderables","MetrostroiAutoDebug")
|
||||
end
|
||||
end
|
||||
hook.Remove("PostDrawTranslucentRenderables","MetrostroiAutoDebug")
|
||||
cvars.AddChangeCallback( "metrostroi_drawsignaldebug", enableDebug)
|
||||
enableDebug()
|
||||
local C_SignalDebug = GetConVar("metrostroi_drawsignaldebug")
|
||||
|
||||
function ENT:Initialize()
|
||||
end
|
||||
function ENT:Draw(flags)
|
||||
self:DrawModel(flags)
|
||||
|
||||
function ENT:OnRemove()
|
||||
end
|
||||
function ENT:RemoveModels()
|
||||
end
|
||||
if not C_SignalDebug:GetBool() then return end
|
||||
if LocalPlayer():GetPos():DistToSqr(self:GetPos()) > 200000 then return end
|
||||
|
||||
function ENT:Draw()
|
||||
self:DrawModel()
|
||||
if false and self.SpeedDetectors then
|
||||
cam.Start3D()
|
||||
for i,dist in ipairs(self.SpeedDetectors) do
|
||||
render.DrawLine(self:LocalToWorld(Vector((dist-80)/0.01905,-3.3,5.5)),self:LocalToWorld(Vector((dist-80)/0.01905,3.3,5.5)), Color(255,0,0),true)
|
||||
render.DrawLine(self:LocalToWorld(Vector((dist-80-0.02)/0.01905,-3.3,5.5)),self:LocalToWorld(Vector((dist-80+0.02)/0.01905,-3.3,5.5)), Color(255,0,0),true)
|
||||
render.DrawLine(self:LocalToWorld(Vector((dist-80-0.02)/0.01905,3.3,5.5)),self:LocalToWorld(Vector((dist-80+0.02)/0.01905,3.3,5.5)), Color(255,0,0),true)
|
||||
end
|
||||
cam.End3D()
|
||||
local pos = self:LocalToWorld(Vector(0,0,0))
|
||||
local ang = self:LocalToWorldAngles(Angle(0,90,90))
|
||||
cam.Start3D2D(pos, ang, 0.25)
|
||||
surface.SetDrawColor(125, 125, 0, 255)
|
||||
surface.DrawRect(-40, -20, 80, 20)
|
||||
cam.End3D2D()
|
||||
|
||||
if self.SpeedDetectors then
|
||||
for i,dist in ipairs(self.SpeedDetectors) do
|
||||
render.DrawLine(self:LocalToWorld(Vector((dist-80)/0.01905,-3.3,5.5)),self:LocalToWorld(Vector((dist-80)/0.01905,3.3,5.5)), Color(255,0,0),true)
|
||||
render.DrawLine(self:LocalToWorld(Vector((dist-80-0.02)/0.01905,-3.3,5.5)),self:LocalToWorld(Vector((dist-80+0.02)/0.01905,-3.3,5.5)), Color(255,0,0),true)
|
||||
render.DrawLine(self:LocalToWorld(Vector((dist-80-0.02)/0.01905,3.3,5.5)),self:LocalToWorld(Vector((dist-80+0.02)/0.01905,3.3,5.5)), Color(255,0,0),true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -53,4 +33,4 @@ net.Receive("metrostroi_auodrive_coils",function()
|
||||
table.insert(ent.SpeedDetectors,net.ReadFloat())
|
||||
end
|
||||
PrintTable(ent.SpeedDetectors)
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user