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

60 lines
1.6 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:
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);
2013-10-18 14:02:53 -04:00
/// log the results of census to server console
void Logd(void);
2013-10-18 14:02:53 -04:00
protected :
cMobProximityCounter m_ProximityCounter;
cMobFamilyCollecter m_MobFamilyCollecter;
std::set<cChunk *> m_EligibleForSpawnChunks;
/// Returns the number of chunks that are elligible for spawning (for now, the loaded, valid chunks)
int GetNumChunks();
/// Returns the cap multiplier value of the given monster family
static int GetCapMultiplier(cMonster::eFamily a_MobFamily);
2013-10-18 14:02:53 -04:00
} ;