changes facing (and desireFacing) on Mobile and on Turreted. range is now 0..255

This commit is contained in:
Bob
2009-10-19 23:45:14 +13:00
parent 451fdc1615
commit a7ce0f97d1
14 changed files with 162 additions and 150 deletions

View File

@@ -14,21 +14,13 @@ namespace OpenRa.Game.Traits
{
}
public void Tick(Actor self, Game game, int dt)
public void Tick( Actor self, Game game, int dt )
{
// TODO: desiredFacing should follow the base unit's facing only when not in combat.
// also, we want to be able to use this for GUN; avoid referencing Mobile.
var df = desiredFacing ?? self.traits.Get<Mobile>().facing;
if( turretFacing != desiredFacing )
{
var leftTurn = ( 32 + turretFacing - desiredFacing ) % 32;
var rightTurn = ( 32 + desiredFacing - turretFacing ) % 32;
if( leftTurn > rightTurn )
turretFacing = ( turretFacing + 1 ) % 32;
else
turretFacing = ( turretFacing + 31 ) % 32;
}
Util.TickFacing( ref turretFacing, df, self.unitInfo.ROT );
}
}
}