diff --git a/source/MobTypesManager.h b/source/MobTypesManager.h index a1b2dfddc..941dac729 100644 --- a/source/MobTypesManager.h +++ b/source/MobTypesManager.h @@ -23,7 +23,7 @@ protected : static tMobTypes2Names& m_MobsTypes2Names(); static tMobTypes2Names MobTypes2NamesInitializerBeforeCx11(); - typedef const std::map tMobType2Family; //MG TODO : this is redundancy with cMonster::getFamily() methods. But almost all the management of MobType is redundancy in this project. Maybe is it optimization, or just historical TODO : understand and do something about it. + typedef const std::map tMobType2Family; static tMobType2Family& m_MobsType2Family(); static tMobType2Family MobType2FamilyInitializerBeforeCx11(); diff --git a/source/Mobs/AggressiveMonster.cpp b/source/Mobs/AggressiveMonster.cpp index d48523373..93dba6d7b 100644 --- a/source/Mobs/AggressiveMonster.cpp +++ b/source/Mobs/AggressiveMonster.cpp @@ -95,12 +95,3 @@ void cAggressiveMonster::Tick(float a_Dt, cChunk & a_Chunk) } -cMonster::eFamily cAggressiveMonster::GetMobFamily() const -{ - return mfHostile; -} - - - - - diff --git a/source/Mobs/AggressiveMonster.h b/source/Mobs/AggressiveMonster.h index c16419542..f22ed5b89 100644 --- a/source/Mobs/AggressiveMonster.h +++ b/source/Mobs/AggressiveMonster.h @@ -20,7 +20,6 @@ public: virtual void EventSeePlayer(cEntity *) override; - virtual eFamily GetMobFamily(void) const override; protected: float m_ChaseTime; diff --git a/source/Mobs/Bat.cpp b/source/Mobs/Bat.cpp index ff86f4139..715f25483 100644 --- a/source/Mobs/Bat.cpp +++ b/source/Mobs/Bat.cpp @@ -13,7 +13,3 @@ cBat::cBat(void) : } -cMonster::eFamily cBat::GetMobFamily() const -{ - return mfAmbient; -} diff --git a/source/Mobs/Bat.h b/source/Mobs/Bat.h index e0afb5744..fd3e00a07 100644 --- a/source/Mobs/Bat.h +++ b/source/Mobs/Bat.h @@ -17,7 +17,6 @@ public: CLASS_PROTODEF(cBat); - virtual eFamily GetMobFamily(void) const override; } ; diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp index a42ae30ee..b378b2bc6 100644 --- a/source/Mobs/Monster.cpp +++ b/source/Mobs/Monster.cpp @@ -9,6 +9,7 @@ #include "../Entities/Player.h" #include "../Defines.h" #include "../MonsterConfig.h" +#include "../MobTypesManager.h" #include "../MersenneTwister.h" #include "../Vector3f.h" @@ -17,6 +18,7 @@ #include "../Tracer.h" #include "../Chunk.h" + // #include "../../iniFile/iniFile.h" @@ -510,3 +512,7 @@ void cMonster::HandleDaylightBurning(cChunk & a_Chunk) +cMonster::eFamily cMonster::GetMobFamily(void) const +{ + return cMobTypesManager::getFamilyFromType(GetMobTypeAsEnum()); +} diff --git a/source/Mobs/Monster.h b/source/Mobs/Monster.h index ef7904e8e..e08fd518a 100644 --- a/source/Mobs/Monster.h +++ b/source/Mobs/Monster.h @@ -94,7 +94,8 @@ public: char GetMobType(void) const {return m_MobType; } // MG TODO : see if we can delete this one. eType GetMobTypeAsEnum(void) const {return (eType)m_MobType; } // MG TODO : see if we should store m_MobType as enum instead of char. - virtual eFamily GetMobFamily(void) const = 0; + eFamily GetMobFamily(void) const; + const char * GetState(); void SetState(const AString & str); diff --git a/source/Mobs/PassiveMonster.cpp b/source/Mobs/PassiveMonster.cpp index 3d7b8c8aa..8c69c8059 100644 --- a/source/Mobs/PassiveMonster.cpp +++ b/source/Mobs/PassiveMonster.cpp @@ -55,11 +55,5 @@ void cPassiveMonster::Tick(float a_Dt, cChunk & a_Chunk) -cMonster::eFamily cPassiveMonster::GetMobFamily() const -{ - return mfPassive; -} - - diff --git a/source/Mobs/PassiveMonster.h b/source/Mobs/PassiveMonster.h index 9d3557727..908bb0ce6 100644 --- a/source/Mobs/PassiveMonster.h +++ b/source/Mobs/PassiveMonster.h @@ -20,7 +20,6 @@ public: /// When hit by someone, run away virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override; - virtual eFamily GetMobFamily(void) const override; } ; diff --git a/source/Mobs/Squid.cpp b/source/Mobs/Squid.cpp index 50265aea4..e6a44079a 100644 --- a/source/Mobs/Squid.cpp +++ b/source/Mobs/Squid.cpp @@ -54,7 +54,3 @@ void cSquid::Tick(float a_Dt, cChunk & a_Chunk) -cMonster::eFamily cSquid::GetMobFamily() const -{ - return mfWater; -} diff --git a/source/Mobs/Squid.h b/source/Mobs/Squid.h index d5f3a74d7..ad299b95c 100644 --- a/source/Mobs/Squid.h +++ b/source/Mobs/Squid.h @@ -21,7 +21,6 @@ public: virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override; - virtual eFamily GetMobFamily(void) const override; } ;