some more overloads etc

This commit is contained in:
Chris Forbes
2011-03-13 18:10:23 +13:00
committed by Chris Forbes
parent c313920c7c
commit 981e57bde8

View File

@@ -4,47 +4,57 @@ namespace OpenRA.Mods.RA
{ {
public static class ActorExts public static class ActorExts
{ {
public static bool AppearsFriendlyTo(this Actor self, Actor toActor) public static bool AppearsFriendlyTo(this Actor self, Player toPlayer)
{ {
if (self.HasTrait<Spy>()) if (self.HasTrait<Spy>())
{ {
if (self.Trait<Spy>().Disguised) if (self.Trait<Spy>().Disguised)
{ {
//TODO: check if we can see through disguise //TODO: check if we can see through disguise
if ( toActor.Owner.Stances[self.Trait<Spy>().disguisedAsPlayer] == Stance.Ally) if ( toPlayer.Stances[self.Trait<Spy>().disguisedAsPlayer] == Stance.Ally)
return true; return true;
} }
else else
{ {
if (toActor.Owner.Stances[self.Owner] == Stance.Ally) if (toPlayer.Stances[self.Owner] == Stance.Ally)
return true; return true;
} }
return false; return false;
} }
return toActor.Owner.Stances[self.Owner] == Stance.Ally; return toPlayer.Stances[self.Owner] == Stance.Ally;
}
public static bool AppearsHostileTo(this Actor self, Player toPlayer)
{
if (self.HasTrait<Spy>())
{
if (toPlayer.Stances[self.Owner] == Stance.Ally)
return false;
if (self.Trait<Spy>().Disguised)
{
//TODO: check if we can see through disguise
if (toPlayer.Stances[self.Trait<Spy>().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) public static bool AppearsHostileTo(this Actor self, Actor toActor)
{ {
if (self.HasTrait<Spy>()) return AppearsHostileTo(self, toActor.Owner);
{ }
if (toActor.Owner.Stances[self.Owner] == Stance.Ally)
return false;
if (self.Trait<Spy>().Disguised) public static bool AppearsFriendlyTo(this Actor self, Actor toActor)
{ {
//TODO: check if we can see through disguise return AppearsFriendlyTo(self, toActor.Owner);
if ( toActor.Owner.Stances[self.Trait<Spy>().disguisedAsPlayer] == Stance.Enemy)
return true;
}
else
{
if (toActor.Owner.Stances[self.Owner] == Stance.Enemy)
return true;
}
return false;
}
return toActor.Owner.Stances[self.Owner] == Stance.Enemy;
} }
} }
} }