Inside cMonster::getMobFamily() : replacing Polymorphism by Map, in order to remove redundancy
This commit is contained in:
parent
bf4781d0ee
commit
f12ac6b995
@ -23,7 +23,7 @@ protected :
|
||||
static tMobTypes2Names& m_MobsTypes2Names();
|
||||
static tMobTypes2Names MobTypes2NamesInitializerBeforeCx11();
|
||||
|
||||
typedef const std::map<cMonster::eType,cMonster::eFamily> 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<cMonster::eType,cMonster::eFamily> tMobType2Family;
|
||||
static tMobType2Family& m_MobsType2Family();
|
||||
static tMobType2Family MobType2FamilyInitializerBeforeCx11();
|
||||
|
||||
|
@ -95,12 +95,3 @@ void cAggressiveMonster::Tick(float a_Dt, cChunk & a_Chunk)
|
||||
}
|
||||
|
||||
|
||||
cMonster::eFamily cAggressiveMonster::GetMobFamily() const
|
||||
{
|
||||
return mfHostile;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -20,7 +20,6 @@ public:
|
||||
|
||||
virtual void EventSeePlayer(cEntity *) override;
|
||||
|
||||
virtual eFamily GetMobFamily(void) const override;
|
||||
|
||||
protected:
|
||||
float m_ChaseTime;
|
||||
|
@ -13,7 +13,3 @@ cBat::cBat(void) :
|
||||
}
|
||||
|
||||
|
||||
cMonster::eFamily cBat::GetMobFamily() const
|
||||
{
|
||||
return mfAmbient;
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ public:
|
||||
|
||||
CLASS_PROTODEF(cBat);
|
||||
|
||||
virtual eFamily GetMobFamily(void) const override;
|
||||
} ;
|
||||
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -55,11 +55,5 @@ void cPassiveMonster::Tick(float a_Dt, cChunk & a_Chunk)
|
||||
|
||||
|
||||
|
||||
cMonster::eFamily cPassiveMonster::GetMobFamily() const
|
||||
{
|
||||
return mfPassive;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -20,7 +20,6 @@ public:
|
||||
/// When hit by someone, run away
|
||||
virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override;
|
||||
|
||||
virtual eFamily GetMobFamily(void) const override;
|
||||
} ;
|
||||
|
||||
|
||||
|
@ -54,7 +54,3 @@ void cSquid::Tick(float a_Dt, cChunk & a_Chunk)
|
||||
|
||||
|
||||
|
||||
cMonster::eFamily cSquid::GetMobFamily() const
|
||||
{
|
||||
return mfWater;
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ public:
|
||||
|
||||
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
|
||||
|
||||
virtual eFamily GetMobFamily(void) const override;
|
||||
} ;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user