2023-06-10 14:48:16 +02:00
|
|
|
#ifndef HOLESOME_MAP_SIMULATION_HPP
|
|
|
|
#define HOLESOME_MAP_SIMULATION_HPP
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <box2d/box2d.h>
|
|
|
|
#include <SFML/System/Vector2.hpp>
|
2023-06-11 15:54:05 +02:00
|
|
|
#include "../../player/player.hpp"
|
2023-06-10 14:48:16 +02:00
|
|
|
#include "map_player.hpp"
|
|
|
|
|
2023-06-13 21:59:50 +02:00
|
|
|
class MapSimulation : public GameObject
|
2023-06-10 14:48:16 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
MapSimulation();
|
|
|
|
|
2023-06-13 21:59:50 +02:00
|
|
|
void update() override;
|
|
|
|
|
|
|
|
void physicsUpdate() override;
|
2023-06-10 14:48:16 +02:00
|
|
|
|
|
|
|
void resetMap(sf::Vector2f worldMapSize);
|
|
|
|
|
|
|
|
static std::shared_ptr<MapSimulation> getInstance();
|
|
|
|
|
2023-06-13 19:04:38 +02:00
|
|
|
void addPlayer(const std::shared_ptr<Player>& player);
|
2023-06-10 14:48:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2023-06-13 21:59:50 +02:00
|
|
|
void removePlayer(std::shared_ptr<Player> &player);
|
2023-06-10 14:48:16 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif //HOLESOME_MAP_SIMULATION_HPP
|