refactor: separate mob ans world listener
This commit is contained in:
@@ -10,8 +10,6 @@
|
||||
#include "Mobs.h"
|
||||
#include "Team.h"
|
||||
|
||||
#include "misc/ObjectNotifier.h"
|
||||
|
||||
namespace td {
|
||||
namespace game {
|
||||
typedef std::pair<std::int16_t, std::int16_t> ChunkCoord;
|
||||
@@ -127,15 +125,11 @@ public:
|
||||
|
||||
virtual void OnArrowShot(MobPtr target, bool fire, Tower* shooter) {}
|
||||
virtual void OnExplosion(utils::shape::Circle explosion, float centerDamage, Tower* shooter) {}
|
||||
|
||||
virtual void OnMobDamage(MobPtr target, float damage, Tower* damager) {}
|
||||
|
||||
virtual void OnMobDead(MobPtr mob) {}
|
||||
};
|
||||
|
||||
typedef utils::ObjectNotifier<WorldListener> WorldNotifier;
|
||||
|
||||
class World : public WorldNotifier, public WorldListener {
|
||||
class World : public WorldListener, public MobListener {
|
||||
protected:
|
||||
TowerTileColorPalette m_TowerPlacePalette;
|
||||
Color m_WalkablePalette;
|
||||
@@ -152,6 +146,9 @@ protected:
|
||||
TowerList m_Towers;
|
||||
|
||||
Game* m_Game;
|
||||
|
||||
WorldNotifier m_WorldNotifier;
|
||||
MobNotifier m_MobNotifier;
|
||||
public:
|
||||
World(Game* game);
|
||||
|
||||
@@ -211,6 +208,9 @@ public:
|
||||
const TowerList& getTowers() const { return m_Towers; };
|
||||
TowerPtr getTowerById(TowerID tower);
|
||||
|
||||
WorldNotifier& getWorldNotifier() { return m_WorldNotifier; }
|
||||
MobNotifier& getMobNotifier() { return m_MobNotifier; }
|
||||
|
||||
// WorldListener
|
||||
|
||||
virtual void OnArcherTowerShot(MobPtr target, ArcherTower* shooter);
|
||||
@@ -218,6 +218,8 @@ public:
|
||||
virtual void OnArrowShot(MobPtr target, bool fire, Tower* shooter);
|
||||
virtual void OnExplosion(utils::shape::Circle explosion, float centerDamage, Tower* shooter);
|
||||
|
||||
// MobListener
|
||||
|
||||
virtual void OnMobDamage(MobPtr target, float damage, Tower* source);
|
||||
private:
|
||||
void moveMobs(std::uint64_t delta);
|
||||
|
||||
Reference in New Issue
Block a user