include("shared.lua")

surface.CreateFont("AmmoCrate_Font", {font = "Arial Black", size = 80, antialias = true})
surface.CreateFont("AmmoCrate_Little_Font", {font = "Arial Black", size = 40, antialias = true})

local local_ply, distance
local next_use = 0
function ENT:Draw()
	self:DrawModel()
	local_ply = local_ply or LocalPlayer()
	distance = local_ply:EyePos():DistToSqr(self:GetPos())
	if distance < 1000000 then
		local ang = self:GetAngles()
		ang:RotateAroundAxis(ang:Forward(), 90)
		ang:RotateAroundAxis(ang:Right(), 270)
		cam.Start3D2D(self:LocalToWorld(Vector(17, 0, 14.5)), ang, 0.1)
			draw.SimpleTextOutlined("Munitionslager", "AmmoCrate_Font", 0, 0, Color(0, 255, 0, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP, 1, color_black)
			if (next_use or 0) > CurTime() then
				draw.SimpleTextOutlined("Nachschub in "..string.ToMinutesSeconds(next_use - CurTime()).." min.", "AmmoCrate_Little_Font", 0, 60, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP, 1, color_black)
			end
		cam.End3D2D()
	end
end

net.Receive("PoliceEquip_NetworkAmmo", function()
	next_use = net.ReadFloat()
end)