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

60 lines
1.6 KiB
C
Raw Permalink Normal View History

#pragma once
#include "MobProximityCounter.h"
#include "MobFamilyCollecter.h"
2013-10-18 18:02:53 +00:00
// fwd:
class cChunk;
class cMonster;
2013-10-18 18:02:53 +00: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 18:02:53 +00: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:
2015-07-31 14:49:10 +00:00
/** Returns the nested proximity counter */
2013-10-18 18:02:53 +00:00
cMobProximityCounter & GetProximityCounter(void);
// collect an elligible Chunk for Mob Spawning
2013-09-08 10:25:07 +00:00
// MG TODO : code the correct rule (not loaded chunk but short distant from players)
2013-10-18 18:02:53 +00:00
void CollectSpawnableChunk(cChunk & a_Chunk);
2016-02-05 21:45:45 +00:00
2015-07-31 14:49:10 +00:00
/** Collect a mob - its distance to player, its family ... */
void CollectMob(cMonster & a_Monster, cChunk & a_Chunk, double a_Distance);
2015-07-31 14:49:10 +00:00
/** Returns true if the family is capped (i.e. there are more mobs of this family than max) */
2013-10-18 18:02:53 +00:00
bool IsCapped(cMonster::eFamily a_MobFamily);
2016-02-05 21:45:45 +00:00
2015-07-31 14:49:10 +00:00
/** log the results of census to server console */
2013-10-18 18:02:53 +00:00
void Logd(void);
2016-02-05 21:45:45 +00:00
2013-10-18 18:02:53 +00:00
protected :
cMobProximityCounter m_ProximityCounter;
cMobFamilyCollecter m_MobFamilyCollecter;
std::set<cChunk *> m_EligibleForSpawnChunks;
2015-07-31 14:49:10 +00:00
/** Returns the number of chunks that are elligible for spawning (for now, the loaded, valid chunks) */
2013-10-18 18:02:53 +00:00
int GetNumChunks();
2015-07-31 14:49:10 +00:00
/** Returns the cap multiplier value of the given monster family */
static int GetCapMultiplier(cMonster::eFamily a_MobFamily);
2013-10-18 18:02:53 +00:00
} ;