add IgnoresDisguise; support it in AppearsHostileTo / AppearsFriendlyTo
This commit is contained in:
@@ -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 System;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
public static class ActorExts
|
public static class ActorExts
|
||||||
{
|
{
|
||||||
public static bool AppearsFriendlyTo(this Actor self, Player toPlayer)
|
static bool IsDisguisedSpy( this Actor a )
|
||||||
{
|
{
|
||||||
if (self.HasTrait<Spy>())
|
return a.HasTrait<Spy>() && a.Trait<Spy>().Disguised;
|
||||||
{
|
|
||||||
if (self.Trait<Spy>().Disguised)
|
|
||||||
{
|
|
||||||
//TODO: check if we can see through disguise
|
|
||||||
if ( toPlayer.Stances[self.Trait<Spy>().disguisedAsPlayer] == Stance.Ally)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (toPlayer.Stances[self.Owner] == Stance.Ally)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return toPlayer.Stances[self.Owner] == Stance.Ally;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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<IgnoresDisguise>())
|
||||||
|
if ( toActor.Owner.Stances[self.Trait<Spy>().disguisedAsPlayer] == Stance.Ally)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return stance == Stance.Ally;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool AppearsHostileTo(this Actor self, Actor toActor)
|
||||||
{
|
{
|
||||||
if (self.HasTrait<Spy>())
|
var stance = toActor.Owner.Stances[ self.Owner ];
|
||||||
{
|
if (stance == Stance.Ally)
|
||||||
if (toPlayer.Stances[self.Owner] == Stance.Ally)
|
return false; /* otherwise, we'll hate friendly disguised spies */
|
||||||
return false;
|
|
||||||
|
if (self.IsDisguisedSpy() && !toActor.HasTrait<IgnoresDisguise>())
|
||||||
if (self.Trait<Spy>().Disguised)
|
if (toActor.Owner.Stances[self.Trait<Spy>().disguisedAsPlayer] == Stance.Enemy)
|
||||||
{
|
return true;
|
||||||
//TODO: check if we can see through disguise
|
|
||||||
if (toPlayer.Stances[self.Trait<Spy>().disguisedAsPlayer] == Stance.Enemy)
|
return stance == 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -134,4 +134,7 @@ namespace OpenRA.Mods.RA
|
|||||||
return order.OrderString == "Disguise" ? "Attack" : null;
|
return order.OrderString == "Disguise" ? "Attack" : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class IgnoresDisguiseInfo : TraitInfo<IgnoresDisguise> {}
|
||||||
|
class IgnoresDisguise {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ DOG:
|
|||||||
CanAttackGround: no
|
CanAttackGround: no
|
||||||
RenderInfantry:
|
RenderInfantry:
|
||||||
IdleAnimations: idle1,idle2
|
IdleAnimations: idle1,idle2
|
||||||
|
IgnoresDisguise:
|
||||||
|
|
||||||
E1:
|
E1:
|
||||||
Inherits: ^Infantry
|
Inherits: ^Infantry
|
||||||
|
|||||||
Reference in New Issue
Block a user