RA - AppearsFriendlyTo and AppearsHostileTo actor extensions

This commit is contained in:
alzeih
2011-03-13 15:37:24 +13:00
parent cf8cfdc42d
commit f4e4f987be
6 changed files with 56 additions and 4 deletions

View File

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