50 lines
1 KiB
C++
50 lines
1 KiB
C++
#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()
|
|
: currentHoles()
|
|
{}
|
|
|
|
DepthHoleLayout HoleLayout::atDepth(float depth) const
|
|
{
|
|
std::vector<DepthHoleDescription> depthHoles{};
|
|
for (const auto &hole: currentHoles)
|
|
{
|
|
auto holeAtDepth = hole.atDepth(depth);
|
|
if (holeAtDepth.width <= 0)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
depthHoles.push_back(holeAtDepth);
|
|
}
|
|
return {depth, depthHoles};
|
|
}
|