]> git.localhorst.tv Git - blobs.git/blob - src/creature/Situation.hpp
f29d9b08b96b0e5c07c4bb588e5a1f0cfa896928
[blobs.git] / src / creature / Situation.hpp
1 #ifndef BLOBS_CREATURE_SITUATION_HPP_
2 #define BLOBS_CREATURE_SITUATION_HPP_
3
4 #include "../math/glm.hpp"
5
6
7 namespace blobs {
8 namespace world {
9         class Planet;
10         class Tile;
11         class TileType;
12 }
13 namespace creature {
14
15 class Situation {
16
17 public:
18         struct State {
19                 glm::dvec3 pos;
20                 glm::dvec3 vel;
21                 State(
22                         const glm::dvec3 &pos = glm::dvec3(0.0),
23                         const glm::dvec3 &vel = glm::dvec3(0.0))
24                 : pos(pos), vel(vel) { }
25         };
26         struct Derivative {
27                 glm::dvec3 vel;
28                 glm::dvec3 acc;
29                 Derivative(
30                         const glm::dvec3 &vel = glm::dvec3(0.0),
31                         const glm::dvec3 &acc = glm::dvec3(0.0))
32                 : vel(vel), acc(acc) { }
33         };
34
35 public:
36         Situation();
37         ~Situation();
38
39         Situation(const Situation &) = delete;
40         Situation &operator =(const Situation &) = delete;
41
42         Situation(Situation &&) = delete;
43         Situation &operator =(Situation &&) = delete;
44
45 public:
46         bool OnPlanet() const noexcept;
47         world::Planet &GetPlanet() const noexcept { return *planet; }
48         bool OnSurface() const noexcept;
49         int Surface() const noexcept { return surface; }
50         const glm::dvec3 &Position() const noexcept { return state.pos; }
51         bool OnTile() const noexcept;
52         glm::ivec2 SurfacePosition() const noexcept;
53         world::Tile &GetTile() const noexcept;
54         const world::TileType &GetTileType() const noexcept;
55
56         void SetState(const State &s) noexcept { state = s; }
57         const State &GetState() const noexcept { return state; }
58
59         const glm::dvec3 &Velocity() const noexcept { return state.vel; }
60         bool Moving() const noexcept { return glm::length2(state.vel) < 0.00000001; }
61         void Move(const glm::dvec3 &dp) noexcept;
62         void SetPlanetSurface(world::Planet &, int srf, const glm::dvec3 &pos) noexcept;
63
64 public:
65         world::Planet *planet;
66         State state;
67         int surface;
68         enum {
69                 LOST,
70                 PLANET_SURFACE,
71         } type;
72
73 };
74
75 }
76 }
77
78 #endif