aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/Village.h
blob: 07858ef98c58cafda460b5f1f7d608150e8b11e0 (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#pragma once

class Village
{
private:
	Level *level;
	vector<shared_ptr<DoorInfo> > doorInfos;

	Pos *accCenter;
	Pos *center;
	int radius;
	int stableSince;
	int _tick;
	int populationSize;
	int noBreedTimer;

	unordered_map<wstring, int> playerStanding;

	class Aggressor
	{
	public:
		shared_ptr<Mob> mob;
		int timeStamp;

		Aggressor(shared_ptr<Mob> mob, int timeStamp);
	};

	vector<Aggressor *> aggressors;
	int golemCount;

public:
	Village();
	Village(Level *level);
	~Village();

	void setLevel(Level *level);

	void tick(int tick);

private:
	Vec3 *findRandomSpawnPos(int x, int y, int z, int sx, int sy, int sz);
	bool canSpawnAt(int x, int y, int z, int sx, int sy, int sz);
	void countGolem();
	void countPopulation();

public:
	Pos *getCenter();
	int getRadius();
	int getDoorCount();
	int getStableAge();
	int getPopulationSize();
	bool isInside(int xx, int yy, int zz);
	vector<shared_ptr<DoorInfo> > *getDoorInfos();
	shared_ptr<DoorInfo> getClosestDoorInfo(int x, int y, int z);
	shared_ptr<DoorInfo> getBestDoorInfo(int x, int y, int z);
	bool hasDoorInfo(int x, int y, int z);
	shared_ptr<DoorInfo> getDoorInfo(int x, int y, int z);
	void addDoorInfo(shared_ptr<DoorInfo> di);
	bool canRemove();
	void addAggressor(shared_ptr<Mob> mob);
	shared_ptr<Mob> getClosestAggressor(shared_ptr<Mob> from);
	shared_ptr<Player> getClosestBadStandingPlayer(shared_ptr<Mob> from); // 4J Stu - Should be LivingEntity when we add that

private:
	void updateAggressors();
	void updateDoors();
	bool isDoor(int x, int y, int z);
	void calcInfo();

public:
	int getStanding(const wstring &playerName);
	int modifyStanding(const wstring &playerName, int delta);
	bool isGoodStanding(const wstring &playerName);
	bool isBadStanding(const wstring &playerName);
	bool isVeryBadStanding(const wstring playerName);
	void readAdditionalSaveData(CompoundTag *tag);
	void addAdditonalSaveData(CompoundTag *tag);
	void resetNoBreedTimer();
	bool isBreedTimerOk();
	void rewardAllPlayers(int amount);
};