From 34928378b8e3464326de38787bfada9adc0bfb11 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 20 Oct 2013 10:23:30 +0200 Subject: Fixed loading allowed mobs in world. --- source/MobTypesManager.h | 58 ++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 24 deletions(-) (limited to 'source/MobTypesManager.h') 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 #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 tMobTypes2Names; - static tMobTypes2Names& m_MobsTypes2Names(); - static tMobTypes2Names MobTypes2NamesInitializerBeforeCx11(); + static tMobTypes2Names& m_MobsTypes2Names(void); + static tMobTypes2Names MobTypes2NamesInitializerBeforeCx11(void); typedef const std::map 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 -- cgit v1.2.3