Skip to content

Commit

Permalink
bookmarks: Implement fly-to bookmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
bwrsandman authored and FalseIlyu committed May 12, 2024
1 parent 62aa08f commit c88b973
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "Debug/Gui.h"
#include "ECS/Archetypes/HandArchetype.h"
#include "ECS/Archetypes/PlayerArchetype.h"
#include "ECS/Components/CameraBookmark.h"
#include "ECS/Components/Mobile.h"
#include "ECS/Components/Transform.h"
#include "ECS/Map.h"
Expand Down Expand Up @@ -254,9 +255,18 @@ bool Game::ProcessEvents(const SDL_Event& event)
const auto index = static_cast<uint8_t>(event.key.keysym.sym - SDLK_1);
Locator::cameraBookmarkSystem::value().SetBookmark(index, handPosition, _camera->GetOrigin());
}
else if (event.key.keysym.mod == 0)
else
{
// TODO(#348): Fly-to the bookmark
const auto& entitiesRegistry = Locator::entitiesRegistry::value();
const size_t index = event.key.keysym.sym - SDLK_1;
const auto& bookmarkEntities = Locator::cameraBookmarkSystem::value().GetBookmarks();
const auto entity = bookmarkEntities.at(index);
const auto [transform, bookmark] =
entitiesRegistry.TryGet<ecs::components::Transform, ecs::components::CameraBookmark>(entity);
if (transform != nullptr && bookmark != nullptr)
{
_camera->GetModel().SetFlight(bookmark->savedOrigin, transform->position);
}
}
break;
}
Expand Down

0 comments on commit c88b973

Please sign in to comment.