fix AppearsFriendlyTo/AppearsHostileTo

This commit is contained in:
Chris Forbes
2011-08-21 19:31:20 +12:00
parent da4811abe8
commit ee2be405ca

View File

@@ -17,16 +17,18 @@ namespace OpenRA.Mods.RA
{ {
static bool IsDisguisedSpy( this Actor a ) static bool IsDisguisedSpy( this Actor a )
{ {
return a.HasTrait<Spy>() && a.Trait<Spy>().Disguised; var spy = a.TraitOrDefault<Spy>();
return spy != null && spy.Disguised;
} }
public static bool AppearsFriendlyTo(this Actor self, Actor toActor) public static bool AppearsFriendlyTo(this Actor self, Actor toActor)
{ {
var stance = toActor.Owner.Stances[ self.Owner ]; var stance = toActor.Owner.Stances[ self.Owner ];
if (stance == Stance.Ally)
return true;
if (self.IsDisguisedSpy() && !toActor.HasTrait<IgnoresDisguise>()) if (self.IsDisguisedSpy() && !toActor.HasTrait<IgnoresDisguise>())
if ( toActor.Owner.Stances[self.Trait<Spy>().disguisedAsPlayer] == Stance.Ally) return toActor.Owner.Stances[self.Trait<Spy>().disguisedAsPlayer] == Stance.Ally;
return true;
return stance == Stance.Ally; return stance == Stance.Ally;
} }
@@ -38,8 +40,7 @@ namespace OpenRA.Mods.RA
return false; /* otherwise, we'll hate friendly disguised spies */ return false; /* otherwise, we'll hate friendly disguised spies */
if (self.IsDisguisedSpy() && !toActor.HasTrait<IgnoresDisguise>()) if (self.IsDisguisedSpy() && !toActor.HasTrait<IgnoresDisguise>())
if (toActor.Owner.Stances[self.Trait<Spy>().disguisedAsPlayer] == Stance.Enemy) return toActor.Owner.Stances[self.Trait<Spy>().disguisedAsPlayer] == Stance.Enemy;
return true;
return stance == Stance.Enemy; return stance == Stance.Enemy;
} }