refactor: separate mob ans world listener

This commit is contained in:
2021-12-11 18:43:49 +01:00
parent a802b5cef5
commit 1474220a77
7 changed files with 38 additions and 21 deletions

View File

@@ -213,7 +213,7 @@ void ArcherTower::tick(std::uint64_t delta, World* world) {
std::uint8_t arrows = explosiveArrows ? 2 : getLevel().getLevel();
for (MobPtr mob : world->getMobList()) {
if (isMobInRange(mob)) {
world->notifyListeners(&WorldListener::OnArcherTowerShot, mob, this);
world->getWorldNotifier().notifyListeners(&WorldListener::OnArcherTowerShot, mob, this);
m_Timer.applyCooldown();
arrowsShot++;
if (arrowsShot >= arrows)
@@ -229,8 +229,8 @@ void IceTower::tick(std::uint64_t delta, World* world) {
for (MobPtr mob : world->getMobList()) {
if (isMobInRange(mob)) {
mob->addEffect(EffectType::Slowness, 1, this); // slowness for 1s every second
if(damage > 0)
world->notifyListeners(&WorldListener::OnMobDamage, mob, damage, this);
if (damage > 0)
world->getMobNotifier().notifyListeners(&MobListener::OnMobDamage, mob, damage, this);
m_Timer.applyCooldown();
}
}
@@ -253,7 +253,7 @@ void PoisonTower::tick(std::uint64_t delta, World* world) {
for (MobPtr mob : world->getMobList()) {
if (isMobInRange(mob)) {
if (getLevel().getPath() == TowerPath::Bottom) {
world->notifyListeners(&WorldListener::OnMobDamage, mob, getStats()->getDamage(), this);
world->getMobNotifier().notifyListeners(&MobListener::OnMobDamage, mob, getStats()->getDamage(), this);
} else {
float durationSec;
switch (getLevel().getLevel()) {