diff --git a/OpenRa.Game/MoveOrder.cs b/OpenRa.Game/MoveOrder.cs index 844522b55d..83ea7d2b5d 100644 --- a/OpenRa.Game/MoveOrder.cs +++ b/OpenRa.Game/MoveOrder.cs @@ -28,16 +28,18 @@ namespace OpenRa.Game 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 ) { - Unit.traits.Get().Deploying = true; + Unit.traits.Get().DeployLocation = Location; var mobile = Unit.traits.Get(); mobile.destination = mobile.toCell; } diff --git a/OpenRa.Game/Traits/McvDeploy.cs b/OpenRa.Game/Traits/McvDeploy.cs index b4bee7fffb..50dce28d4c 100644 --- a/OpenRa.Game/Traits/McvDeploy.cs +++ b/OpenRa.Game/Traits/McvDeploy.cs @@ -7,7 +7,7 @@ namespace OpenRa.Game.Traits { class McvDeploy : IOrder, ITick { - public bool Deploying; + public int2? DeployLocation; public McvDeploy(Actor self) { @@ -16,18 +16,26 @@ namespace OpenRa.Game.Traits public Order Order(Actor self, Game game, int2 xy) { // TODO: check that there's enough space at the destination. - if (xy == self.Location) - return new DeployMcvOrder(self); + if( xy == self.Location ) + return new DeployMcvOrder( self, xy ); return null; } public void Tick(Actor self, Game game, int dt) { - if (!Deploying) + var mobile = self.traits.Get(); + + if( mobile.moveFraction < mobile.moveFractionTotal ) return; - if (self.traits.Get().Turn(12)) + if( self.Location != DeployLocation ) + { + DeployLocation = null; + return; + } + + if (mobile.Turn(12)) return; game.world.AddFrameEndTask(_ =>