]> git.localhorst.tv Git - blobs.git/blob - src/creature/Memory.hpp
1d72c751bc694516fc608e5a19058d854f925315
[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 Tick(double dt);
39
40 private:
41         /// track time spent on a tile
42         void TrackStay(const Location &, double t);
43
44 private:
45         Creature &c;
46
47         struct Stay {
48                 double first_been;
49                 Location first_loc;
50                 double last_been;
51                 Location last_loc;
52                 double time_spent;
53         };
54         std::map<int, Stay> known_types;
55
56 };
57
58 }
59 }
60
61 #endif