Add AttackSource enum.

This commit is contained in:
Paul Chote
2020-01-10 20:46:03 +00:00
committed by teinarss
parent 6f52365f9d
commit 51870a471a
15 changed files with 20 additions and 18 deletions

View File

@@ -72,7 +72,7 @@ namespace OpenRA.Mods.Cnc.Traits
leapToken = conditionManager.RevokeCondition(self, leapToken);
}
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor)
public override Activity GetAttackActivity(Actor self, AttackSource source, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor)
{
return new LeapAttack(self, newTarget, allowMove, forceAttack, this, info, targetLineColor);
}

View File

@@ -30,7 +30,7 @@ namespace OpenRA.Mods.Cnc.Traits
public AttackTDGunboatTurreted(Actor self, AttackTDGunboatTurretedInfo info)
: base(self, info) { }
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor)
public override Activity GetAttackActivity(Actor self, AttackSource source, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor)
{
return new AttackTDGunboatTurretedActivity(self, newTarget, allowMove, forceAttack, targetLineColor);
}

View File

@@ -78,7 +78,7 @@ namespace OpenRA.Mods.Cnc.Traits
void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel) { }
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)
public override Activity GetAttackActivity(Actor self, AttackSource source, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)
{
return new ChargeAttack(this, newTarget, forceAttack, targetLineColor);
}

View File

@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Cnc.Traits
{
base.Activate(self, order, manager);
attack.AttackTarget(order.Target, false, false, true);
attack.AttackTarget(order.Target, AttackSource.Default, false, false, true);
}
protected override void Created(Actor self)

View File

@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Common.Activities
ChildActivity.Cancel(self);
var attackBases = autoTarget.ActiveAttackBases;
foreach (var ab in attackBases)
QueueChild(ab.GetAttackActivity(self, target, false, false));
QueueChild(ab.GetAttackActivity(self, AttackSource.AttackMove, target, false, false));
// Make sure to continue moving when the attack activities have finished.
QueueChild(getInner());

View File

@@ -98,7 +98,7 @@ namespace OpenRA.Mods.Common.Scripting
Log.Write("lua", "{1} is not revealed for player {0}!", Self.Owner, targetActor);
foreach (var attack in attackBases)
attack.AttackTarget(target, true, allowMove, forceAttack);
attack.AttackTarget(target, AttackSource.Default, true, allowMove, forceAttack);
}
[Desc("Checks if the targeted actor is a valid target for this actor.")]

View File

@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Traits
aircraftInfo = self.Info.TraitInfo<AircraftInfo>();
}
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)
public override Activity GetAttackActivity(Actor self, AttackSource source, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)
{
return new FlyAttack(self, newTarget, forceAttack, targetLineColor);
}

View File

@@ -86,7 +86,7 @@ namespace OpenRA.Mods.Common.Traits
OnRemovedFromWorld(self);
}
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor)
public override Activity GetAttackActivity(Actor self, AttackSource source, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor)
{
throw new NotImplementedException("AttackBomber requires a scripted target");
}

View File

@@ -21,6 +21,8 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
public enum AttackSource { Default, AutoTarget, AttackMove }
public abstract class AttackBaseInfo : PausableConditionalTraitInfo
{
[Desc("Armament names")]
@@ -199,7 +201,7 @@ namespace OpenRA.Mods.Common.Traits
if (!order.Target.IsValidFor(self))
return;
AttackTarget(order.Target, order.Queued, true, forceAttack, Info.TargetLineColor);
AttackTarget(order.Target, AttackSource.Default, order.Queued, true, forceAttack, Info.TargetLineColor);
self.ShowTargetLines();
}
@@ -224,7 +226,7 @@ namespace OpenRA.Mods.Common.Traits
return order.OrderString == attackOrderName || order.OrderString == forceAttackOrderName ? Info.Voice : null;
}
public abstract Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null);
public abstract Activity GetAttackActivity(Actor self, AttackSource source, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null);
public bool HasAnyValidWeapons(Target t, bool checkForCenterTargetingWeapons = false)
{
@@ -391,7 +393,7 @@ namespace OpenRA.Mods.Common.Traits
&& a.Weapon.IsValidAgainst(t, self.World, self));
}
public void AttackTarget(Target target, bool queued, bool allowMove, bool forceAttack = false, Color? targetLineColor = null)
public void AttackTarget(Target target, AttackSource source, bool queued, bool allowMove, bool forceAttack = false, Color? targetLineColor = null)
{
if (IsTraitDisabled)
return;
@@ -399,7 +401,7 @@ namespace OpenRA.Mods.Common.Traits
if (!target.IsValidFor(self))
return;
var activity = GetAttackActivity(self, target, allowMove, forceAttack, targetLineColor);
var activity = GetAttackActivity(self, source, target, allowMove, forceAttack, targetLineColor);
self.QueueActivity(queued, activity);
OnResolveAttackOrder(self, activity, target, queued, forceAttack);
}

View File

@@ -152,7 +152,7 @@ namespace OpenRA.Mods.Common.Traits
base.Tick(self);
}
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)
public override Activity GetAttackActivity(Actor self, AttackSource source, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)
{
return new AttackActivity(self, newTarget, allowMove, forceAttack, targetLineColor);
}

View File

@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Traits
return TargetInFiringArc(self, target, Info.FacingTolerance);
}
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)
public override Activity GetAttackActivity(Actor self, AttackSource source, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)
{
return new Activities.Attack(self, newTarget, allowMove, forceAttack, targetLineColor);
}

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Traits
public AttackOmni(Actor self, AttackOmniInfo info)
: base(self, info) { }
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)
public override Activity GetAttackActivity(Actor self, AttackSource source, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor = null)
{
return new SetTarget(this, newTarget, allowMove, forceAttack, targetLineColor);
}

View File

@@ -321,7 +321,7 @@ namespace OpenRA.Mods.Common.Traits
void Attack(Actor self, Target target, bool allowMove)
{
foreach (var ab in ActiveAttackBases)
ab.AttackTarget(target, false, allowMove);
ab.AttackTarget(target, AttackSource.AutoTarget, false, allowMove);
}
public bool HasValidTargetPriority(Actor self, Player owner, BitSet<TargetableType> targetTypes)

View File

@@ -70,7 +70,7 @@ namespace OpenRA.Mods.D2k.Traits
self.QueueActivity(false, new SwallowActor(self, target, a, facing));
}
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor)
public override Activity GetAttackActivity(Actor self, AttackSource source, Target newTarget, bool allowMove, bool forceAttack, Color? targetLineColor)
{
return new SwallowTarget(self, newTarget, allowMove, forceAttack);
}

View File

@@ -89,7 +89,7 @@ namespace OpenRA.Mods.D2k.Traits
if (target.Type == TargetType.Actor)
{
attackTrait.AttackTarget(target, false, true, false);
attackTrait.AttackTarget(target, AttackSource.AutoTarget, false, true, false);
return;
}