diff options
author | madmaxoft <github@xoft.cz> | 2013-10-20 10:23:30 +0200 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2013-10-20 10:23:30 +0200 |
commit | 34928378b8e3464326de38787bfada9adc0bfb11 (patch) | |
tree | f057fec656fcead894b49315b948c078c2ba07d7 /source/MobTypesManager.h | |
parent | Merge branch 'htmlescape'. (diff) | |
download | cuberite-34928378b8e3464326de38787bfada9adc0bfb11.tar cuberite-34928378b8e3464326de38787bfada9adc0bfb11.tar.gz cuberite-34928378b8e3464326de38787bfada9adc0bfb11.tar.bz2 cuberite-34928378b8e3464326de38787bfada9adc0bfb11.tar.lz cuberite-34928378b8e3464326de38787bfada9adc0bfb11.tar.xz cuberite-34928378b8e3464326de38787bfada9adc0bfb11.tar.zst cuberite-34928378b8e3464326de38787bfada9adc0bfb11.zip |
Diffstat (limited to 'source/MobTypesManager.h')
-rw-r--r-- | source/MobTypesManager.h | 58 |
1 files changed, 34 insertions, 24 deletions
diff --git a/source/MobTypesManager.h b/source/MobTypesManager.h index 941dac729..6fc8bcfeb 100644 --- a/source/MobTypesManager.h +++ b/source/MobTypesManager.h @@ -1,44 +1,54 @@ #pragma once -#include <vector> #include "Mobs/Monster.h" // this is a side effect of declaring cMonster::eType inside cMonster MG TODO : make a namespace + + + +// fwd: class cFastRandom; -// this aggregate static functionnalities about mob types (some could call it helper) -// functionnalities are (in the first version) : -// - create a mob from its type (as enum) (in that way it is a compiler-proxy for mobs) -// - can transform MobTypes from enums to string and reciprocal -// - return mob family from providen type + + + + +/** +This class aggregates static functions about mob types: + - create a mob from its type (as enum) (in that way it is a compiler-proxy for mobs) + - transform MobTypes from enums to string and vice versa + - return mob family from given type +*/ class cMobTypesManager { public: - static const std::string& fromMobTypeToString(cMonster::eType a_MobType); - static cMonster::eType fromStringToMobType(const std::string& a_MobTypeName); - static cMonster::eFamily getFamilyFromType(cMonster::eType a_MobType); + static AString MobTypeToString(cMonster::eType a_MobType); + static cMonster::eType StringToMobType(const AString& a_MobTypeName); + static cMonster::eFamily FamilyFromType(cMonster::eType a_MobType); + + /** create a new object of the specified mob. + a_MobType is the type of the mob to be created + a_Size is the size (for mobs with size) + if a_Size is let to -1 for entities that need size, size will be random + asserts and returns null if mob type is not specified + asserts if invalid size for mobs that need size + */ + static cMonster * NewMonsterFromType(cMonster::eType a_MobType, int a_Size = -1); protected : typedef const std::map<cMonster::eType,std::string> tMobTypes2Names; - static tMobTypes2Names& m_MobsTypes2Names(); - static tMobTypes2Names MobTypes2NamesInitializerBeforeCx11(); + static tMobTypes2Names& m_MobsTypes2Names(void); + static tMobTypes2Names MobTypes2NamesInitializerBeforeCx11(void); typedef const std::map<cMonster::eType,cMonster::eFamily> tMobType2Family; - static tMobType2Family& m_MobsType2Family(); - static tMobType2Family MobType2FamilyInitializerBeforeCx11(); + static tMobType2Family& m_MobsType2Family(void); + static tMobType2Family MobType2FamilyInitializerBeforeCx11(void); - static cFastRandom& m_Random(); + static cFastRandom & m_Random(void); public : - /** create a new object of the specified mob. - Warning, new without delete here; - a_MobType is the type of the mob to be created - a_Size is the size (for mobs with size) - if a_Size is let to -1 for entities that need size, size will be random - assert or return null if mob type is not specified - assert if size < 1 or > 3 for entities that need size - */ - static cMonster* NewMonsterFromType(cMonster::eType a_MobType, int a_Size=-1); +} ; + + -}; // tolua_export |