Actors will lose targets and AI won't follow indefinitely

This commit is contained in:
pevers
2015-04-09 16:00:47 +02:00
committed by Oliver Brakmann
parent 1cbde65a08
commit 6ed0273656
8 changed files with 93 additions and 14 deletions

View File

@@ -10,6 +10,7 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.Activities;
using OpenRA.Mods.Common.Pathfinder;
@@ -27,7 +28,23 @@ namespace OpenRA.Mods.Common.Activities
readonly DomainIndex domainIndex;
readonly uint movementClass;
protected Target Target { get; private set; }
Target target;
bool canHideUnderFog;
protected Target Target
{
get
{
return target;
}
private set
{
target = value;
if (target.Type == TargetType.Actor)
canHideUnderFog = target.Actor.HasTrait<HiddenUnderFog>();
}
}
protected CPos targetPosition;
Activity inner;
bool repath;
@@ -66,6 +83,17 @@ namespace OpenRA.Mods.Common.Activities
{
var targetIsValid = Target.IsValidFor(self);
// Target moved under the fog. Move to its last known position.
if (Target.Type == TargetType.Actor && canHideUnderFog
&& !self.Owner.CanTargetActor(Target.Actor))
{
if (inner != null)
inner.Cancel(self);
self.SetTargetLine(Target.FromCell(self.World, targetPosition), Color.Green);
return Util.RunActivity(self, new AttackMoveActivity(self, mobile.MoveTo(targetPosition, 0)));
}
// Inner move order has completed.
if (inner == null)
{