--[[
	lua/autorun/client/InfoCollect.lua
	XTC | (STEAM_0:0:5565681)
	===DStream===
]]

if not CLIENT then return end

local running = false
local EntityData = {}

local function CollectEnts()
	EntityData = ents.GetAll()
end

local function ShowInfo()

for k, v in pairs(EntityData) do
	if v and v:IsValid() then 
		local distance = math.Round(LocalPlayer():GetPos():Distance(v:GetPos()))
		local class = v:GetClass()
		if distance < 3000 then
			local pos = v:GetPos():ToScreen()
			if class == "prop_physics" then 
				draw.DrawText( "Prop", "Default", pos.x, pos.y, Color(0, 255, 0, 255), 1 )
			elseif string.find(class, "door") then 
				draw.DrawText( "Door", "Default", pos.x, pos.y, Color(255, 0, 0, 255), 1 )
			else
				draw.DrawText( class, "Default", pos.x, pos.y, Color(0, 0, 255, 255), 1 )
			end
		end
	end
end

end

concommand.Add("stopscore", function() 
	if running == true then 
		timer.Destroy("UpdateInfoz")
		hook.Remove("HUDPaint", "ShowInfo")
		running = false
	end 

end)
concommand.Add("showscore", function() 
	if running == false then 
		timer.Create("UpdateInfoz", 1, 0, CollectEnts)
		hook.Add("HUDPaint", "ShowInfo", ShowInfo)
		running = true
	end 

end)

concommand.Add("map_delete", function(ply, cmd, args) 
	local target = LocalPlayer():GetEyeTrace().Entity
	if target:IsValid() then
		print("Ent Class: " .. target:GetClass())
		print("Ent Model: " .. target:GetModel())
		file.Append("map_delete.txt", "Class: " .. target:GetClass() .. " Model: " .. target:GetModel() .. " Pos: {" .. target:GetPos().x .. ", " .. target:GetPos().y .. ", " .. target:GetPos().z .. "}\n\n")
	end
end)

concommand.Add("map_freeze", function(ply, cmd, args) 
	local target = LocalPlayer():GetEyeTrace().Entity
	if target:IsValid() then
		print("Ent Class: " .. target:GetClass())
		print("Ent Model: " .. target:GetModel())
		file.Append("map_freeze.txt", "Class: " .. target:GetClass() .. " Model: " .. target:GetModel() .. " Pos: {" .. target:GetPos().x .. ", " .. target:GetPos().y .. ", " .. target:GetPos().z .. "}\n\n")
	end
end)

concommand.Add("map_door", function(ply, cmd, args) 
	if not args[1] then chat.AddText("Specify a name!") return end
	local target = LocalPlayer():GetEyeTrace().Entity
	if target:IsValid() then
		print("Ent Class: " .. target:GetClass())
		print("Ent Model: " .. target:GetModel())
		file.Append("map_door.txt", "Name: " .. args[1] .. " Class: " .. target:GetClass() .. " Model: " .. target:GetModel() .. " Pos: {" .. target:GetPos().x .. ", " .. target:GetPos().y .. ", " .. target:GetPos().z .. "}\n\n")
	end
end)

concommand.Add("map_npc", function(ply, cmd, args)
	if not args[1] then chat.AddText("Specify a name!") return end
	local target = LocalPlayer():GetEyeTrace().HitPos
	file.Append("map_npc.txt",  "Name: " .. args[1] .. " Pos: {" .. target.x .. ", " .. target.y .. ", " .. target.z .. "}\n\n")
end)


