#include "td/game/Towers.h"
#include "td/game/World.h"

namespace td {
namespace game {

void IceTower::Tick(std::uint64_t delta, World* world) {
	if (m_Timer.Update(delta)) {
		float damage = GetStats()->GetDamage();
		for (MobPtr mob : world->GetMobList()) {
			if (IsMobInRange(mob)) {
				mob->AddEffect(EffectType::Slowness, 1, this);    // slowness for 1s every second
				if (damage > 0)
					world->GetMobNotifier().NotifyListeners(&MobListener::OnMobDamage, mob.get(), damage, this);
				m_Timer.ApplyCooldown();
			}
		}
	}
}

} // namespace game
} // namespace td