2011-11-04 01:01:55 -04:00
|
|
|
#pragma once
|
|
|
|
|
2012-03-06 16:06:51 -05:00
|
|
|
#include "Vector3i.h"
|
|
|
|
|
2011-11-04 01:01:55 -04:00
|
|
|
class cWorld;
|
|
|
|
class cRedstone
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2012-02-22 10:35:10 -05:00
|
|
|
cRedstone( cWorld* a_World );
|
2011-11-04 01:01:55 -04:00
|
|
|
|
2012-02-22 10:35:10 -05:00
|
|
|
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;
|
|
|
|
}
|
2011-11-04 01:01:55 -04:00
|
|
|
|
2012-03-06 16:06:51 -05:00
|
|
|
static bool IsRepeaterPointingTo( const Vector3i & a_RepeaterPos, char a_MetaData, const Vector3i & a_BlockPos )
|
|
|
|
{
|
2012-03-06 16:56:12 -05:00
|
|
|
switch( a_MetaData & 0x3 )
|
2012-03-06 16:06:51 -05:00
|
|
|
{
|
|
|
|
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 )
|
|
|
|
{
|
2012-03-06 16:56:12 -05:00
|
|
|
switch( a_MetaData & 0x3 )
|
2012-03-06 16:06:51 -05:00
|
|
|
{
|
|
|
|
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 )
|
|
|
|
{
|
2012-03-06 16:56:12 -05:00
|
|
|
switch( a_MetaData & 0x3 )
|
2012-03-06 16:06:51 -05:00
|
|
|
{
|
|
|
|
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();
|
|
|
|
}
|
2011-11-04 01:01:55 -04:00
|
|
|
|
2012-02-22 10:35:10 -05:00
|
|
|
void CalculateRedstone( int, int, int );
|
|
|
|
void ChangeRedstone( int, int, int, bool );
|
|
|
|
bool IsBlockPowered( int, int, int );
|
2011-11-04 01:01:55 -04:00
|
|
|
|
2012-02-22 10:35:10 -05:00
|
|
|
cWorld* m_World;
|
2011-11-04 01:01:55 -04:00
|
|
|
|
2012-02-22 10:35:10 -05:00
|
|
|
char m_Metadata;
|
|
|
|
char m_Direction;
|
2011-11-08 20:31:19 -05:00
|
|
|
|
2012-02-22 10:35:10 -05:00
|
|
|
static bool s_UseRedstone;
|
2011-11-04 01:01:55 -04:00
|
|
|
};
|