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

@@ -48,10 +48,9 @@ namespace OpenRA.Mods.Common.Traits
// TODO: FrozenActors don't yet have a way of caching conditions, so we can't filter disabled traits
// This therefore assumes that all Capturable traits are enabled, which is probably wrong.
// Actors with FrozenUnderFog should therefore not disable the Capturable trait.
var stance = frozenActor.Owner.Stances[captor.Owner];
var stance = captor.Owner.RelationshipWith(frozenActor.Owner);
return frozenActor.Info.TraitInfos<CapturableInfo>()
.Any(c => c.ValidStances.HasStance(stance) &&
captures.Info.CaptureTypes.Overlaps(c.Types));
.Any(c => c.ValidStances.HasStance(stance) && captures.Info.CaptureTypes.Overlaps(c.Types));
}
}
@@ -129,7 +128,7 @@ namespace OpenRA.Mods.Common.Traits
public bool CanBeTargetedBy(Actor self, Actor captor, CaptureManager captorManager)
{
var stance = self.Owner.Stances[captor.Owner];
var stance = captor.Owner.RelationshipWith(self.Owner);
if (stance.HasStance(PlayerRelationship.Enemy))
return captorManager.capturesTypes.Overlaps(enemyCapturableTypes);
@@ -147,7 +146,7 @@ namespace OpenRA.Mods.Common.Traits
if (captures.IsTraitDisabled)
return false;
var stance = self.Owner.Stances[captor.Owner];
var stance = captor.Owner.RelationshipWith(self.Owner);
if (stance.HasStance(PlayerRelationship.Enemy))
return captures.Info.CaptureTypes.Overlaps(enemyCapturableTypes);