local StaminaSystem = inherited("StaminaSystem", SystemMap)

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

function StaminaSystem:dynamic_wants(ent)
	return ent.aspects.stamina and ent:is_stamina_not_full()
end

function StaminaSystem:ent_added(ent)	
end

function StaminaSystem:ent_removed(ent)	
end

function StaminaSystem:step(dt)
	local world = self.world
	for ent, _ in pairs(self.ents) do
		local stamina = ent.stamina
		local max = ent.stamina_max
		stamina = math.approach(stamina, max, dt*ent.stamina_recovery_speed)			
		if stamina >= max then
			ent.stamina = max
			world:check_dynamic_systems(ent)
		else
			ent.stamina = stamina
		end
	end
end

return StaminaSystem