mirror of
https://github.com/ApfelTeeSaft/PlanetFleet.git
synced 2026-08-26 19:33:38 +00:00
74 lines
1.8 KiB
C++
Executable File
74 lines
1.8 KiB
C++
Executable File
#pragma once
|
|
#ifndef MAP_H
|
|
#define MAP_H
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include <vector.h>
|
|
#include <util.h>
|
|
|
|
namespace vb01{
|
|
class Model;
|
|
class Node;
|
|
}
|
|
|
|
namespace battleship{
|
|
class Player;
|
|
struct Cell;
|
|
|
|
struct Edge{
|
|
Cell *cellA, *cellB;
|
|
int weight;
|
|
};
|
|
|
|
struct Cell{
|
|
enum Type{LAND, WATER};
|
|
|
|
Type type;
|
|
vb01::Vector3 pos;
|
|
std::vector<Edge> edges;
|
|
|
|
Cell(){}
|
|
Cell(vb01::Vector3 p, Type t): pos(p), type(t){}
|
|
};
|
|
|
|
class Map {
|
|
public:
|
|
static Map* getSingleton();
|
|
~Map(){}
|
|
void update();
|
|
void load(std::string, bool = false);
|
|
void unload();
|
|
int getCellId(vb01::Vector3, int);
|
|
bool isPointWithinTerrainObject(vb01::Vector3, int);
|
|
inline std::string getMapName(){return mapName;}
|
|
inline vb01::Node* getNodeParent(){return terrainNode;}
|
|
inline vb01::Vector3 getCellSize(){return CELL_SIZE;}
|
|
inline std::vector<Player*> getPlayers() {return players;}
|
|
inline Player* getPlayer(int i){return players[i];}
|
|
inline void addPlayer(Player *p){players.push_back(p);}
|
|
inline int getNumPlayers(){return players.size();}
|
|
inline int getNumSpawnPoints(){return spawnPoints.size();}
|
|
inline vb01::Vector3 getSpawnPoint(int i){return spawnPoints[i];}
|
|
inline void addSpawnPoint(vb01::Vector3 sp){spawnPoints.push_back(sp);}
|
|
private:
|
|
std::string mapTable = "map";
|
|
vb01::Node *terrainNode = nullptr;
|
|
std::string mapName;
|
|
vb01::Vector3 CELL_SIZE = vb01::Vector3(7, 7, 7);
|
|
std::vector<vb01::Vector3> spawnPoints;
|
|
std::vector<Player*> players;
|
|
std::vector<Cell> cells;
|
|
|
|
Map(){}
|
|
void preprareScene();
|
|
void loadSpawnPoints();
|
|
void loadPlayers();
|
|
void loadSkybox();
|
|
void loadTerrainObject(int);
|
|
};
|
|
}
|
|
|
|
#endif
|