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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
#pragma once
#include "Vector3i.h"
class cWorld;
class cRedstone
{
public:
cRedstone( cWorld* a_World );
static char RepeaterRotationToMetaData( float a_Rotation )
{
a_Rotation += 90 + 45; // So its not aligned with axis
if( a_Rotation > 360.f ) a_Rotation -= 360.f;
if( a_Rotation >= 0.f && a_Rotation < 90.f )
return 0x1;
else if( a_Rotation >= 180 && a_Rotation < 270 )
return 0x3;
else if( a_Rotation >= 90 && a_Rotation < 180 )
return 0x2;
else
return 0x0;
}
static bool IsRepeaterPointingTo( const Vector3i & a_RepeaterPos, char a_MetaData, const Vector3i & a_BlockPos )
{
switch( a_MetaData )
{
case 0x0:
if( (a_RepeaterPos - a_BlockPos).Equals( Vector3i( 0, 0, 1 ) ) )
{
return true;
}
break;
case 0x1:
if( (a_RepeaterPos - a_BlockPos).Equals( Vector3i(-1, 0, 0 ) ) )
{
return true;
}
break;
case 0x2:
if( (a_RepeaterPos - a_BlockPos).Equals( Vector3i( 0, 0,-1 ) ) )
{
return true;
}
break;
case 0x3:
if( (a_RepeaterPos - a_BlockPos).Equals( Vector3i( 1, 0, 0 ) ) )
{
return true;
}
break;
default:
break;
}
return false;
}
static bool IsRepeaterPointingAway( const Vector3i & a_RepeaterPos, char a_MetaData, const Vector3i & a_BlockPos )
{
switch( a_MetaData )
{
case 0x0:
if( (a_RepeaterPos - a_BlockPos).Equals( Vector3i( 0, 0,-1 ) ) )
{
return true;
}
break;
case 0x1:
if( (a_RepeaterPos - a_BlockPos).Equals( Vector3i( 1, 0, 0 ) ) )
{
return true;
}
break;
case 0x2:
if( (a_RepeaterPos - a_BlockPos).Equals( Vector3i( 0, 0, 1 ) ) )
{
return true;
}
break;
case 0x3:
if( (a_RepeaterPos - a_BlockPos).Equals( Vector3i(-1, 0, 0 ) ) )
{
return true;
}
break;
default:
break;
}
return false;
}
static Vector3i GetRepeaterDirection( char a_MetaData )
{
switch( a_MetaData )
{
case 0x0:
return Vector3i( 0, 0,-1 );
case 0x1:
return Vector3i( 1, 0, 0 );
case 0x2:
return Vector3i( 0, 0, 1 );
case 0x3:
return Vector3i(-1, 0, 0 );
default:
break;
}
return Vector3i();
}
void CalculateRedstone( int, int, int );
void ChangeRedstone( int, int, int, bool );
bool IsBlockPowered( int, int, int );
cWorld* m_World;
char m_Metadata;
char m_Direction;
static bool s_UseRedstone;
};
|