2013-09-07 18:11:38 -04:00
# pragma once
2013-10-28 11:49:06 -04:00
# include "Chunk.h"
2014-07-17 13:13:23 -04:00
# 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-09-07 18:11:38 -04:00
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 :
2015-07-31 10:49:10 -04:00
/** Constructor
a_MobFamily is the Family of mobs that this spawner will spawn
a_AllowedTypes is the set of types allowed for mobs it will spawn . Empty set would result in no spawn at all
Allowed mobs thah are not of the right Family will not be include ( no warning ) . */
2014-09-17 13:40:10 -04:00
cMobSpawner ( cMonster : : eFamily MobFamily , const std : : set < eMonsterType > & a_AllowedTypes ) ;
2013-09-07 18:11:38 -04:00
2015-07-31 10:49:10 -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 ) ;
2015-07-31 10:49:10 -04:00
/** Try to create a monster here
If this is the first of a Pack , determine the type of monster
a_Biome , BlockType & BlockMeta are used to decide what kind of Mob can Spawn here
2019-10-11 05:02:53 -04:00
a_MaxPackSize is set to the maximum size for a pack this type of mob */
cMonster * TryToSpawnHere ( cChunk * a_Chunk , Vector3i a_RelPos , EMCSBiome a_Biome , int & a_MaxPackSize ) ;
2013-09-07 19:21:43 -04:00
2015-07-31 10:49:10 -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
2017-09-11 17:20:49 -04:00
std : : vector < std : : unique_ptr < cMonster > > & getSpawned ( void )
{
return m_Spawned ;
}
2013-09-07 19:21:43 -04:00
2014-09-19 17:00:54 -04:00
/** Returns true if specified type of mob can spawn on specified block */
2020-09-27 13:02:16 -04:00
static bool CanSpawnHere ( cChunk * a_Chunk , Vector3i a_RelPos , eMonsterType a_MobType , EMCSBiome a_Biome , bool a_DisableSolidBelowCheck = false ) ;
2014-09-19 17:00:54 -04:00
2018-04-11 07:17:30 -04:00
/** Returns all mob types that can spawn that biome */
static std : : set < eMonsterType > GetAllowedMobTypes ( EMCSBiome a_Biome ) ;
2019-10-11 05:02:53 -04:00
2014-07-17 10:33:09 -04:00
protected :
2019-10-11 05:02:53 -04:00
2015-07-31 10:49:10 -04:00
/** Returns a random type that can spawn in the specified biome.
Returns mtInvalidType if none is possible . */
2014-09-17 13:40:10 -04:00
eMonsterType ChooseMobType ( EMCSBiome a_Biome ) ;
2013-09-07 19:21:43 -04:00
cMonster : : eFamily m_MonsterFamily ;
2014-09-17 13:40:10 -04:00
std : : set < eMonsterType > m_AllowedTypes ;
2013-09-07 19:21:43 -04:00
bool m_NewPack ;
2014-09-17 13:40:10 -04:00
eMonsterType m_MobType ;
2017-09-11 17:20:49 -04:00
std : : vector < std : : unique_ptr < cMonster > > m_Spawned ;
2013-10-20 07:33:23 -04:00
} ;
2013-09-07 19:21:43 -04:00
2013-09-07 18:11:38 -04:00