move to range actually uses weapon's range now

This commit is contained in:
Chris Forbes
2009-10-27 00:32:11 +13:00
parent b4d75f6195
commit 01a3fc5c62

View File

@@ -82,18 +82,27 @@ namespace OpenRa.Game.Traits
public readonly Actor Attacker;
public readonly Actor Target;
const int RangeTolerance = 1; /* how far inside our maximum range we should try to sit */
public AttackOrder( Actor attacker, Actor target )
{
this.Attacker = attacker;
this.Target = target;
}
public override void Apply()
{
var mobile = Attacker.traits.GetOrDefault<Mobile>();
if (mobile != null)
{
var weapon = Attacker.unitInfo.Primary ?? Attacker.unitInfo.Secondary;
/* todo: choose the appropriate weapon, when only one works against this target */
var range = Rules.WeaponInfo[weapon].Range;
mobile.Cancel(Attacker);
mobile.QueueActivity(new Mobile.MoveTo(Target, 3)); /* todo: get range properly */
mobile.QueueActivity(
new Mobile.MoveTo(Target,
Math.Max(0, (int)range - RangeTolerance)));
}
Attacker.traits.Get<AttackTurreted>().target = Target;