+bool Situation::OnSurface() const noexcept {
+ return type == PLANET_SURFACE;
+}
+
+world::Tile &Situation::GetTile() const noexcept {
+ double side_length = planet->SideLength();
+ double offset = side_length * 0.5;
+ double x = std::max(0.0, std::min(side_length, position.x + offset));
+ double y = std::max(0.0, std::min(side_length, position.y + offset));
+ return planet->TileAt(surface, int(x), int(y));
+}
+
+const world::TileType &Situation::GetTileType() const noexcept {
+ return planet->GetSimulation().TileTypes()[GetTile().type];
+}
+
+void Situation::Move(const glm::dvec3 &dp) noexcept {
+ position += dp;
+ if (OnSurface()) {
+ // enforce ground constraint
+ position.z = std::max(0.0, position.z);
+ }
+}
+