include("sh_init.lua")
include("cl_maths.lua")
include("cl_panel.lua")

local mat = CreateMaterial("Keypad_Texture", "VertexLitGeneric", {
	["$basetexture"] = "white",
	["$color"] = "{ 36 36 36 }",
})

local local_ply
function ENT:Draw()
	local_ply = local_ply or LocalPlayer()
	if local_ply:EyePos():DistToSqr(self:GetPos()) > 1000000 then
		self:DrawModel()
		return
	end
	render.SetMaterial(mat)
	render.DrawBox(self:GetPos(), self:GetAngles(), self.Mins, self.Maxs, color_white, true)
	local pos, ang = self:CalculateRenderPos(), self:CalculateRenderAng()
	local w, h = self.Width2D, self.Height2D
	local x, y = self:CalculateCursorPos()
	cam.Start3D2D(pos, ang, self.Scale)
		self:Paint(w, h, x, y)
	cam.End3D2D()
end

function ENT:SendCommand(command, data)
	net.Start("Keypad")
		net.WriteEntity(self)
		net.WriteUInt(command, 4)
		if data then
			net.WriteUInt(data, 8)
		end
	net.SendToServer()
end