summaryrefslogtreecommitdiffstats
path: root/source/cTorch.h
blob: 6bb2291b2bfa63bbb0f7bb0bddd0289d6c408a42 (plain) (blame)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
#pragma once

#include "Vector3i.h"

class cTorch												//tolua_export
{															//tolua_export
public:

	static char DirectionToMetaData( char a_Direction )		//tolua_export
	{														//tolua_export
		switch( a_Direction )
		{
		case 0x0:
			return 0x0;
		case 0x1:
			return 0x5; //standing on floor
		case 0x2:
			return 0x4; // south
		case 0x3:
			return 0x3; // north
		case 0x4:
			return 0x2; // west
		case 0x5:
			return 0x1; // east
		default:
			break;
		};
		return 0x0;
	}														//tolua_export

	static char MetaDataToDirection( char a_MetaData )		//tolua_export
	{														//tolua_export
		switch( a_MetaData )
		{
		case 0x0:
			return 0x0;
		case 0x1:
			return 0x5;
		case 0x2:
			return 0x4;
		case 0x3:
			return 0x3;
		case 0x4:
			return 0x2;
		case 0x5:
			return 0x1;
		default:
			break;
		};
		return 0x0;
	}														//tolua_export

	static bool IsAttachedTo( const Vector3i & a_TorchPos, char a_TorchMeta, const Vector3i & a_BlockPos )
	{
		switch( a_TorchMeta )
		{
		case 0x0:
		case 0x5:	// On floor
			if( (a_TorchPos - a_BlockPos).Equals( Vector3i(0, 1, 0 ) ) )
			{
				return true;
			}
			break;
		case 0x4: // South -Z
			if( (a_TorchPos - a_BlockPos).Equals( Vector3i(0, 0, -1 ) ) )
			{
				return true;
			}
			break;
		case 0x3: // North +Z
			if( (a_TorchPos - a_BlockPos).Equals( Vector3i(0, 0, 1 ) ) )
			{
				return true;
			}
			break;
		case 0x2: // West -X
			if( (a_TorchPos - a_BlockPos).Equals( Vector3i(-1, 0, 0 ) ) )
			{
				return true;
			}
			break;
		case 0x1: // East +X
			if( (a_TorchPos - a_BlockPos).Equals( Vector3i( 1, 0, 0 ) ) )
			{
				return true;
			}
			break;
		default:
			break;
		};
		return false;
	}

};															//tolua_export