1
0
cuberite-2a/source/MobCensus.h

67 lines
1.8 KiB
C
Raw Normal View History

#pragma once
#include "MobProximityCounter.h"
#include "MobFamilyCollecter.h"
2013-10-18 14:02:53 -04:00
// fwd:
class cChunk;
class cMonster;
2013-10-18 14:02:53 -04:00
/** This class is used to collect information, for each Mob, what is the distance of the closest player
it was first being designed in order to make mobs spawn / despawn / act
as the behaviour and even life of mobs depends on the distance to closest player
2013-10-18 14:02:53 -04:00
as side effect : it also collect the chunks that are elligible for spawning
as side effect 2 : it also know the caps for mobs number and can compare census to this numbers
*/
class cMobCensus
{
public:
typedef const std::map<cMonster::eFamily,int> tMobSpawnRate;
2013-10-18 14:02:53 -04:00
static tMobSpawnRate & m_SpawnRate(void);
2013-10-18 14:02:53 -04:00
/// Returns the nested proximity counter
cMobProximityCounter & GetProximityCounter(void);
// collect an elligible Chunk for Mob Spawning
2013-09-08 06:25:07 -04:00
// MG TODO : code the correct rule (not loaded chunk but short distant from players)
2013-10-18 14:02:53 -04:00
void CollectSpawnableChunk(cChunk & a_Chunk);
2013-10-18 14:02:53 -04:00
/// Collect a mob - it's distance to player, it's family ...
void CollectMob(cMonster& a_Monster, cChunk& a_Chunk, double a_Distance);
2013-10-18 14:02:53 -04:00
/// Returns true if the family is capped (i.e. there are more mobs of this family than max)
bool IsCapped(cMonster::eFamily a_MobFamily);
/// log the results of census to server console
void Logd(void);
protected :
cMobProximityCounter m_ProximityCounter;
cMobFamilyCollecter m_MobFamilyCollecter;
typedef const std::map<cMonster::eFamily,int> tCapMultipliersMap;
static tCapMultipliersMap & m_CapMultipliers(void);
std::set<cChunk *> m_EligibleForSpawnChunks;
/// Returns the number of chunks that are elligible for spawning (for now, the loaded, valid chunks)
int GetNumChunks();
static tCapMultipliersMap CapMultiplierInitializerBeforeCx11(void);
static tCapMultipliersMap MobSpawnRateInitializerBeforeCx11(void);
} ;