include("shared.lua")

function ENT:Draw()
	self:DrawModel()

	if (LocalPlayer():GetPos():Distance(self:GetPos()) < 200) then
		self:DrawInfo()
	end
end

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

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

function ENT:DrawInfo()
	local Pos = self:GetPos() + Vector(0, 0, 20)
	local Ang = Angle(0, LocalPlayer():EyeAngles().y - 90, 90)
	local amount = math.Round(self:GetResourceAmount(), 2)
	local Text = amount .. zrmine.config.BuyerNPC_Mass

	local rtype = self:GetResourceType()

	if (amount >= zrmine.config.ResourceCrates_Capacity) then
		info = "- " .. zrmine.language.Basket_Full .. " -"
	end

	local rColor = {}
	rColor["Coal"] = Color(85, 85, 85)
	rColor["Iron"] = Color(104, 85, 87)
	rColor["Bronze"] = Color(158, 72, 39)
	rColor["Silver"] = Color(125, 125, 125)
	rColor["Gold"] = Color(189, 143, 49)
	local size = 200
	local cSize = 200 / zrmine.config.ResourceCrates_Capacity
	cSize = cSize * amount

	if (amount > 0) then
		cam.Start3D2D(Pos, Ang, 0.1)
		surface.SetDrawColor(Color(255, 255, 255, 15))
		surface.SetMaterial(CircleIcon)
		surface.DrawTexturedRect(-100, -100, size, size)
		draw.NoTexture()

		if (amount >= zrmine.config.ResourceCrates_Capacity) then
			surface.SetDrawColor(Color(125, 0, 0, 255))
			surface.SetMaterial(CircleIcon)
			surface.DrawTexturedRect(-cSize / 1.9, -cSize / 1.9, cSize + 10, cSize + 10)
			draw.NoTexture()
		end

		surface.SetDrawColor(rColor[rtype])
		surface.SetMaterial(CircleIcon)
		surface.DrawTexturedRect(-cSize / 2, -cSize / 2, cSize, cSize)
		draw.NoTexture()
		draw.DrawText(rtype, "zrmine_resource_font1", 0, -50, zrmine.config.UI["RefinerCrate"].TextColor, TEXT_ALIGN_CENTER)
		draw.DrawText(Text, "zrmine_resource_font1", 0, 0, zrmine.config.UI["RefinerCrate"].TextColor, TEXT_ALIGN_CENTER)
		cam.End3D2D()
	end
end
------------------------------//
