]> git.localhorst.tv Git - blank.git/blob - src/ai/Spawner.hpp
centralize entity controllers
[blank.git] / src / ai / Spawner.hpp
1 #ifndef BLANK_AI_SPAWNER_HPP_
2 #define BLANK_AI_SPAWNER_HPP_
3
4 #include "../app/IntervalTimer.hpp"
5
6 #include <vector>
7 #include <glm/glm.hpp>
8
9
10 namespace blank {
11
12 class Entity;
13 class GaloisLFSR;
14 class Model;
15 class ModelRegistry;
16 class World;
17
18 class Spawner {
19
20 public:
21         Spawner(World &, ModelRegistry &, GaloisLFSR &);
22         ~Spawner();
23
24         void LimitModels(std::size_t begin, std::size_t end);
25
26         void Update(int dt);
27
28 private:
29         void CheckDespawn() noexcept;
30         void TrySpawn();
31         void Spawn(Entity &reference, const glm::ivec3 &, const glm::vec3 &);
32
33         Model &RandomModel() noexcept;
34
35 private:
36         World &world;
37         ModelRegistry &models;
38         std::vector<Entity *> entities;
39
40         GaloisLFSR &random;
41
42         CoarseTimer timer;
43         float despawn_range;
44         float spawn_distance;
45         unsigned int max_entities;
46         int chunk_range;
47
48         std::size_t model_offset;
49         std::size_t model_length;
50
51 };
52
53 }
54
55 #endif