added AttackTurreted.

This commit is contained in:
Bob
2009-10-18 23:51:00 +13:00
parent 62207efbd9
commit 5f2d89fd63
8 changed files with 144 additions and 54 deletions

View File

@@ -5,18 +5,30 @@ using System.Text;
namespace OpenRa.Game.Traits
{
class Turreted : ITick // temporary.
class Turreted : ITick
{
public int turretFacing = Game.CellSize;
public int turretFacing = 0;
public int? desiredFacing;
public Turreted(Actor self)
{
}
// temporary.
public void Tick(Actor self, Game game, int dt)
{
turretFacing = (turretFacing + 1) % 32;
// 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;
}
}
}
}