diff options
author | Mattes D <github@xoft.cz> | 2013-11-27 09:23:17 +0100 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2013-11-27 09:23:17 +0100 |
commit | 49760db89d94ede5d123d927141a6cd60dbaaf07 (patch) | |
tree | 6c6cf99e4cf3128311a93cd187947b502f3732a0 /src/MobCensus.h | |
parent | cWorld::SpawnExperienceOrb() now returns the entity ID of the spawned orb. (diff) | |
parent | Fixed VC2008 compilation, normalized include paths. (diff) | |
download | cuberite-49760db89d94ede5d123d927141a6cd60dbaaf07.tar cuberite-49760db89d94ede5d123d927141a6cd60dbaaf07.tar.gz cuberite-49760db89d94ede5d123d927141a6cd60dbaaf07.tar.bz2 cuberite-49760db89d94ede5d123d927141a6cd60dbaaf07.tar.lz cuberite-49760db89d94ede5d123d927141a6cd60dbaaf07.tar.xz cuberite-49760db89d94ede5d123d927141a6cd60dbaaf07.tar.zst cuberite-49760db89d94ede5d123d927141a6cd60dbaaf07.zip |
Diffstat (limited to 'src/MobCensus.h')
-rw-r--r-- | src/MobCensus.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/MobCensus.h b/src/MobCensus.h new file mode 100644 index 000000000..e3892bec6 --- /dev/null +++ b/src/MobCensus.h @@ -0,0 +1,59 @@ + +#pragma once + +#include "MobProximityCounter.h" +#include "MobFamilyCollecter.h" + + + + +// fwd: +class cChunk; +class cMonster; + + + + + +/** 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 + +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: + /// Returns the nested proximity counter + cMobProximityCounter & GetProximityCounter(void); + + // collect an elligible Chunk for Mob Spawning + // MG TODO : code the correct rule (not loaded chunk but short distant from players) + void CollectSpawnableChunk(cChunk & a_Chunk); + + /// Collect a mob - it's distance to player, it's family ... + void CollectMob(cMonster& a_Monster, cChunk& a_Chunk, double a_Distance); + + /// 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; + + 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); +} ; + + + + |