Reset RequestedTargets that are cancelled before the first attack tick.
This commit is contained in:
@@ -63,8 +63,9 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
var attackBases = autoTarget.ActiveAttackBases;
|
var attackBases = autoTarget.ActiveAttackBases;
|
||||||
foreach (var ab in attackBases)
|
foreach (var ab in attackBases)
|
||||||
{
|
{
|
||||||
QueueChild(self, ab.GetAttackActivity(self, target, true, false));
|
var activity = ab.GetAttackActivity(self, target, true, false);
|
||||||
ab.OnQueueAttackActivity(self, target, false, true, false);
|
QueueChild(self, activity);
|
||||||
|
ab.OnQueueAttackActivity(self, activity, target, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure to continue moving when the attack activities have finished.
|
// Make sure to continue moving when the attack activities have finished.
|
||||||
|
|||||||
@@ -392,11 +392,12 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!queued)
|
if (!queued)
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
|
|
||||||
self.QueueActivity(GetAttackActivity(self, target, allowMove, forceAttack));
|
var activity = GetAttackActivity(self, target, allowMove, forceAttack);
|
||||||
OnQueueAttackActivity(self, target, queued, allowMove, forceAttack);
|
self.QueueActivity(activity);
|
||||||
|
OnQueueAttackActivity(self, activity, target, allowMove, forceAttack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void OnQueueAttackActivity(Actor self, Target target, bool queued, bool allowMove, bool forceAttack) { }
|
public virtual void OnQueueAttackActivity(Actor self, Activity activity, Target target, bool allowMove, bool forceAttack) { }
|
||||||
|
|
||||||
public bool IsReachableTarget(Target target, bool allowMove)
|
public bool IsReachableTarget(Target target, bool allowMove)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
Mobile mobile;
|
Mobile mobile;
|
||||||
AutoTarget autoTarget;
|
AutoTarget autoTarget;
|
||||||
int requestedTargetLastTick;
|
|
||||||
bool requestedForceAttack;
|
bool requestedForceAttack;
|
||||||
|
Activity requestedTargetPresetForActivity;
|
||||||
bool opportunityForceAttack;
|
bool opportunityForceAttack;
|
||||||
bool opportunityTargetIsPersistentTarget;
|
bool opportunityTargetIsPersistentTarget;
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
RequestedTarget = target;
|
RequestedTarget = target;
|
||||||
requestedForceAttack = isForceAttack;
|
requestedForceAttack = isForceAttack;
|
||||||
requestedTargetLastTick = self.World.WorldTick;
|
requestedTargetPresetForActivity = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClearRequestedTarget()
|
public void ClearRequestedTarget()
|
||||||
@@ -59,6 +59,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
|
|
||||||
RequestedTarget = Target.Invalid;
|
RequestedTarget = Target.Invalid;
|
||||||
|
requestedTargetPresetForActivity = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AttackFollow(Actor self, AttackFollowInfo info)
|
public AttackFollow(Actor self, AttackFollowInfo info)
|
||||||
@@ -100,12 +101,19 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
opportunityTargetIsPersistentTarget = false;
|
opportunityTargetIsPersistentTarget = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (requestedTargetLastTick != self.World.WorldTick)
|
if (requestedTargetPresetForActivity != null)
|
||||||
{
|
{
|
||||||
// Activities tick before traits, so if we are here it means the activity didn't run
|
// RequestedTarget was set by OnQueueAttackActivity in preparation for a queued activity
|
||||||
// (either queued next or already cancelled) and we need to recalculate the target ourself
|
// requestedTargetPresetForActivity will be cleared once the activity starts running and calls UpdateRequestedTarget
|
||||||
bool targetIsHiddenActor;
|
if (self.CurrentActivity != null && self.CurrentActivity.NextActivity == requestedTargetPresetForActivity)
|
||||||
RequestedTarget = RequestedTarget.Recalculate(self.Owner, out targetIsHiddenActor);
|
{
|
||||||
|
bool targetIsHiddenActor;
|
||||||
|
RequestedTarget = RequestedTarget.Recalculate(self.Owner, out targetIsHiddenActor);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Requested activity has been canceled
|
||||||
|
else
|
||||||
|
ClearRequestedTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Can't fire on anything
|
// Can't fire on anything
|
||||||
@@ -148,16 +156,15 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return new AttackActivity(self, newTarget, allowMove, forceAttack);
|
return new AttackActivity(self, newTarget, allowMove, forceAttack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnQueueAttackActivity(Actor self, Target target, bool queued, bool allowMove, bool forceAttack)
|
public override void OnQueueAttackActivity(Actor self, Activity activity, Target target, bool allowMove, bool forceAttack)
|
||||||
{
|
{
|
||||||
// If not queued we know that the attack activity will run next
|
|
||||||
// We can improve responsiveness for turreted actors by preempting
|
// We can improve responsiveness for turreted actors by preempting
|
||||||
// the last order (usually a move) and set the target immediately
|
// the last order (usually a move) and setting the target immediately
|
||||||
if (!queued)
|
if (self.CurrentActivity != null && self.CurrentActivity.NextActivity == activity)
|
||||||
{
|
{
|
||||||
RequestedTarget = target;
|
RequestedTarget = target;
|
||||||
requestedForceAttack = forceAttack;
|
requestedForceAttack = forceAttack;
|
||||||
requestedTargetLastTick = self.World.WorldTick;
|
requestedTargetPresetForActivity = activity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user