diff --git a/OpenRA.Mods.RA/ActorExts.cs b/OpenRA.Mods.RA/ActorExts.cs index 84b4149c77..925bb8ced5 100644 --- a/OpenRA.Mods.RA/ActorExts.cs +++ b/OpenRA.Mods.RA/ActorExts.cs @@ -1,61 +1,48 @@ +#region Copyright & License Information +/* + * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation. For more information, + * see COPYING. + */ +#endregion + using System; using OpenRA.Traits; + namespace OpenRA.Mods.RA { public static class ActorExts { - public static bool AppearsFriendlyTo(this Actor self, Player toPlayer) - { - if (self.HasTrait()) - { - if (self.Trait().Disguised) - { - //TODO: check if we can see through disguise - if ( toPlayer.Stances[self.Trait().disguisedAsPlayer] == Stance.Ally) - return true; - } - else - { - if (toPlayer.Stances[self.Owner] == Stance.Ally) - return true; - } - return false; - } - return toPlayer.Stances[self.Owner] == Stance.Ally; + static bool IsDisguisedSpy( this Actor a ) + { + return a.HasTrait() && a.Trait().Disguised; } - public static bool AppearsHostileTo(this Actor self, Player toPlayer) + public static bool AppearsFriendlyTo(this Actor self, Actor toActor) + { + var stance = toActor.Owner.Stances[ self.Owner ]; + + if (self.IsDisguisedSpy() && !toActor.HasTrait()) + if ( toActor.Owner.Stances[self.Trait().disguisedAsPlayer] == Stance.Ally) + return true; + + return stance == Stance.Ally; + } + + public static bool AppearsHostileTo(this Actor self, Actor toActor) { - if (self.HasTrait()) - { - if (toPlayer.Stances[self.Owner] == Stance.Ally) - return false; - - if (self.Trait().Disguised) - { - //TODO: check if we can see through disguise - if (toPlayer.Stances[self.Trait().disguisedAsPlayer] == Stance.Enemy) - return true; - } - else - { - if (toPlayer.Stances[self.Owner] == Stance.Enemy) - return true; - } - return false; - } - return toPlayer.Stances[self.Owner] == Stance.Enemy; - } - - public static bool AppearsHostileTo(this Actor self, Actor toActor) - { - return AppearsHostileTo(self, toActor.Owner); - } - - public static bool AppearsFriendlyTo(this Actor self, Actor toActor) - { - return AppearsFriendlyTo(self, toActor.Owner); - } + var stance = toActor.Owner.Stances[ self.Owner ]; + if (stance == Stance.Ally) + return false; /* otherwise, we'll hate friendly disguised spies */ + + if (self.IsDisguisedSpy() && !toActor.HasTrait()) + if (toActor.Owner.Stances[self.Trait().disguisedAsPlayer] == Stance.Enemy) + return true; + + return stance == Stance.Enemy; + } } } diff --git a/OpenRA.Mods.RA/Spy.cs b/OpenRA.Mods.RA/Spy.cs index 8efd3c59ca..53d3b6c85d 100644 --- a/OpenRA.Mods.RA/Spy.cs +++ b/OpenRA.Mods.RA/Spy.cs @@ -134,4 +134,7 @@ namespace OpenRA.Mods.RA return order.OrderString == "Disguise" ? "Attack" : null; } } + + class IgnoresDisguiseInfo : TraitInfo {} + class IgnoresDisguise {} } diff --git a/mods/ra/rules/infantry.yaml b/mods/ra/rules/infantry.yaml index 6fb5d5f051..130d64c988 100644 --- a/mods/ra/rules/infantry.yaml +++ b/mods/ra/rules/infantry.yaml @@ -25,6 +25,7 @@ DOG: CanAttackGround: no RenderInfantry: IdleAnimations: idle1,idle2 + IgnoresDisguise: E1: Inherits: ^Infantry