diff --git a/OpenRa.DataStructures/float2.cs b/OpenRa.DataStructures/float2.cs index b0b5a6f4c1..06fc49b828 100644 --- a/OpenRa.DataStructures/float2.cs +++ b/OpenRa.DataStructures/float2.cs @@ -54,7 +54,8 @@ 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 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); diff --git a/OpenRa.Game/Harvester.cs b/OpenRa.Game/Harvester.cs index 772feda071..a7f36b439c 100644 --- a/OpenRa.Game/Harvester.cs +++ b/OpenRa.Game/Harvester.cs @@ -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 ) diff --git a/OpenRa.Game/Mcv.cs b/OpenRa.Game/Mcv.cs index 2fee2e3534..88d22d8081 100644 --- a/OpenRa.Game/Mcv.cs +++ b/OpenRa.Game/Mcv.cs @@ -18,23 +18,20 @@ namespace OpenRa.Game { nextOrder = delegate( Game game, double t ) { - int desiredFacing = 12; - if( facing != desiredFacing ) - Turn( desiredFacing ); - else - { - World world = game.world; - world.AddFrameEndTask( delegate - { - world.Remove( this ); - world.Add( new ConstructionYard( fromCell - new int2( 1, 1 ), palette ) ); - world.Add( new Refinery( fromCell - new int2( 1, -2 ), palette ) ); + if( Turn( 12 ) ) + return; - world.myUnit = new Harvester(fromCell - new int2(0, -4), palette); - world.Add((Actor)world.myUnit); - } ); - currentOrder = null; - } + World world = game.world; + world.AddFrameEndTask( delegate + { + world.Remove( this ); + world.Add( new ConstructionYard( fromCell - new int2( 1, 1 ), palette ) ); + world.Add( new Refinery( fromCell - new int2( 1, -2 ), palette ) ); + + world.myUnit = new Harvester( fromCell - new int2( 0, -4 ), palette ); + world.Add( (Actor)world.myUnit ); + } ); + currentOrder = null; }; } diff --git a/OpenRa.Game/Unit.cs b/OpenRa.Game/Unit.cs index bfdaadc3ce..c6628290ad 100644 --- a/OpenRa.Game/Unit.cs +++ b/OpenRa.Game/Unit.cs @@ -29,7 +29,7 @@ namespace OpenRa.Game } static float2[] fvecs = Util.MakeArray( 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 )