2023-06-13 21:59:50 +02:00
|
|
|
#ifndef HOLESOME_PLAYER_COLLECTION_HPP
|
|
|
|
#define HOLESOME_PLAYER_COLLECTION_HPP
|
|
|
|
|
|
|
|
|
|
|
|
#include "../game_object.h"
|
|
|
|
#include "player.hpp"
|
|
|
|
|
|
|
|
class PlayerCollection : public GameObject
|
|
|
|
{
|
|
|
|
public:
|
2023-07-03 01:16:44 +02:00
|
|
|
explicit PlayerCollection(int maxPlayerCount = DEFAULT_MAX_PLAYER_NUMBER);
|
2023-06-13 21:59:50 +02:00
|
|
|
|
|
|
|
static std::shared_ptr<PlayerCollection> getInstance();
|
|
|
|
|
|
|
|
void setSpawnPoints(std::vector<GridCoordinates> newSpawnPoints);
|
|
|
|
|
|
|
|
void addPlayer(const std::shared_ptr<Player>& player);
|
|
|
|
|
|
|
|
void removePlayer(const std::shared_ptr<Player>& player);
|
|
|
|
|
2023-07-09 21:24:50 +02:00
|
|
|
std::shared_ptr<Player> getClosestPlayer(const TranslatedCoordinates& point) const;
|
|
|
|
|
2023-06-28 01:13:10 +02:00
|
|
|
[[nodiscard]] std::vector<std::shared_ptr<Player>> getPlayers() const;
|
2023-06-21 16:05:11 +02:00
|
|
|
|
2023-06-28 01:13:10 +02:00
|
|
|
[[nodiscard]] std::shared_ptr<Player> getPlayerById(int playerId) const;
|
2023-06-13 21:59:50 +02:00
|
|
|
|
2023-06-28 01:13:10 +02:00
|
|
|
[[nodiscard]] std::vector<std::shared_ptr<Player>> getNewPlayers() const;
|
|
|
|
|
|
|
|
[[nodiscard]] std::vector<std::shared_ptr<Player>> getRemovedPlayers() const;
|
2023-06-13 21:59:50 +02:00
|
|
|
|
2023-07-03 01:16:44 +02:00
|
|
|
[[nodiscard]] int getMaxPlayerCount() const;
|
|
|
|
|
2023-06-13 21:59:50 +02:00
|
|
|
void lateUpdate() override;
|
|
|
|
|
|
|
|
void clear();
|
|
|
|
|
2023-07-09 23:51:34 +02:00
|
|
|
void activatePlayers();
|
|
|
|
void deactivatePlayers();
|
|
|
|
|
2023-06-13 21:59:50 +02:00
|
|
|
private:
|
|
|
|
static inline std::shared_ptr<PlayerCollection> singletonInstance = nullptr;
|
|
|
|
|
|
|
|
std::vector<std::shared_ptr<Player>> newPlayerBuffer = {};
|
|
|
|
std::vector<std::shared_ptr<Player>> removedPlayerBuffer = {};
|
|
|
|
|
|
|
|
std::vector<GridCoordinates> spawnPoints;
|
|
|
|
int nextSpawnPointIndex = 0;
|
|
|
|
|
|
|
|
void spawnPlayer(const std::shared_ptr<InputIdentity> &inputIdentity);
|
2023-07-03 01:16:44 +02:00
|
|
|
|
2023-07-09 23:51:34 +02:00
|
|
|
std::vector<int> takenSkinIndices = {};
|
|
|
|
|
|
|
|
std::string getNextSkin();
|
|
|
|
|
2023-07-03 01:16:44 +02:00
|
|
|
int maxPlayerCount;
|
|
|
|
|
|
|
|
void updateInputIdentityAllowance() const;
|
2023-06-13 21:59:50 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif //HOLESOME_PLAYER_COLLECTION_HPP
|