39 lines
973 B
C++
39 lines
973 B
C++
#ifndef HOLESOME_MAP_SIMULATION_HPP
|
|
#define HOLESOME_MAP_SIMULATION_HPP
|
|
|
|
#include <memory>
|
|
#include <box2d/box2d.h>
|
|
#include <SFML/System/Vector2.hpp>
|
|
#include "../../player/player.hpp"
|
|
#include "map_player.hpp"
|
|
|
|
class MapSimulation : public GameObject
|
|
{
|
|
public:
|
|
MapSimulation();
|
|
|
|
void update() override;
|
|
|
|
void physicsUpdate() override;
|
|
|
|
void resetMap(sf::Vector2<int> worldMapSize);
|
|
|
|
static std::shared_ptr<MapSimulation> getInstance();
|
|
|
|
void addPlayer(const std::shared_ptr<Player>& player);
|
|
|
|
[[nodiscard]] std::shared_ptr<MapPlayer> getMapPlayerByBody(b2Body* body) const;
|
|
|
|
private:
|
|
static inline std::shared_ptr<MapSimulation> singletonInstance = nullptr;
|
|
|
|
std::shared_ptr<b2World> world;
|
|
std::map<int, std::shared_ptr<MapPlayer>> mapPlayersById;
|
|
|
|
void constructSquareObstacle(float minX, float minY, float maxX, float maxY);
|
|
|
|
void removePlayer(std::shared_ptr<Player> &player);
|
|
};
|
|
|
|
|
|
#endif //HOLESOME_MAP_SIMULATION_HPP
|