local HealthRenderSystem = inherited("HealthRenderSystem", SystemMap)

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

function HealthRenderSystem:wants(ent)
	return ent.aspects.health and ent.aspects.hud_health and ent:is_health_not_full()
end

function HealthRenderSystem:dynamic_wants(ent)
	return ent.aspects.health and ent.aspects.hud_health and ent:is_health_not_full()
end

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

function HealthRenderSystem:ent_removed(ent)
end

function HealthRenderSystem:render(x, y, scale, perspective, angle, a, r, g, b)
	for ent in pairs(self.ents) do
		local rx = x + ent.rx*scale
		local ry = y + ent.ry*scale*perspective -ent.rz*scale
		ent:health_render(rx, ry, scale, perspective, angle, a, r, g, b)
	end
end

return HealthRenderSystem