OpenFusion/src/ChunkManager.hpp

40 lines
1.2 KiB
C++
Raw Normal View History

2020-09-17 22:45:43 +00:00
#pragma once
#include "CNProtocol.hpp"
#include <utility>
#include <vector>
#include <set>
#include <map>
2020-10-01 01:44:37 +00:00
#include <tuple>
2020-09-17 22:45:43 +00:00
class Chunk {
public:
std::set<CNSocket*> players;
std::set<int32_t> NPCs;
};
2020-10-01 01:44:37 +00:00
enum {
INSTANCE_OVERWORLD, // default instance every player starts in
INSTANCE_IZ, // all infected zones share an instance
INSTANCE_UNIQUE // fusion lairs are generated as requested (+ uid)
};
2020-09-17 22:45:43 +00:00
namespace ChunkManager {
void init();
void cleanup();
2020-10-01 01:44:37 +00:00
extern std::map<std::tuple<int, int, int>, Chunk*> chunks;
2020-09-17 22:45:43 +00:00
2020-10-01 01:44:37 +00:00
void addNPC(int posX, int posY, int instanceID, int32_t id);
void addPlayer(int posX, int posY, int instanceID, CNSocket* sock);
void removePlayer(std::tuple<int, int, int> chunkPos, CNSocket* sock);
void removeNPC(std::tuple<int, int, int> chunkPos, int32_t id);
bool checkChunk(std::tuple<int, int, int> chunk);
void destroyChunk(std::tuple<int, int, int> chunkPos);
2020-10-01 01:44:37 +00:00
std::tuple<int, int, int> grabChunk(int posX, int posY, int instanceID);
std::vector<Chunk*> grabChunks(std::tuple<int, int, int> chunkPos);
2020-09-17 22:45:43 +00:00
std::vector<Chunk*> getDeltaChunks(std::vector<Chunk*> from, std::vector<Chunk*> to);
2020-10-01 01:44:37 +00:00
bool inPopulatedChunks(int posX, int posY, int instanceID);
2020-09-17 22:45:43 +00:00
}