diff --git a/OpenRA.Mods.RA/ActorExts.cs b/OpenRA.Mods.RA/ActorExts.cs index 925bb8ced5..59d9bf0290 100644 --- a/OpenRA.Mods.RA/ActorExts.cs +++ b/OpenRA.Mods.RA/ActorExts.cs @@ -17,16 +17,18 @@ namespace OpenRA.Mods.RA { static bool IsDisguisedSpy( this Actor a ) { - return a.HasTrait() && a.Trait().Disguised; + var spy = a.TraitOrDefault(); + return spy != null && spy.Disguised; } public static bool AppearsFriendlyTo(this Actor self, Actor toActor) { var stance = toActor.Owner.Stances[ self.Owner ]; + if (stance == Stance.Ally) + return true; if (self.IsDisguisedSpy() && !toActor.HasTrait()) - if ( toActor.Owner.Stances[self.Trait().disguisedAsPlayer] == Stance.Ally) - return true; + return toActor.Owner.Stances[self.Trait().disguisedAsPlayer] == Stance.Ally; return stance == Stance.Ally; } @@ -38,8 +40,7 @@ namespace OpenRA.Mods.RA 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 toActor.Owner.Stances[self.Trait().disguisedAsPlayer] == Stance.Enemy; return stance == Stance.Enemy; }