2013-09-07 18:11:38 -04:00
# pragma once
# include <set>
# include "BlockID.h"
# include "ChunkDef.h"
# include "FastRandom.h"
# include "Mobs/Monster.h" //this is a side-effect of keeping Mobfamily inside Monster class. I'd prefer to keep both (Mobfamily and Monster) inside a "Monster" namespace MG TODO : do it
2013-10-20 07:33:23 -04:00
// fwd:
2013-09-07 18:11:38 -04:00
class cChunk ;
2013-10-20 07:33:23 -04:00
/** This class is used to determine which monster can be spawned in which place
it is essentially static ( eg . Squids spawn in water , Zombies spawn in dark places )
but it also has dynamic part depending on the world . ini settings .
*/
2013-09-07 18:11:38 -04:00
class cMobSpawner
{
public :
// constructor
2013-09-07 19:21:43 -04:00
// a_MobFamily is the Family of mobs that this spawner will spawn
2013-09-07 18:11:38 -04:00
// a_AllowedTypes is the set of types allowed for mobs it will spawn. Empty set
// would result in no spawn at all
2013-09-07 19:21:43 -04:00
// Allowed mobs thah are not of the right Family will not be include (no warning)
2013-10-20 07:33:23 -04:00
cMobSpawner ( cMonster : : eFamily MobFamily , const std : : set < cMonster : : eType > & a_AllowedTypes ) ;
2013-09-07 18:11:38 -04:00
2013-10-20 07:33:23 -04:00
/// Check if specified block can be a Pack center for this spawner
2013-09-07 19:21:43 -04:00
bool CheckPackCenter ( BLOCKTYPE a_BlockType ) ;
// Try to create a monster here
// if this is the first of a Pack : determine the type of monster
2013-10-20 07:33:23 -04:00
// BlockType & BlockMeta are used to decide what kind of Mob can Spawn here
2013-09-07 19:21:43 -04:00
// MaxPackSize is set to the maximal size for a pack this type of mob
2013-10-20 07:33:23 -04:00
cMonster * TryToSpawnHere ( BLOCKTYPE a_BlockType , NIBBLETYPE a_BlockMeta , BLOCKTYPE a_BlockType_below , NIBBLETYPE a_BlockMeta_below , BLOCKTYPE a_BlockType_above , NIBBLETYPE a_BlockMeta_above , EMCSBiome a_Biome , int a_Level , int & a_MaxPackSize ) ;
2013-09-07 19:21:43 -04:00
// mark the beginning of a new Pack
// all mobs of the same Pack are the same type
2013-10-20 07:33:23 -04:00
void NewPack ( void ) ;
2013-09-07 19:21:43 -04:00
// return true if there is at least one allowed type
2013-10-20 07:33:23 -04:00
bool CanSpawnAnything ( void ) ;
2013-09-07 19:21:43 -04:00
2013-10-20 07:33:23 -04:00
typedef const std : : set < cMonster * > tSpawnedContainer ;
tSpawnedContainer & getSpawned ( void ) ;
2013-09-07 19:21:43 -04:00
protected :
// return true if specified type of mob can spawn on specified block
bool CanSpawnHere ( cMonster : : eType a_MobType , BLOCKTYPE a_BlockType , NIBBLETYPE a_BlockMeta , BLOCKTYPE a_BlockType_below , NIBBLETYPE a_BlockMeta_below , BLOCKTYPE a_BlockType_above , NIBBLETYPE a_BlockMeta_above , EMCSBiome a_Biome , int a_Level ) ;
// return a random type that can spawn on specified biome.
// returns E_ENTITY_TYPE_DONOTUSE if none is possible
cMonster : : eType ChooseMobType ( EMCSBiome a_Biome ) ;
// add toAdd inside toAddIn, if toAdd is in m_AllowedTypes
2013-10-20 07:33:23 -04:00
void addIfAllowed ( cMonster : : eType toAdd , std : : set < cMonster : : eType > & toAddIn ) ;
2013-09-07 19:21:43 -04:00
protected :
cMonster : : eFamily m_MonsterFamily ;
std : : set < cMonster : : eType > m_AllowedTypes ;
bool m_NewPack ;
cMonster : : eType m_MobType ;
std : : set < cMonster * > m_Spawned ;
cFastRandom m_Random ;
2013-10-20 07:33:23 -04:00
} ;
2013-09-07 19:21:43 -04:00
2013-09-07 18:11:38 -04:00