local HudTextRenderSystem = inherited("HudTextRenderSystem", SystemMap)

function HudTextRenderSystem:new()
	local ms = instance(self)
	return ms
end

function HudTextRenderSystem:wants(ent)
	return ent.aspects.hud_text
end

function HudTextRenderSystem:ent_added(ent)
	ent.rx = ent.x
	ent.ry = ent.y
	ent.rz = ent.z
end

function HudTextRenderSystem:ent_removed(ent)
end

function HudTextRenderSystem:render_hud(x, y, scale, perspective, angle, a, r, g, b)
	for ent, _ in pairs(self.ents) do
		local hud_text = ent.hud_text
		local hud_font = ent.hud_font
		local rx = x + ent.rx*scale
		local ry = y + ent.ry*scale*perspective -(ent.rz)*scale
		local col = ent.hud_color
		local scale = ent.hud_scale
		video.renderTextSprites(hud_text, rx, ry+fonts.alignY(hud_font, nil, scale), 1, hud_font, a, col.r, col.g, col.b, nil, scale)	
	end
end

return HudTextRenderSystem