include("shared.lua")

function ENT:Draw()
	self:DrawModel()

	if (LocalPlayer():GetPos():Distance(self:GetPos()) < 150 and LocalPlayer():GetPos():Distance(self:GetPos()) > 15) then
		self:DrawInfo()
	end
end

function ENT:DrawTranslucent()
	self:Draw()
end

local OreIcon = Material("materials/zerochain/zrms/ui/zrms_ore.png", "smooth")
local CircleIcon = Material("materials/zerochain/zrms/ui/zrms_circle.png", "smooth")

function ENT:DrawResourceItem(Info, color, offsetY)
	local size = 75
	draw.RoundedBox(1, -2, 69 + offsetY, 4, 7, Color(255, 255, 255, 15))
	surface.SetDrawColor(Color(255, 255, 255, 25))
	surface.SetMaterial(CircleIcon)
	surface.DrawTexturedRect(-38, offsetY, size, size)
	draw.NoTexture()
	surface.SetDrawColor(color)
	surface.SetMaterial(OreIcon)
	surface.DrawTexturedRect(-38, offsetY, size, size)
	draw.NoTexture()
	draw.DrawText(Info .. zrmine.config.BuyerNPC_Mass, "zrmine_gravelcrate_font1", 1, offsetY + 32, Color(255, 255, 255), TEXT_ALIGN_CENTER)
end

function ENT:DrawInfo()
	local Pos = self:GetPos() + Vector(0, 0, 27)
	local Ang = Angle(0, LocalPlayer():EyeAngles().y - 90, LocalPlayer():EyeAngles().z + 90)
	local rTable = {}

	rTable["Coal"] = {
		a = math.Round(self:GetcCoal(), 1),
		c = Color(85, 85, 85)
	}

	rTable["Iron"] = {
		a = math.Round(self:GetcIron(), 1),
		c = Color(104, 85, 87)
	}

	rTable["Bronze"] = {
		a = math.Round(self:GetcBronze(), 1),
		c = Color(158, 72, 39)
	}

	rTable["Silver"] = {
		a = math.Round(self:GetcSilver(), 1),
		c = Color(125, 125, 125)
	}

	rTable["Gold"] = {
		a = math.Round(self:GetcGold(), 1),
		c = Color(189, 143, 49)
	}

	cam.Start3D2D(Pos, Ang, 0.15)
	local oY = -35

	for k, v in pairs(rTable) do
		if (rTable[k].a > 0) then
			self:DrawResourceItem(rTable[k].a, rTable[k].c, oY)
			oY = oY - 70
		end
	end

	cam.End3D2D()
end
------------------------------//
