1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "MobTypesManager.h"
#include "MersenneTwister.h"
#include "Mobs/Monster.h"
#include "Mobs/IncludeAllMonsters.h"
#include "FastRandom.h"
cMobTypesManager::tMobTypes2Names& cMobTypesManager::m_MobsTypes2Names()
{
static std::map<cMonster::eType,std::string>* value = new std::map<cMonster::eType,std::string>(MobTypes2NamesInitializerBeforeCx11());
return *value;
}
cMobTypesManager::tMobTypes2Names cMobTypesManager::MobTypes2NamesInitializerBeforeCx11()
{
std::map<cMonster::eType,std::string> toReturn;
typedef std::map<cMonster::eType,std::string>::value_type ValueType;
toReturn.insert(ValueType(cMonster::mtMagmaCube,"Magmacube"));
toReturn.insert(ValueType(cMonster::mtSlime,"Slime"));
toReturn.insert(ValueType(cMonster::mtBat,"Bat"));
toReturn.insert(ValueType(cMonster::mtBlaze,"Blaze"));
toReturn.insert(ValueType(cMonster::mtCaveSpider,"Cavespider"));
toReturn.insert(ValueType(cMonster::mtChicken,"Chicken"));
toReturn.insert(ValueType(cMonster::mtCow,"Cow"));
toReturn.insert(ValueType(cMonster::mtCreeper,"Creeper"));
toReturn.insert(ValueType(cMonster::mtEnderman,"Enderman"));
toReturn.insert(ValueType(cMonster::mtGhast,"Ghast"));
toReturn.insert(ValueType(cMonster::mtMooshroom,"Mooshroom"));
toReturn.insert(ValueType(cMonster::mtOcelot,"Ocelot"));
toReturn.insert(ValueType(cMonster::mtPig,"Pig"));
toReturn.insert(ValueType(cMonster::mtSheep,"Sheep"));
toReturn.insert(ValueType(cMonster::mtSilverfish,"Silverfish"));
toReturn.insert(ValueType(cMonster::mtSkeleton,"Skeleton"));
toReturn.insert(ValueType(cMonster::mtSpider,"Spider"));
toReturn.insert(ValueType(cMonster::mtSquid,"Squid"));
toReturn.insert(ValueType(cMonster::mtVillager,"Villager"));
toReturn.insert(ValueType(cMonster::mtWitch,"Witch"));
toReturn.insert(ValueType(cMonster::mtWolf,"Wolf"));
toReturn.insert(ValueType(cMonster::mtZombie,"Zombie"));
toReturn.insert(ValueType(cMonster::mtZombiePigman,"Zombiepigman"));
return toReturn;
}
cMobTypesManager::tMobType2Family& cMobTypesManager::m_MobsType2Family()
{
static std::map<cMonster::eType,cMonster::eFamily>* value = new std::map<cMonster::eType,cMonster::eFamily>(MobType2FamilyInitializerBeforeCx11());
return *value;
}
cMobTypesManager::tMobType2Family cMobTypesManager::MobType2FamilyInitializerBeforeCx11()
{
std::map<cMonster::eType,cMonster::eFamily> toReturn;
typedef std::map<cMonster::eType,cMonster::eFamily>::value_type ValueType;
toReturn.insert(ValueType(cMonster::mtBat,cMonster::mfAmbient));
toReturn.insert(ValueType(cMonster::mtSquid,cMonster::mfWater));
toReturn.insert(ValueType(cMonster::mtCow,cMonster::mfPassive));
toReturn.insert(ValueType(cMonster::mtPig,cMonster::mfPassive));
toReturn.insert(ValueType(cMonster::mtSheep,cMonster::mfPassive));
toReturn.insert(ValueType(cMonster::mtChicken,cMonster::mfPassive));
toReturn.insert(ValueType(cMonster::mtVillager,cMonster::mfPassive));
toReturn.insert(ValueType(cMonster::mtMagmaCube,cMonster::mfHostile));
toReturn.insert(ValueType(cMonster::mtSlime,cMonster::mfHostile));
toReturn.insert(ValueType(cMonster::mtBlaze,cMonster::mfHostile));
toReturn.insert(ValueType(cMonster::mtCaveSpider,cMonster::mfHostile));
toReturn.insert(ValueType(cMonster::mtCreeper,cMonster::mfHostile));
toReturn.insert(ValueType(cMonster::mtEnderman,cMonster::mfHostile));
toReturn.insert(ValueType(cMonster::mtGhast,cMonster::mfHostile));
toReturn.insert(ValueType(cMonster::mtMooshroom,cMonster::mfHostile));
toReturn.insert(ValueType(cMonster::mtOcelot,cMonster::mfHostile));
toReturn.insert(ValueType(cMonster::mtSilverfish,cMonster::mfHostile));
toReturn.insert(ValueType(cMonster::mtSkeleton,cMonster::mfHostile));
toReturn.insert(ValueType(cMonster::mtSpider,cMonster::mfHostile));
toReturn.insert(ValueType(cMonster::mtWitch,cMonster::mfHostile));
toReturn.insert(ValueType(cMonster::mtWolf,cMonster::mfHostile));
toReturn.insert(ValueType(cMonster::mtZombie,cMonster::mfHostile));
toReturn.insert(ValueType(cMonster::mtZombiePigman,cMonster::mfHostile));
return toReturn;
}
cFastRandom& cMobTypesManager::m_Random()
{
static cFastRandom* value = new cFastRandom();
return *value;
}
cMonster* cMobTypesManager::NewMonsterFromType(cMonster::eType a_MobType, int a_Size)
{
cMonster * toReturn = NULL;
// unspecified size get rand[1,3] for Monsters that need size
switch (a_MobType)
{
case cMonster::mtMagmaCube:
case cMonster::mtSlime:
if (a_Size == -1)
{
a_Size = m_Random().NextInt(2,a_MobType)+1;
}
if (a_Size <= 0 || a_Size >= 4)
{
ASSERT(!"Random for size was supposed to pick in [1..3] and picked outside");
a_Size = 1;
}
break;
default : break;
}
// the big switch
switch (a_MobType)
{
case cMonster::mtMagmaCube: toReturn = new cMagmaCube(a_Size); break;
case cMonster::mtSlime: toReturn = new cSlime(a_Size); break;
case cMonster::mtBat: toReturn = new cBat(); break;
case cMonster::mtBlaze: toReturn = new cBlaze(); break;
case cMonster::mtCaveSpider: toReturn = new cCavespider(); break;
case cMonster::mtChicken: toReturn = new cChicken(); break;
case cMonster::mtCow: toReturn = new cCow(); break;
case cMonster::mtCreeper: toReturn = new cCreeper(); break;
case cMonster::mtEnderman: toReturn = new cEnderman(); break;
case cMonster::mtGhast: toReturn = new cGhast(); break;
case cMonster::mtMooshroom: toReturn = new cMooshroom(); break;
case cMonster::mtOcelot: toReturn = new cOcelot(); break;
case cMonster::mtPig: toReturn = new cPig(); break;
// TODO: Implement sheep color
case cMonster::mtSheep: toReturn = new cSheep(0); break;
case cMonster::mtSilverfish: toReturn = new cSilverfish(); break;
// TODO: Implement wither geration
case cMonster::mtSkeleton: toReturn = new cSkeleton(false); break;
case cMonster::mtSpider: toReturn = new cSpider(); break;
case cMonster::mtSquid: toReturn = new cSquid(); break;
case cMonster::mtVillager: toReturn = new cVillager(cVillager::vtFarmer); break;
case cMonster::mtWitch: toReturn = new cWitch(); break;
case cMonster::mtWolf: toReturn = new cWolf(); break;
case cMonster::mtZombie: toReturn = new cZombie(false); break;
case cMonster::mtZombiePigman: toReturn = new cZombiePigman(); break;
default:
{
ASSERT(!"Unhandled Mob type");
}
}
return toReturn;
}
const std::string& cMobTypesManager::fromMobTypeToString(cMonster::eType a_MobType)
{
static std::string toReturnDefault = "";
std::string& toReturn = toReturnDefault;
std::map<cMonster::eType,std::string>::const_iterator itr = m_MobsTypes2Names().find(a_MobType);
if (itr != m_MobsTypes2Names().end())
{
toReturn = itr->second;
}
return toReturn;
}
cMonster::eType cMobTypesManager::fromStringToMobType(const std::string& a_Name)
{
for(std::map<cMonster::eType,std::string>::const_iterator itr = m_MobsTypes2Names().begin(); itr != m_MobsTypes2Names().end(); itr++)
{
if (itr->second == a_Name)
{
return itr->first;
}
}
return cMonster::mtInvalidType;
}
cMonster::eFamily cMobTypesManager::getFamilyFromType(cMonster::eType a_Type)
{
cMonster::eFamily toReturn = cMonster::mfMaxplusone;
std::map<cMonster::eType,cMonster::eFamily>::const_iterator itr = m_MobsType2Family().find(a_Type);
if (itr != m_MobsType2Family().end())
{
toReturn = itr->second;
}
return toReturn;
}
|