2023-06-28 16:57:13 +02:00
|
|
|
#include "hole_layout.hpp"
|
|
|
|
#include "../../../player/player_collection.hpp"
|
|
|
|
|
|
|
|
std::shared_ptr<HoleLayout> HoleLayout::getInstance()
|
|
|
|
{
|
|
|
|
if (singletonInstance == nullptr)
|
|
|
|
{
|
|
|
|
singletonInstance = std::make_shared<HoleLayout>();
|
|
|
|
}
|
|
|
|
return singletonInstance;
|
|
|
|
}
|
|
|
|
|
|
|
|
void HoleLayout::clear()
|
|
|
|
{
|
|
|
|
previousHoles.clear();
|
|
|
|
currentHoles.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void HoleLayout::lateUpdate()
|
|
|
|
{
|
|
|
|
// Move history forward
|
|
|
|
previousHoles = currentHoles;
|
|
|
|
currentHoles.clear();
|
|
|
|
|
|
|
|
// Collect hole descriptions of active players
|
|
|
|
for (const auto &player: PlayerCollection::getInstance()->getPlayers())
|
|
|
|
{
|
|
|
|
if (player->getActive())
|
|
|
|
{
|
|
|
|
currentHoles.emplace_back(player);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HoleLayout::HoleLayout()
|
|
|
|
: currentHoles(), previousHoles()
|
|
|
|
{}
|
2023-06-29 21:26:30 +02:00
|
|
|
|
|
|
|
DepthHoleLayout HoleLayout::atDepth(float depth) const
|
|
|
|
{
|
|
|
|
std::vector<DepthHoleDescription> depthHoles{};
|
|
|
|
for (const auto &hole: currentHoles)
|
|
|
|
{
|
|
|
|
depthHoles.push_back(hole.atDepth(depth));
|
|
|
|
}
|
|
|
|
return DepthHoleLayout(depth, depthHoles);
|
|
|
|
}
|