local LimitedLifeSystem = inherited("LimitedLifeSystem", SystemMap)

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

function LimitedLifeSystem:wants(ent)
	return ent.aspects.limited_life
end

function LimitedLifeSystem:ent_added(ent)
end

function LimitedLifeSystem:ent_removed(ent)
end

function LimitedLifeSystem:step(dt)
	local world = self.world
	for ent, _ in pairs(self.ents) do
		local life_time = ent.life_time
		if life_time > 0 then
			life_time = life_time - dt
			if life_time <= 0 then
				world:remove_ent(ent)
			else
				ent.life_time = life_time
			end
		end			
	end
end

return LimitedLifeSystem