git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1323 993157c7-ee19-0410-b2c4-bb4e9862e678

This commit is contained in:
(no author)
2007-07-23 05:47:35 +00:00
parent 5eb3d2ea2d
commit 90168ad5dc
4 changed files with 24 additions and 30 deletions

View File

@@ -54,6 +54,7 @@ namespace OpenRa
}
public static float2 operator *(float a, float2 b) { return new float2(a * b.X, a * b.Y); }
public static float2 operator *( float2 a, float2 b ) { return new float2( a.X * b.X, a.Y * b.Y ); }
public static float2 operator /( float2 a, float2 b ) { return new float2( a.X / b.X, a.Y / b.Y ); }
public static readonly float2 Zero = new float2(0, 0);

View File

@@ -26,12 +26,8 @@ namespace OpenRa.Game
// TODO: check that there's actually some ore in this cell :)
// face in one of the 8 directions
int desiredFacing = ( facing + 1 ) & 28;
if( facing != desiredFacing )
{
Turn( desiredFacing );
if( Turn( ( facing + 1 ) & ~3 ) )
return;
}
currentOrder = delegate { };
if( nextOrder == null )

View File

@@ -18,11 +18,9 @@ namespace OpenRa.Game
{
nextOrder = delegate( Game game, double t )
{
int desiredFacing = 12;
if( facing != desiredFacing )
Turn( desiredFacing );
else
{
if( Turn( 12 ) )
return;
World world = game.world;
world.AddFrameEndTask( delegate
{
@@ -34,7 +32,6 @@ namespace OpenRa.Game
world.Add( (Actor)world.myUnit );
} );
currentOrder = null;
}
};
}

View File

@@ -29,7 +29,7 @@ namespace OpenRa.Game
}
static float2[] fvecs = Util.MakeArray<float2>( 32,
delegate( int i ) { return -float2.FromAngle( i / 16.0f * (float)Math.PI ); } );
delegate( int i ) { return -float2.FromAngle( i / 16.0f * (float)Math.PI ) * new float2( 1f, 1.3f ); } );
int GetFacing( float2 d )
{
@@ -37,7 +37,7 @@ namespace OpenRa.Game
return facing;
int highest = -1;
float highestDot = -1.0f;
float highestDot = -1.0f
for( int i = 0 ; i < fvecs.Length ; i++ )
{
@@ -74,12 +74,8 @@ namespace OpenRa.Game
if( nextOrder != null )
destination = toCell;
int desiredFacing = GetFacing( toCell - fromCell );
if( facing != desiredFacing )
{
Turn( desiredFacing );
if( Turn( GetFacing( toCell - fromCell ) ) )
return;
}
moveFraction += (int)( t * ( Speed * 100 ) );
if( moveFraction < moveFractionTotal )
@@ -108,10 +104,14 @@ namespace OpenRa.Game
};
}
protected void Turn( int desiredFacing )
protected bool Turn( int desiredFacing )
{
if( facing == desiredFacing )
return false;
int df = ( desiredFacing - facing + 32 ) % 32;
facing = ( facing + ( df > 16 ? 31 : 1 ) ) % 32;
return true;
}
public virtual IOrder Order( int2 xy )