Replace usage of the Stances dict by a method call

This commit is contained in:
abcdefg30
2020-09-25 17:02:25 +02:00
committed by Paul Chote
parent eda9966d27
commit 10f645bf77
55 changed files with 104 additions and 107 deletions

View File

@@ -36,24 +36,24 @@ namespace OpenRA.Mods.Common
public static bool AppearsFriendlyTo(this Actor self, Actor toActor)
{
var stance = toActor.Owner.Stances[self.Owner];
var stance = toActor.Owner.RelationshipWith(self.Owner);
if (stance == PlayerRelationship.Ally)
return true;
if (self.EffectiveOwner != null && self.EffectiveOwner.Disguised && !toActor.Info.HasTraitInfo<IgnoresDisguiseInfo>())
return toActor.Owner.Stances[self.EffectiveOwner.Owner] == PlayerRelationship.Ally;
return toActor.Owner.RelationshipWith(self.EffectiveOwner.Owner) == PlayerRelationship.Ally;
return false;
}
public static bool AppearsHostileTo(this Actor self, Actor toActor)
{
var stance = toActor.Owner.Stances[self.Owner];
var stance = toActor.Owner.RelationshipWith(self.Owner);
if (stance == PlayerRelationship.Ally)
return false; /* otherwise, we'll hate friendly disguised spies */
return false;
if (self.EffectiveOwner != null && self.EffectiveOwner.Disguised && !toActor.Info.HasTraitInfo<IgnoresDisguiseInfo>())
return toActor.Owner.Stances[self.EffectiveOwner.Owner] == PlayerRelationship.Enemy;
return toActor.Owner.RelationshipWith(self.EffectiveOwner.Owner) == PlayerRelationship.Enemy;
return stance == PlayerRelationship.Enemy;
}
@@ -61,10 +61,8 @@ namespace OpenRA.Mods.Common
public static void NotifyBlocker(this Actor self, IEnumerable<Actor> blockers)
{
foreach (var blocker in blockers)
{
foreach (var moveBlocked in blocker.TraitsImplementing<INotifyBlockingMove>())
moveBlocked.OnNotifyBlockingMove(blocker, self);
}
}
public static void NotifyBlocker(this Actor self, CPos position)