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);
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 
bool CanSpawnAnything(void)
Definition: MobSpawner.cpp:483
bool CheckPackCenter(BLOCKTYPE a_BlockType)
Check if specified block can be a Pack center for this spawner.
Definition: MobSpawner.cpp:30
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:42
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:433
static bool CanSpawnHere(cChunk *a_Chunk, Vector3i a_RelPos, eMonsterType a_MobType, EMCSBiome a_Biome)
Returns true if specified type of mob can spawn on specified block.
Definition: MobSpawner.cpp:74
void NewPack(void)
Mark the beginning of a new Pack.
Definition: MobSpawner.cpp:474
EMCSBiome
Biome IDs The first batch corresponds to the clientside biomes, used by MineCraft.
Definition: BiomeDef.h:21
Definition: Chunk.h:49
cMonster::eFamily m_MonsterFamily
Definition: MobSpawner.h:58
eMonsterType
Identifies individual monster type, as well as their network type-ID.
Definition: MonsterTypes.h:10
std::vector< std::unique_ptr< cMonster > > m_Spawned
Definition: MobSpawner.h:62
static std::set< eMonsterType > GetAllowedMobTypes(EMCSBiome a_Biome)
Returns all mob types that can spawn that biome.
Definition: MobSpawner.cpp:299
eMonsterType ChooseMobType(EMCSBiome a_Biome)
Returns a random type that can spawn in the specified biome.
Definition: MobSpawner.cpp:48
This class is used to determine which monster can be spawned in which place it is essentially static ...
Definition: MobSpawner.h:15
std::set< eMonsterType > m_AllowedTypes
Definition: MobSpawner.h:59
bool m_NewPack
Definition: MobSpawner.h:60
std::vector< std::unique_ptr< cMonster > > & getSpawned(void)
Definition: MobSpawner.h:40
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:12
eMonsterType m_MobType
Definition: MobSpawner.h:61