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()
|
|
|
|
{
|
|
|
|
currentHoles.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void HoleLayout::lateUpdate()
|
|
|
|
{
|
|
|
|
currentHoles.clear();
|
|
|
|
|
|
|
|
// Collect hole descriptions of active players
|
|
|
|
for (const auto &player: PlayerCollection::getInstance()->getPlayers())
|
|
|
|
{
|
|
|
|
if (player->getActive())
|
|
|
|
{
|
|
|
|
currentHoles.emplace_back(player);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HoleLayout::HoleLayout()
|
2023-07-05 01:06:57 +02:00
|
|
|
: currentHoles()
|
2023-06-28 16:57:13 +02:00
|
|
|
{}
|
2023-06-29 21:26:30 +02:00
|
|
|
|
|
|
|
DepthHoleLayout HoleLayout::atDepth(float depth) const
|
|
|
|
{
|
|
|
|
std::vector<DepthHoleDescription> depthHoles{};
|
|
|
|
for (const auto &hole: currentHoles)
|
|
|
|
{
|
2023-07-05 01:06:57 +02:00
|
|
|
auto holeAtDepth = hole.atDepth(depth);
|
|
|
|
if (holeAtDepth.width <= 0)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
depthHoles.push_back(holeAtDepth);
|
2023-06-29 21:26:30 +02:00
|
|
|
}
|
2023-07-02 04:22:03 +02:00
|
|
|
return {depth, depthHoles};
|
2023-06-29 21:26:30 +02:00
|
|
|
}
|