aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/DoorInfo.cpp
blob: 177b88858de8dd81bd5d43b2c040a9138c9ec500 (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
#include "stdafx.h"

#include "DoorInfo.h"

DoorInfo::DoorInfo(int x, int y, int z, int insideDx, int insideDy, int timeStamp) : x(x), y(y), z(z), insideDx(insideDx), insideDz(insideDy)
{
	removed = false;
	bookings = 0;

	this->timeStamp = timeStamp;
}

int DoorInfo::distanceTo(int x2, int y2, int z2)
{
	return static_cast<int>(sqrt((float)distanceToSqr(x2, y2, z2)));
}

int DoorInfo::distanceToSqr(int x2, int y2, int z2)
{
	int dx = x2 - x;
	int dy = y2 - y;
	int dz = z2 - z;
	return dx * dx + dy * dy + dz * dz;
}

int DoorInfo::distanceToInsideSqr(int x2, int y2, int z2)
{
	int dx = x2 - x - insideDx;
	int dy = y2 - y;
	int dz = z2 - z - insideDz;
	return dx * dx + dy * dy + dz * dz;
}

int DoorInfo::getIndoorX()
{
	return x + insideDx;
}

int DoorInfo::getIndoorY()
{
	return y;
}

int DoorInfo::getIndoorZ()
{
	return z + insideDz;
}

bool DoorInfo::isInsideSide(int testX, int testZ)
{
	int vdx = testX - x;
	int vdz = testZ - z;
	return vdx * insideDx + vdz * insideDz >= 0;
}

void DoorInfo::resetBookingCount()
{
	bookings = 0;
}

void DoorInfo::incBookingCount()
{
	++bookings;
}

int DoorInfo::getBookingsCount()
{
	return bookings;
}