]> git.localhorst.tv Git - blobs.git/blob - src/creature/Memory.hpp
aggression
[blobs.git] / src / creature / Memory.hpp
1 #ifndef BLOBS_CREATURE_MEMORY_HPP_
2 #define BLOBS_CREATURE_MEMORY_HPP_
3
4 #include "../math/glm.hpp"
5
6 #include <map>
7
8
9 namespace blobs {
10 namespace world {
11         class Planet;
12 }
13 namespace creature {
14
15 class Creature;
16
17 class Memory {
18
19 public:
20         struct Location {
21                 world::Planet *planet;
22                 glm::dvec3 position;
23         };
24
25 public:
26         explicit Memory(Creature &);
27         ~Memory();
28
29 public:
30         /// remove all memories
31         void Erase();
32
33         /// try to remember where stuff was
34         /// when true, pos contains an approximation of the
35         /// location of the best fitting resource
36         bool RememberLocation(const Composition &, glm::dvec3 &pos) const noexcept;
37
38         void TrackCollision(Creature &);
39
40         void Tick(double dt);
41
42 private:
43         /// track time spent on a tile
44         void TrackStay(const Location &, double t);
45
46 private:
47         Creature &c;
48
49         struct Stay {
50                 double first_been;
51                 Location first_loc;
52                 double last_been;
53                 Location last_loc;
54                 double time_spent;
55         };
56         std::map<int, Stay> known_types;
57         struct Profile {
58                 double annoyance = 0.0;
59                 double familiarity = 0.0;
60         };
61         std::map<Creature *, Profile> known_creatures;
62
63 };
64
65 }
66 }
67
68 #endif