Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
cMobSpawner Class Reference

This class is used to determine which monster can be spawned in which place it is essentially static (eg. More...

#include <MobSpawner.h>

Public Member Functions

bool CanSpawnAnything (void)
 
bool CheckPackCenter (BLOCKTYPE a_BlockType)
 Check if specified block can be a Pack center for this spawner. More...
 
 cMobSpawner (cMonster::eFamily MobFamily, const std::set< eMonsterType > &a_AllowedTypes)
 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. More...
 
std::vector< std::unique_ptr< cMonster > > & getSpawned (void)
 
void NewPack (void)
 Mark the beginning of a new Pack. More...
 
cMonsterTryToSpawnHere (cChunk *a_Chunk, Vector3i a_RelPos, EMCSBiome a_Biome, int &a_MaxPackSize)
 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 a_MaxPackSize is set to the maximum size for a pack this type of mob. More...
 

Static Public Member Functions

static bool CanSpawnHere (cChunk *a_Chunk, Vector3i a_RelPos, eMonsterType a_MobType, EMCSBiome a_Biome, bool a_DisableSolidBelowCheck=false)
 Returns true if specified type of mob can spawn on specified block. More...
 
static std::set< eMonsterTypeGetAllowedMobTypes (EMCSBiome a_Biome)
 Returns all mob types that can spawn that biome. More...
 

Protected Member Functions

eMonsterType ChooseMobType (EMCSBiome a_Biome)
 Returns a random type that can spawn in the specified biome. More...
 

Protected Attributes

std::set< eMonsterTypem_AllowedTypes
 
eMonsterType m_MobType
 
cMonster::eFamily m_MonsterFamily
 
bool m_NewPack
 
std::vector< std::unique_ptr< cMonster > > m_Spawned
 

Detailed Description

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.

Definition at line 15 of file MobSpawner.h.

Constructor & Destructor Documentation

◆ cMobSpawner()

cMobSpawner::cMobSpawner ( cMonster::eFamily  MobFamily,
const std::set< eMonsterType > &  a_AllowedTypes 
)

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).

Definition at line 13 of file MobSpawner.cpp.

Member Function Documentation

◆ CanSpawnAnything()

bool cMobSpawner::CanSpawnAnything ( void  )

Definition at line 548 of file MobSpawner.cpp.

◆ CanSpawnHere()

bool cMobSpawner::CanSpawnHere ( cChunk a_Chunk,
Vector3i  a_RelPos,
eMonsterType  a_MobType,
EMCSBiome  a_Biome,
bool  a_DisableSolidBelowCheck = false 
)
static

Returns true if specified type of mob can spawn on specified block.

Definition at line 75 of file MobSpawner.cpp.

◆ CheckPackCenter()

bool cMobSpawner::CheckPackCenter ( BLOCKTYPE  a_BlockType)

Check if specified block can be a Pack center for this spawner.

Definition at line 31 of file MobSpawner.cpp.

◆ ChooseMobType()

eMonsterType cMobSpawner::ChooseMobType ( EMCSBiome  a_Biome)
protected

Returns a random type that can spawn in the specified biome.

Returns mtInvalidType if none is possible.

Definition at line 49 of file MobSpawner.cpp.

◆ GetAllowedMobTypes()

std::set< eMonsterType > cMobSpawner::GetAllowedMobTypes ( EMCSBiome  a_Biome)
static

Returns all mob types that can spawn that biome.

Definition at line 355 of file MobSpawner.cpp.

◆ getSpawned()

std::vector<std::unique_ptr<cMonster> >& cMobSpawner::getSpawned ( void  )
inline

Definition at line 40 of file MobSpawner.h.

◆ NewPack()

void cMobSpawner::NewPack ( void  )

Mark the beginning of a new Pack.

All mobs of the same Pack are the same type

Definition at line 539 of file MobSpawner.cpp.

◆ TryToSpawnHere()

cMonster * cMobSpawner::TryToSpawnHere ( cChunk a_Chunk,
Vector3i  a_RelPos,
EMCSBiome  a_Biome,
int &  a_MaxPackSize 
)

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 a_MaxPackSize is set to the maximum size for a pack this type of mob.

Definition at line 480 of file MobSpawner.cpp.

Member Data Documentation

◆ m_AllowedTypes

std::set<eMonsterType> cMobSpawner::m_AllowedTypes
protected

Definition at line 59 of file MobSpawner.h.

◆ m_MobType

eMonsterType cMobSpawner::m_MobType
protected

Definition at line 61 of file MobSpawner.h.

◆ m_MonsterFamily

cMonster::eFamily cMobSpawner::m_MonsterFamily
protected

Definition at line 58 of file MobSpawner.h.

◆ m_NewPack

bool cMobSpawner::m_NewPack
protected

Definition at line 60 of file MobSpawner.h.

◆ m_Spawned

std::vector<std::unique_ptr<cMonster> > cMobSpawner::m_Spawned
protected

Definition at line 62 of file MobSpawner.h.


The documentation for this class was generated from the following files: