aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/Villages.h
blob: 030edc33cecd751f9fb36bc731fd72c868227c97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#pragma once

#include "SavedData.h"

class Villages : public SavedData
{
public:
	static const wstring VILLAGE_FILE_ID;

	static const int MaxDoorDist = 32;

private:
	Level *level;
	deque<Pos *> queries;
	vector<shared_ptr<DoorInfo> > unclustered;
	vector<shared_ptr<Village> > villages;
	int _tick;

public:
	Villages(const wstring &id);
	Villages(Level *level);
	~Villages();

	void setLevel(Level *level);
	void queryUpdateAround(int x, int y, int z);
	void tick();

private:
	void removeVillages();

public:
	vector<shared_ptr<Village> > *getVillages();
	shared_ptr<Village> getClosestVillage(int x, int y, int z, int maxDist);

private:
	void processNextQuery();
	void cluster();
	void addDoorInfos(Pos *pos);
	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);
};