Fixed bug #16.

This commit is contained in:
Bob
2009-10-13 21:45:36 +13:00
parent 3b1558d678
commit bdad41c159
2 changed files with 19 additions and 9 deletions

View File

@@ -28,16 +28,18 @@ namespace OpenRa.Game
class DeployMcvOrder : Order class DeployMcvOrder : Order
{ {
Actor Unit; Actor Unit;
int2 Location;
public DeployMcvOrder( Actor unit ) public DeployMcvOrder( Actor unit, int2 location )
{ {
Unit = unit; Unit = unit;
Location = location;
} }
public override void Apply( Game game ) public override void Apply( Game game )
{ {
Unit.traits.Get<Traits.McvDeploy>().Deploying = true; Unit.traits.Get<Traits.McvDeploy>().DeployLocation = Location;
var mobile = Unit.traits.Get<Traits.Mobile>(); var mobile = Unit.traits.Get<Traits.Mobile>();
mobile.destination = mobile.toCell; mobile.destination = mobile.toCell;
} }

View File

@@ -7,7 +7,7 @@ namespace OpenRa.Game.Traits
{ {
class McvDeploy : IOrder, ITick class McvDeploy : IOrder, ITick
{ {
public bool Deploying; public int2? DeployLocation;
public McvDeploy(Actor self) public McvDeploy(Actor self)
{ {
@@ -16,18 +16,26 @@ namespace OpenRa.Game.Traits
public Order Order(Actor self, Game game, int2 xy) public Order Order(Actor self, Game game, int2 xy)
{ {
// TODO: check that there's enough space at the destination. // TODO: check that there's enough space at the destination.
if (xy == self.Location) if( xy == self.Location )
return new DeployMcvOrder(self); return new DeployMcvOrder( self, xy );
return null; return null;
} }
public void Tick(Actor self, Game game, int dt) public void Tick(Actor self, Game game, int dt)
{ {
if (!Deploying) var mobile = self.traits.Get<Mobile>();
if( mobile.moveFraction < mobile.moveFractionTotal )
return; return;
if (self.traits.Get<Mobile>().Turn(12)) if( self.Location != DeployLocation )
{
DeployLocation = null;
return;
}
if (mobile.Turn(12))
return; return;
game.world.AddFrameEndTask(_ => game.world.AddFrameEndTask(_ =>