diff options
author | Samuel Barney <samjbarney@gmail.com> | 2013-10-14 18:03:47 +0200 |
---|---|---|
committer | Samuel Barney <samjbarney@gmail.com> | 2013-10-14 18:03:47 +0200 |
commit | 318d5522486f3aedc2e808f955eff97957bd968e (patch) | |
tree | 7d9a3c5ad98585fb298691110dd4296de86a9317 /source/MobCensus.h | |
parent | Merge branch 'master' of https://github.com/mc-server/MCServer (diff) | |
parent | Merge branch 'master' into MobSpawning (diff) | |
download | cuberite-318d5522486f3aedc2e808f955eff97957bd968e.tar cuberite-318d5522486f3aedc2e808f955eff97957bd968e.tar.gz cuberite-318d5522486f3aedc2e808f955eff97957bd968e.tar.bz2 cuberite-318d5522486f3aedc2e808f955eff97957bd968e.tar.lz cuberite-318d5522486f3aedc2e808f955eff97957bd968e.tar.xz cuberite-318d5522486f3aedc2e808f955eff97957bd968e.tar.zst cuberite-318d5522486f3aedc2e808f955eff97957bd968e.zip |
Diffstat (limited to 'source/MobCensus.h')
-rw-r--r-- | source/MobCensus.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/source/MobCensus.h b/source/MobCensus.h new file mode 100644 index 000000000..8aa8f3a6c --- /dev/null +++ b/source/MobCensus.h @@ -0,0 +1,58 @@ + +#pragma once + +#include "MobProximityCounter.h" +#include "MobFamilyCollecter.h" + +class cChunk; +class cMonster; + +// This class is used to collect, 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 : + cMobCensus(); + +protected : + cMobProximityCounter m_ProximityCounter; + cMobFamilyCollecter m_MobFamilyCollecter; + + typedef const std::map<cMonster::eFamily,int> tCapMultipliersMap; + static tCapMultipliersMap& m_CapMultipliers(); + + std::set<cChunk*> m_EligibleForSpawnChunks; + + // count the chunks that are elligible to spawn (for now, the loaded valide not null chunks) + int getChunkNb(); + +public: + typedef const std::map<cMonster::eFamily,int> tMobSpawnRate; + static tMobSpawnRate& m_SpawnRate(); + + // return the nested proximity counter + cMobProximityCounter& getProximityCounter(); + +public : + // 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); + + // return true if the family is caped (i.e. there is more mobs of this family than max) + bool isCaped(cMonster::eFamily a_MobFamily); + + // log the results of census + void logd(); + +protected : + static tCapMultipliersMap CapMultiplierInitializerBeforeCx11(); + static tCapMultipliersMap MobSpawnRateInitializerBeforeCx11(); +}; + |