X-Git-Url: http://git.localhorst.tv/?p=blobs.git;a=blobdiff_plain;f=src%2Fcreature%2FSituation.hpp;h=a12f4224c64ca9d9dcb5d8ab6cd4bc4ddb1f13ab;hp=a60aeb7aa27ee55595210ef8cf0924ebdd6fc319;hb=b0e73e632f0b681a0af78f889dd82d370563944a;hpb=c475ecb15fb2222977cf64ca7bdbea0f303a4192 diff --git a/src/creature/Situation.hpp b/src/creature/Situation.hpp index a60aeb7..a12f422 100644 --- a/src/creature/Situation.hpp +++ b/src/creature/Situation.hpp @@ -14,6 +14,24 @@ namespace creature { class Situation { +public: + struct State { + glm::dvec3 pos; + glm::dvec3 vel; + State( + const glm::dvec3 &pos = glm::dvec3(0.0), + const glm::dvec3 &vel = glm::dvec3(0.0)) + : pos(pos), vel(vel) { } + }; + struct Derivative { + glm::dvec3 vel; + glm::dvec3 acc; + Derivative( + const glm::dvec3 &vel = glm::dvec3(0.0), + const glm::dvec3 &acc = glm::dvec3(0.0)) + : vel(vel), acc(acc) { } + }; + public: Situation(); ~Situation(); @@ -29,18 +47,22 @@ public: world::Planet &GetPlanet() const noexcept { return *planet; } bool OnSurface() const noexcept; int Surface() const noexcept { return surface; } - const glm::dvec3 &Position() const noexcept { return position; } + const glm::dvec3 &Position() const noexcept { return state.pos; } bool OnTile() const noexcept; glm::ivec2 SurfacePosition() const noexcept; world::Tile &GetTile() const noexcept; const world::TileType &GetTileType() const noexcept; + void SetState(const State &s) noexcept { state = s; } + const State &GetState() const noexcept { return state; } + + bool Moving() const noexcept { return glm::length2(state.vel) < 0.00000001; } void Move(const glm::dvec3 &dp) noexcept; void SetPlanetSurface(world::Planet &, int srf, const glm::dvec3 &pos) noexcept; public: world::Planet *planet; - glm::dvec3 position; + State state; int surface; enum { LOST,