1 #ifndef BLOBS_CREATURE_SITUATION_HPP_
2 #define BLOBS_CREATURE_SITUATION_HPP_
4 #include "../math/glm.hpp"
23 // face direction, normalized
26 const glm::dvec3 &pos = glm::dvec3(0.0),
27 const glm::dvec3 &vel = glm::dvec3(0.0),
28 const glm::dvec3 &dir = glm::dvec3(0.0, 0.0, -1.0))
29 : pos(pos), vel(vel), dir(dir) { }
37 const glm::dvec3 &vel = glm::dvec3(0.0),
38 const glm::dvec3 &acc = glm::dvec3(0.0))
39 : vel(vel), acc(acc) { }
46 Situation(const Situation &) = delete;
47 Situation &operator =(const Situation &) = delete;
49 Situation(Situation &&) = delete;
50 Situation &operator =(Situation &&) = delete;
53 bool OnPlanet() const noexcept;
54 world::Planet &GetPlanet() const noexcept { return *planet; }
55 bool OnSurface() const noexcept;
56 bool OnGround() const noexcept;
57 const glm::dvec3 &Position() const noexcept { return state.pos; }
58 glm::dvec3 SurfaceNormal() const noexcept;
59 world::Tile &GetTile() const noexcept;
60 const world::TileType &GetTileType() const noexcept;
62 void SetState(const State &s) noexcept { state = s; }
63 const State &GetState() const noexcept { return state; }
65 const glm::dvec3 &Velocity() const noexcept { return state.vel; }
66 bool Moving() const noexcept { return glm::length2(state.vel) > 0.00001; }
67 void Move(const glm::dvec3 &dp) noexcept;
68 void Accelerate(const glm::dvec3 &dv) noexcept;
69 void EnforceConstraints(State &) const noexcept;
71 void Heading(const glm::dvec3 &h) noexcept { state.dir = h; }
72 const glm::dvec3 &Heading() const noexcept { return state.dir; }
74 void SetPlanetSurface(world::Planet &, const glm::dvec3 &pos) noexcept;
77 world::Planet *planet;