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

Distance -> DistToSqr

This commit is contained in:
Hellss
2022-06-04 12:53:34 +03:00
parent 7383dcdd45
commit dfad20eec1
9 changed files with 10 additions and 10 deletions

View File

@@ -665,7 +665,7 @@ local function enableDebug()
if ent.ButtonMap ~= nil then
draw.NoTexture()
for kp,panel in pairs(ent.ButtonMap) do
if kp ~= "BaseClass" and LocalPlayer():GetPos():Distance(ent:LocalToWorld(panel.pos)) < 512 then
if kp ~= "BaseClass" and LocalPlayer():GetPos():DistToSqr(ent:LocalToWorld(panel.pos)) < 262144 then
ent:DrawOnPanel(kp,function()
surface.SetDrawColor(0,0,255)
if not ent:ShouldDrawPanel(kp) then surface.SetDrawColor(255,0,0) end

View File

@@ -5,7 +5,7 @@ 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():Distance(sig:GetPos()) < 512 then
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)

View File

@@ -25,7 +25,7 @@ local function enableDebug()
if debug:GetBool() then
hook.Add("PostDrawTranslucentRenderables","MetrostroiPAMarkerDebug",function(bDrawingDepth,bDrawingSkybox)
for _,ent in pairs(ents.FindByClass("gmod_track_autodrive_plate")) do
if bDrawingDepth and LocalPlayer():GetPos():Distance(sig:GetPos()) < 512 then
if bDrawingDepth and LocalPlayer():GetPos():DistToSqr(sig:GetPos()) < 262144 then
cam.Start3D()
render.SetMaterial(mat)
--render.DrawQuadEasy(self:GetPos(),self:GetAngles():Forward(),600,600,Color(255,255,255),0)

View File

@@ -256,7 +256,7 @@ function ENT:Think()
local target = Vector(0,0,0)
for j=1,count do
local vec = self:GetNW2Vector("TrainDoor"..j,Vector(0,0,0))
local d = vec:Distance(self.ClientModels[i]:GetPos())
local d = vec:DistToSqr(self.ClientModels[i]:GetPos())
if d < distance then
target = vec
distance = d

View File

@@ -268,7 +268,7 @@ function ENT:Think()
local BoardTime = 8+7*self.HorliftStation
for k,v in pairs(ents.FindByClass("gmod_subway_*")) do
if v.Base ~= "gmod_subway_base" and v:GetClass() ~= "gmod_subway_base" then continue end
if not IsValid(v) or v:GetPos():Distance(self:GetPos()) > self.PlatformStart:Distance(self.PlatformEnd) then continue end
if not IsValid(v) or v:GetPos():DistToSqr(self:GetPos()) > self.PlatformStart:DistToSqr(self.PlatformEnd) then continue end
local platform_distance = ((self.PlatformStart-v:GetPos()) - ((self.PlatformStart-v:GetPos()):Dot(self.PlatformNorm))*self.PlatformNorm):Length()
local vertical_distance = math.abs(v:GetPos().z - self.PlatformStart.z)

View File

@@ -589,7 +589,7 @@ local function enableDebug()
if debug:GetBool() then
hook.Add("PreDrawEffects","MetrostroiSignalDebug",function()
for _,sig in pairs(ents.FindByClass("gmod_track_signal")) do
if IsValid(sig) and LocalPlayer():GetPos():Distance(sig:GetPos()) < 384 then
if IsValid(sig) and LocalPlayer():GetPos():DistToSqr(sig:GetPos()) < 147456 then
local pos = sig:LocalToWorld(Vector(48,0,150))
local ang = sig:LocalToWorldAngles(Angle(0,180,90))
cam.Start3D2D(pos, ang, 0.25)

View File

@@ -5,7 +5,7 @@ local function enableDebug()
if debug:GetBool() then
hook.Add("PostDrawTranslucentRenderables","MetrostroiSignDebug",function(bDrawingDepth,bDrawingSkybox)
for _,ent in pairs(ents.FindByClass("gmod_track_signs")) do
if bDrawingDepth and LocalPlayer():GetPos():Distance(sig:GetPos()) < 512 then
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)

View File

@@ -5,7 +5,7 @@ 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():Distance(ent:GetPos()) < 512 then
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)

View File

@@ -767,8 +767,8 @@ hook.Add("Think","metrostroi_camera_move",function()
local camera = Metrostroi.RenderCam
Metrostroi.RenderCam = nil
if IsValid(camera[1]) then
local distance = camera[1]:LocalToWorld(camera[2]):Distance(LocalPlayer():GetPos())
if distance > 256 then return end
local distance = camera[1]:LocalToWorld(camera[2]):DistToSqr(LocalPlayer():GetPos())
if distance > 65536 then return end
local x,y = camera[9],camera[10]
local scale = camera[11] or 1
local xmin,ymin = camera[12] or 0,camera[13] or 0