2020-09-17 22:45:43 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "CNProtocol.hpp"
|
|
|
|
|
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
|
|
|
#include <set>
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
class Chunk {
|
|
|
|
public:
|
|
|
|
std::set<CNSocket*> players;
|
|
|
|
std::set<int32_t> NPCs;
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace ChunkManager {
|
|
|
|
void init();
|
|
|
|
void cleanup();
|
|
|
|
|
|
|
|
extern std::map<std::pair<int, int>, Chunk*> chunks;
|
|
|
|
|
|
|
|
void addNPC(int posX, int posY, int32_t id);
|
|
|
|
void addPlayer(int posX, int posY, CNSocket* sock);
|
2020-09-21 19:55:34 +00:00
|
|
|
void removePlayer(std::pair<int, int> chunkPos, CNSocket* sock);
|
2020-09-23 14:53:06 +00:00
|
|
|
void removeNPC(std::pair<int, int> chunkPos, int32_t id);
|
2020-09-21 19:55:34 +00:00
|
|
|
bool checkChunk(std::pair<int, int> chunk);
|
2020-09-17 22:45:43 +00:00
|
|
|
std::pair<int, int> grabChunk(int posX, int posY);
|
2020-09-21 19:55:34 +00:00
|
|
|
std::vector<Chunk*> grabChunks(std::pair<int, int> chunkPos);
|
2020-09-17 22:45:43 +00:00
|
|
|
std::vector<Chunk*> getDeltaChunks(std::vector<Chunk*> from, std::vector<Chunk*> to);
|
2020-09-22 18:33:10 +00:00
|
|
|
bool inPopulatedChunks(int posX, int posY);
|
2020-09-17 22:45:43 +00:00
|
|
|
}
|