move cancels attack

This commit is contained in:
Chris Forbes
2009-10-27 00:05:38 +13:00
parent 98bcfe3bce
commit e9faf62c4a
2 changed files with 11 additions and 4 deletions

View File

@@ -242,7 +242,7 @@ namespace OpenRa.Game
unit = new Actor(name, (1 / 24f * producer.CenterLocation).ToInt2(), player); unit = new Actor(name, (1 / 24f * producer.CenterLocation).ToInt2(), player);
var mobile = unit.traits.Get<Mobile>(); var mobile = unit.traits.Get<Mobile>();
mobile.facing = 128; mobile.facing = 128;
mobile.QueueActivity(new Traits.Mobile.MoveTo(unit.Location + new int2(0, 3))); mobile.QueueActivity(new Mobile.MoveTo(unit.Location + new int2(0, 3)));
} }
world.AddFrameEndTask(_ => world.Add(unit)); world.AddFrameEndTask(_ => world.Add(unit));

View File

@@ -1,6 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using System.Linq;
using OpenRa.Game.Traits;
namespace OpenRa.Game namespace OpenRa.Game
{ {
@@ -30,9 +32,14 @@ namespace OpenRa.Game
{ {
if (Game.LocalPlayer == Unit.Owner) if (Game.LocalPlayer == Unit.Owner)
Game.PlaySound(Game.SovietVoices.First.GetNext() + GetVoiceSuffix(), false); Game.PlaySound(Game.SovietVoices.First.GetNext() + GetVoiceSuffix(), false);
var mobile = Unit.traits.Get<Traits.Mobile>();
var mobile = Unit.traits.Get<Mobile>();
mobile.Cancel(Unit); mobile.Cancel(Unit);
mobile.QueueActivity( new Traits.Mobile.MoveTo( Destination ) ); mobile.QueueActivity( new Mobile.MoveTo( Destination ) );
var attackBase = Unit.traits.WithInterface<AttackBase>().FirstOrDefault();
if (attackBase != null)
attackBase.target = null; /* move cancels attack order */
} }
} }
} }