/*
function DrawPropertyVectors()
	if not Pos1 or not Pos2 then print("not drawing") return end
	
	local Pos1A = Vector(Pos2.x, Pos1.y, Pos1.z):ToScreen()
	local Pos1B = Vector(Pos2.x, Pos1.y, Pos2.z):ToScreen()
	local Pos1C = Vector(Pos1.x, Pos1.y, Pos2.z):ToScreen()
	local Pos2A = Vector(Pos2.x, Pos2.y, Pos1.z):ToScreen()
	local Pos2B = Vector(Pos1.x, Pos2.y, Pos1.z):ToScreen()
	local Pos2C = Vector(Pos1.x, Pos2.y, Pos2.z):ToScreen()
	
	local TPos1 = Pos1:ToScreen()
	local TPos2 = Pos2:ToScreen()
	
	surface.SetMaterial( BlueLaser )
	surface.SetDrawColor(255,0,0,255)
	
	--Pos1Box
	surface.DrawLine(TPos1.x, TPos1.y, Pos1A.x, Pos1A.y)
	surface.DrawLine(Pos1A.x, Pos1A.y, Pos1B.x, Pos1B.y)
	surface.DrawLine(Pos1B.x, Pos1B.y, Pos1C.x, Pos1C.y)
	surface.DrawLine(Pos1C.x, Pos1C.y, TPos1.x, TPos1.y)
	--Pos2Box
	surface.DrawLine(TPos2.x, TPos2.y, Pos2A.x, Pos2A.y)
	surface.DrawLine(Pos2A.x, Pos2A.y, Pos2B.x, Pos2B.y)
	surface.DrawLine(Pos2B.x, Pos2B.y, Pos2C.x, Pos2C.y)
	surface.DrawLine(Pos2C.x, Pos2C.y, TPos2.x, TPos2.y)
	--Connections between boxes
	surface.DrawLine(TPos1.x, TPos1.y, Pos2B.x, Pos2B.y)
	surface.DrawLine(Pos1A.x, Pos1A.y, Pos2A.x, Pos2A.y)
	surface.DrawLine(Pos1B.x, Pos1B.y, TPos2.x, TPos2.y)
	surface.DrawLine(Pos1C.x, Pos1C.y, Pos2C.x, Pos2C.y)
	
	
end
hook.Add("HUDPaint", "DrawPropertyVectors", DrawPropertyVectors)
*/

local Pos1 
local Pos2
local BlueLaser = Material("sprites/bluelaser1")
local beamcolor = Color(255,255,255,255)
function DrawPropertyVectors()
	if not Pos1 or not Pos2 then return end
	
	local Pos1A = Vector(Pos2.x, Pos1.y, Pos1.z)
	local Pos1B = Vector(Pos2.x, Pos1.y, Pos2.z)
	local Pos1C = Vector(Pos1.x, Pos1.y, Pos2.z)
	local Pos2A = Vector(Pos2.x, Pos2.y, Pos1.z)
	local Pos2B = Vector(Pos1.x, Pos2.y, Pos1.z)
	local Pos2C = Vector(Pos1.x, Pos2.y, Pos2.z)

	render.SetMaterial( BlueLaser )
	
	cam.IgnoreZ( true )
	--Pos1Box
	render.DrawBeam( Pos1, Pos1A, 5, 5, 5, beamcolor )
	render.DrawBeam( Pos1A, Pos1B, 5, 5, 5, beamcolor )
	render.DrawBeam( Pos1B, Pos1C, 5, 5, 5, beamcolor )
	render.DrawBeam( Pos1C, Pos1, 5, 5, 5, beamcolor )
	--Pos2Box
	render.DrawBeam( Pos2, Pos2A, 5, 5, 5, beamcolor )
	render.DrawBeam( Pos2A, Pos2B, 5, 5, 5, beamcolor )
	render.DrawBeam( Pos2B, Pos2C, 5, 5, 5, beamcolor )
	render.DrawBeam( Pos2C, Pos2, 5, 5, 5, beamcolor )
	--Connections between boxes
	render.DrawBeam( Pos1, Pos2B, 5, 5, 5, beamcolor )
	render.DrawBeam( Pos1A, Pos2A, 5, 5, 5, beamcolor )
	render.DrawBeam( Pos1B, Pos2, 5, 5, 5, beamcolor )
	render.DrawBeam( Pos1C, Pos2C, 5, 5, 5, beamcolor )
	cam.IgnoreZ( false )
	
	
end
hook.Add("PostDrawOpaqueRenderables", "DrawPropertyVectors", DrawPropertyVectors)

concommand.Add("SetPos1", function(ply, cmd, args)
	Pos1 = ply:GetEyeTrace().HitPos
	print("Pos1")
	print("Vector(" .. Pos1.x .. ", " .. Pos1.y .. ", " .. Pos1.z .. " )")
end)

concommand.Add("SetPos2", function(ply, cmd, args)
	Pos2 = ply:GetEyeTrace().HitPos
	print("Pos2")
	print("Vector(" .. Pos2.x .. ", " .. Pos2.y .. ", " .. Pos2.z .. " )")
	print("Set To Clipboard")
	SetClipboardText("Vector(" .. Pos1.x .. ", " .. Pos1.y .. ", " .. Pos1.z .. " ), " .. "Vector(" .. Pos2.x .. ", " .. Pos2.y .. ", " .. Pos2.z .. " )");
end)

concommand.Add("ResetPos", function(ply, cmd, args)
	Pos1 = nil
	Pos2 = nil
end)

print("Reloaded Script")














