43 lines
1 KiB
C++
43 lines
1 KiB
C++
|
#ifndef HOLESOME_PLAYER_COLLECTION_HPP
|
||
|
#define HOLESOME_PLAYER_COLLECTION_HPP
|
||
|
|
||
|
|
||
|
#include "../game_object.h"
|
||
|
#include "player.hpp"
|
||
|
|
||
|
class PlayerCollection : public GameObject
|
||
|
{
|
||
|
public:
|
||
|
PlayerCollection();
|
||
|
|
||
|
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);
|
||
|
|
||
|
std::vector<std::shared_ptr<Player>> getNewPlayers() const;
|
||
|
|
||
|
std::vector<std::shared_ptr<Player>> getRemovedPlayers() const;
|
||
|
|
||
|
void lateUpdate() override;
|
||
|
|
||
|
void clear();
|
||
|
|
||
|
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);
|
||
|
};
|
||
|
|
||
|
|
||
|
#endif //HOLESOME_PLAYER_COLLECTION_HPP
|