From a93426a77fc47e92c41c8a9eaf2b37d6d5a3dc1c Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@993157c7-ee19-0410-b2c4-bb4e9862e678> Date: Sun, 15 Jul 2007 18:38:44 +0000 Subject: [PATCH] git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1281 993157c7-ee19-0410-b2c4-bb4e9862e678 --- OpenRa.Game/Mcv.cs | 28 +++++++++++----------------- OpenRa.Game/World.cs | 9 +++------ 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/OpenRa.Game/Mcv.cs b/OpenRa.Game/Mcv.cs index dcc1187189..00ff4d4d7d 100644 --- a/OpenRa.Game/Mcv.cs +++ b/OpenRa.Game/Mcv.cs @@ -72,32 +72,26 @@ namespace OpenRa.Game public override void Tick( double t ) { - if (currentOrder == null) + if( currentOrder == null ) return; - if (float2.WithinEpsilon(location, currentOrder.Destination, 1.0f)) + if( float2.WithinEpsilon( location, currentOrder.Destination, 1.0f ) ) return; Range r = new Range( - new float2(-Speed * (float)t, -Speed * (float)t), - new float2(Speed * (float)t, Speed * (float)t)); + new float2( -Speed * (float)t, -Speed * (float)t ), + new float2( Speed * (float)t, Speed * (float)t ) ); - float2 d = (currentOrder.Destination - location).Constrain(r); + float2 d = ( currentOrder.Destination - location ).Constrain( r ); - int desiredFacing = GetFacing(d); - if (desiredFacing == facing) + int desiredFacing = GetFacing( d ); + int df = (desiredFacing - facing + 32) % 32; + if( df == 0 ) location += d; + else if( df > 16 ) + facing = ( facing + 31 ) % 32; else - { - int df = desiredFacing - facing; - if (df < 0) - df = 32 - df; - - if (df < 32 - df) - facing = (facing + 1) % 32; - else - facing = (facing + 31) % 32; - } + facing = ( facing + 1 ) % 32; } } } diff --git a/OpenRa.Game/World.cs b/OpenRa.Game/World.cs index 39929fc153..cf9eba9e04 100644 --- a/OpenRa.Game/World.cs +++ b/OpenRa.Game/World.cs @@ -37,20 +37,17 @@ namespace OpenRa.Game foreach (Actor a in actors) { - Sprite[] images = a.CurrentImages; - a.Tick( dt ); - if (images == null) - continue; + Sprite[] images = a.CurrentImages; - if (a.location.X > range.End.X || a.location.X < range.Start.X - images[0].bounds.Width) + if( a.location.X > range.End.X || a.location.X < range.Start.X - images[ 0 ].bounds.Width ) continue; if (a.location.Y > range.End.Y || a.location.Y < range.Start.Y - images[0].bounds.Height) continue; - foreach (Sprite image in images) + foreach( Sprite image in images ) spriteRenderer.DrawSprite(image, a.location, a.palette); }