4jcraft/Minecraft.World/WorldGen/Structures/Villages.h
2026-03-13 17:06:56 -05:00

47 lines
1.1 KiB
C++

#pragma once
#include "../../Level/Storage/SavedData.h"
class Villages : public SavedData {
public:
static const std::wstring VILLAGE_FILE_ID;
static const int MaxDoorDist = 32;
private:
Level* level;
std::deque<Pos*> queries;
std::vector<std::shared_ptr<DoorInfo> > unclustered;
std::vector<std::shared_ptr<Village> > villages;
int _tick;
public:
Villages(const std::wstring& id);
Villages(Level* level);
~Villages();
void setLevel(Level* level);
void queryUpdateAround(int x, int y, int z);
void tick();
private:
void removeVillages();
public:
std::vector<std::shared_ptr<Village> >* getVillages();
std::shared_ptr<Village> getClosestVillage(int x, int y, int z,
int maxDist);
private:
void processNextQuery();
void cluster();
void addDoorInfos(Pos* pos);
std::shared_ptr<DoorInfo> getDoorInfo(int x, int y, int z);
void createDoorInfo(int x, int y, int z);
bool hasQuery(int x, int y, int z);
bool isDoor(int x, int y, int z);
public:
void load(CompoundTag* tag);
void save(CompoundTag* tag);
};