Cuberite
A lightweight, fast and extensible game server for Minecraft
MobSpawner.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "Chunk.h"
5 #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
6 
7 
8 
9 
10 
16 {
17 public :
22  cMobSpawner(cMonster::eFamily MobFamily, const std::set<eMonsterType> & a_AllowedTypes);
23 
25  bool CheckPackCenter(BLOCKTYPE a_BlockType);
26 
31  cMonster * TryToSpawnHere(cChunk * a_Chunk, Vector3i a_RelPos, EMCSBiome a_Biome, int & a_MaxPackSize);
32 
35  void NewPack(void);
36 
37  // return true if there is at least one allowed type
38  bool CanSpawnAnything(void);
39 
40  std::vector<std::unique_ptr<cMonster>> & getSpawned(void)
41  {
42  return m_Spawned;
43  }
44 
46  static bool CanSpawnHere(cChunk * a_Chunk, Vector3i a_RelPos, eMonsterType a_MobType, EMCSBiome a_Biome, bool a_DisableSolidBelowCheck = false);
47 
49  static std::set<eMonsterType> GetAllowedMobTypes(EMCSBiome a_Biome);
50 
51 
52 protected :
53 
57 
59  std::set<eMonsterType> m_AllowedTypes;
60  bool m_NewPack;
62  std::vector<std::unique_ptr<cMonster>> m_Spawned;
63 } ;
64 
65 
66 
67 
EMCSBiome
Biome IDs The first batch corresponds to the clientside biomes, used by MineCraft.
Definition: BiomeDef.h:18
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:41
eMonsterType
Identifies individual monster type.
Definition: MonsterTypes.h:11
Definition: Chunk.h:36
This class is used to determine which monster can be spawned in which place it is essentially static ...
Definition: MobSpawner.h:16
std::vector< std::unique_ptr< cMonster > > & getSpawned(void)
Definition: MobSpawner.h:40
bool CheckPackCenter(BLOCKTYPE a_BlockType)
Check if specified block can be a Pack center for this spawner.
Definition: MobSpawner.cpp:31
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 ...
Definition: MobSpawner.cpp:13
static std::set< eMonsterType > GetAllowedMobTypes(EMCSBiome a_Biome)
Returns all mob types that can spawn that biome.
Definition: MobSpawner.cpp:355
eMonsterType m_MobType
Definition: MobSpawner.h:61
eMonsterType ChooseMobType(EMCSBiome a_Biome)
Returns a random type that can spawn in the specified biome.
Definition: MobSpawner.cpp:49
std::vector< std::unique_ptr< cMonster > > m_Spawned
Definition: MobSpawner.h:62
bool m_NewPack
Definition: MobSpawner.h:60
bool CanSpawnAnything(void)
Definition: MobSpawner.cpp:548
void NewPack(void)
Mark the beginning of a new Pack.
Definition: MobSpawner.cpp:539
std::set< eMonsterType > m_AllowedTypes
Definition: MobSpawner.h:59
cMonster * 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,...
Definition: MobSpawner.cpp:480
cMonster::eFamily m_MonsterFamily
Definition: MobSpawner.h:58
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.
Definition: MobSpawner.cpp:75