Merge pull request #7544 from delftswa2014/bugfix/sam_site_friendlyfire

Friendly fire fixes and sam sites
This commit is contained in:
Oliver Brakmann
2015-03-08 16:16:14 +01:00
5 changed files with 15 additions and 8 deletions

View File

@@ -164,6 +164,9 @@ namespace OpenRA.Mods.Common.Traits
public void AttackTarget(Target target, bool queued, bool allowMove) public void AttackTarget(Target target, bool queued, bool allowMove)
{ {
if (self.IsDisabled())
return;
if (!target.IsValidFor(self)) if (!target.IsValidFor(self))
return; return;

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new AttackFollow(init.Self, this); } public override object Create(ActorInitializer init) { return new AttackFollow(init.Self, this); }
} }
public class AttackFollow : AttackBase, ITick, ISync public class AttackFollow : AttackBase, ITick, INotifyOwnerChanged, ISync
{ {
public Target Target { get; protected set; } public Target Target { get; protected set; }
@@ -46,6 +46,11 @@ namespace OpenRA.Mods.Common.Traits
Target = Target.Invalid; Target = Target.Invalid;
} }
public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
{
Target = Target.Invalid;
}
class AttackActivity : Activity class AttackActivity : Activity
{ {
readonly AttackFollow attack; readonly AttackFollow attack;

View File

@@ -35,12 +35,11 @@ namespace OpenRA.Mods.Common.Traits
if (!base.CanAttack(self, target)) if (!base.CanAttack(self, target))
return false; return false;
var canAttack = false;
foreach (var t in turrets) foreach (var t in turrets)
if (t.FaceTarget(self, target)) if (t.FaceTarget(self, target))
canAttack = true; return true;
return canAttack; return false;
} }
} }
} }

View File

@@ -46,13 +46,13 @@ namespace OpenRA.Mods.Common.Traits
} }
} }
public void Reverse(Actor self, Activity activity) public void Reverse(Actor self, Activity activity, bool queued = true)
{ {
renderBuilding.PlayCustomAnimBackwards(self, info.Sequence, () => renderBuilding.PlayCustomAnimBackwards(self, info.Sequence, () =>
{ {
// avoids visual glitches as we wait for the actor to get destroyed // avoids visual glitches as we wait for the actor to get destroyed
renderBuilding.DefaultAnimation.PlayFetchIndex(info.Sequence, () => 0); renderBuilding.DefaultAnimation.PlayFetchIndex(info.Sequence, () => 0);
self.QueueActivity(activity); self.QueueActivity(queued, activity);
}); });
} }
} }

View File

@@ -53,9 +53,9 @@ namespace OpenRA.Mods.Common.Traits
var makeAnimation = self.TraitOrDefault<WithMakeAnimation>(); var makeAnimation = self.TraitOrDefault<WithMakeAnimation>();
if (makeAnimation != null) if (makeAnimation != null)
makeAnimation.Reverse(self, new Sell()); makeAnimation.Reverse(self, new Sell(), false);
else else
self.QueueActivity(new Sell()); self.QueueActivity(false, new Sell());
} }
} }
} }