holesome/src/game/physics/map/map_simulation.hpp

40 lines
973 B
C++
Raw Normal View History

#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"
#include "map_player.hpp"
class MapSimulation : public GameObject
{
public:
MapSimulation();
void update() override;
void physicsUpdate() override;
2023-06-17 19:48:51 +02:00
void resetMap(sf::Vector2<int> worldMapSize);
static std::shared_ptr<MapSimulation> getInstance();
void addPlayer(const std::shared_ptr<Player>& player);
2023-06-28 01:13:10 +02:00
[[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