OpenFusion/src/ChunkManager.hpp
dongresource ac1fd1e5be Implemented mob roaming.
Will likely need further tuning.
Mobs in vacant chunks are skipped.
2020-09-22 20:33:10 +02:00

31 lines
800 B
C++

#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);
void removePlayer(std::pair<int, int> chunkPos, CNSocket* sock);
bool checkChunk(std::pair<int, int> chunk);
std::pair<int, int> grabChunk(int posX, int posY);
std::vector<Chunk*> grabChunks(std::pair<int, int> chunkPos);
std::vector<Chunk*> getDeltaChunks(std::vector<Chunk*> from, std::vector<Chunk*> to);
bool inPopulatedChunks(int posX, int posY);
}