Rename remaining Stance references to PlayerRelationship.

This commit is contained in:
Paul Chote
2021-02-04 20:07:05 +00:00
committed by reaperrr
parent b3821e71dc
commit fb0031d34a
40 changed files with 88 additions and 88 deletions

View File

@@ -265,7 +265,7 @@ namespace OpenRA
return RelationshipWith(p) == PlayerRelationship.Ally; return RelationshipWith(p) == PlayerRelationship.Ally;
} }
public Color PlayerStanceColor(Actor a) public Color PlayerRelationshipColor(Actor a)
{ {
var player = a.World.RenderPlayer ?? a.World.LocalPlayer; var player = a.World.RenderPlayer ?? a.World.LocalPlayer;
if (player != null && !player.Spectating) if (player != null && !player.Spectating)

View File

@@ -76,12 +76,12 @@ namespace OpenRA.Traits
Ally = 4, Ally = 4,
} }
public static class StanceExts public static class PlayerRelationshipExts
{ {
public static bool HasStance(this PlayerRelationship s, PlayerRelationship stance) public static bool HasRelationship(this PlayerRelationship r, PlayerRelationship relationship)
{ {
// PERF: Enum.HasFlag is slower and requires allocations. // PERF: Enum.HasFlag is slower and requires allocations.
return (s & stance) == stance; return (r & relationship) == relationship;
} }
} }

View File

@@ -167,7 +167,7 @@ namespace OpenRA.Mods.Cnc.Traits
if (!Disguised || self.Owner.IsAlliedWith(self.World.RenderPlayer)) if (!Disguised || self.Owner.IsAlliedWith(self.World.RenderPlayer))
return color; return color;
return color = Game.Settings.Game.UsePlayerStanceColors ? AsPlayer.PlayerStanceColor(self) : AsPlayer.Color; return color = Game.Settings.Game.UsePlayerStanceColors ? AsPlayer.PlayerRelationshipColor(self) : AsPlayer.Color;
} }
public void DisguiseAs(Actor target) public void DisguiseAs(Actor target)
@@ -298,8 +298,8 @@ namespace OpenRA.Mods.Cnc.Traits
public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor) public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
{ {
var stance = self.Owner.RelationshipWith(target.Owner); var relationship = self.Owner.RelationshipWith(target.Owner);
if (!info.ValidRelationships.HasStance(stance)) if (!info.ValidRelationships.HasRelationship(relationship))
return false; return false;
return info.TargetTypes.Overlaps(target.GetAllTargetTypes()); return info.TargetTypes.Overlaps(target.GetAllTargetTypes());
@@ -307,8 +307,8 @@ namespace OpenRA.Mods.Cnc.Traits
public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor) public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
{ {
var stance = self.Owner.RelationshipWith(target.Owner); var relationship = self.Owner.RelationshipWith(target.Owner);
if (!info.ValidRelationships.HasStance(stance)) if (!info.ValidRelationships.HasRelationship(relationship))
return false; return false;
return info.TargetTypes.Overlaps(target.Info.GetAllTargetTypes()); return info.TargetTypes.Overlaps(target.Info.GetAllTargetTypes());

View File

@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Cnc.Traits
protected override bool ShouldRender(Actor self) protected override bool ShouldRender(Actor self)
{ {
return infiltrators.Any(i => Info.ValidRelationships.HasStance(i.RelationshipWith(self.World.RenderPlayer))); return infiltrators.Any(i => Info.ValidRelationships.HasRelationship(i.RelationshipWith(self.World.RenderPlayer)));
} }
} }
} }

View File

@@ -101,10 +101,10 @@ namespace OpenRA.Mods.Cnc.Traits
{ {
case TargetType.Actor: case TargetType.Actor:
return Info.Types.Overlaps(target.Actor.GetEnabledTargetTypes()) && return Info.Types.Overlaps(target.Actor.GetEnabledTargetTypes()) &&
Info.ValidRelationships.HasStance(self.Owner.RelationshipWith(target.Actor.Owner)); Info.ValidRelationships.HasRelationship(self.Owner.RelationshipWith(target.Actor.Owner));
case TargetType.FrozenActor: case TargetType.FrozenActor:
return target.FrozenActor.IsValid && Info.Types.Overlaps(target.FrozenActor.TargetTypes) && return target.FrozenActor.IsValid && Info.Types.Overlaps(target.FrozenActor.TargetTypes) &&
Info.ValidRelationships.HasStance(self.Owner.RelationshipWith(target.FrozenActor.Owner)); Info.ValidRelationships.HasRelationship(self.Owner.RelationshipWith(target.FrozenActor.Owner));
default: default:
return false; return false;
} }
@@ -136,7 +136,7 @@ namespace OpenRA.Mods.Cnc.Traits
public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor) public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
{ {
var stance = self.Owner.RelationshipWith(target.Owner); var stance = self.Owner.RelationshipWith(target.Owner);
if (!info.ValidRelationships.HasStance(stance)) if (!info.ValidRelationships.HasRelationship(stance))
return false; return false;
return info.Types.Overlaps(target.GetAllTargetTypes()); return info.Types.Overlaps(target.GetAllTargetTypes());
@@ -145,7 +145,7 @@ namespace OpenRA.Mods.Cnc.Traits
public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor) public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
{ {
var stance = self.Owner.RelationshipWith(target.Owner); var stance = self.Owner.RelationshipWith(target.Owner);
if (!info.ValidRelationships.HasStance(stance)) if (!info.ValidRelationships.HasRelationship(stance))
return false; return false;
return info.Types.Overlaps(target.Info.GetAllTargetTypes()); return info.Types.Overlaps(target.Info.GetAllTargetTypes());

View File

@@ -124,7 +124,7 @@ namespace OpenRA.Mods.Common.Activities
foreach (var t in enterActor.TraitsImplementing<INotifyCapture>()) foreach (var t in enterActor.TraitsImplementing<INotifyCapture>())
t.OnCapture(enterActor, self, oldOwner, self.Owner, captures.Info.CaptureTypes); t.OnCapture(enterActor, self, oldOwner, self.Owner, captures.Info.CaptureTypes);
if (self.Owner.RelationshipWith(oldOwner).HasStance(captures.Info.PlayerExperienceRelationships)) if (self.Owner.RelationshipWith(oldOwner).HasRelationship(captures.Info.PlayerExperienceRelationships))
self.Owner.PlayerActor.TraitOrDefault<PlayerExperience>()?.GiveExperience(captures.Info.PlayerExperience); self.Owner.PlayerActor.TraitOrDefault<PlayerExperience>()?.GiveExperience(captures.Info.PlayerExperience);
if (captures.Info.ConsumedByCapture) if (captures.Info.ConsumedByCapture)

View File

@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Activities
// Make sure we can still repair the target before entering // Make sure we can still repair the target before entering
// (but not before, because this may stop the actor in the middle of nowhere) // (but not before, because this may stop the actor in the middle of nowhere)
var stance = self.Owner.RelationshipWith(enterActor.Owner); var stance = self.Owner.RelationshipWith(enterActor.Owner);
if (enterHealth == null || enterHealth.DamageState == DamageState.Undamaged || enterEngineerRepariable == null || enterEngineerRepariable.IsTraitDisabled || !info.ValidRelationships.HasStance(stance)) if (enterHealth == null || enterHealth.DamageState == DamageState.Undamaged || enterEngineerRepariable == null || enterEngineerRepariable.IsTraitDisabled || !info.ValidRelationships.HasRelationship(stance))
{ {
Cancel(self, true); Cancel(self, true);
return false; return false;
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Activities
return; return;
var stance = self.Owner.RelationshipWith(enterActor.Owner); var stance = self.Owner.RelationshipWith(enterActor.Owner);
if (!info.ValidRelationships.HasStance(stance)) if (!info.ValidRelationships.HasRelationship(stance))
return; return;
if (enterHealth.DamageState == DamageState.Undamaged) if (enterHealth.DamageState == DamageState.Undamaged)

View File

@@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Effects
void AddCellsToPlayerShroud(Player p, PPos[] uv) void AddCellsToPlayerShroud(Player p, PPos[] uv)
{ {
if (validStances.HasStance(player.RelationshipWith(p))) if (validStances.HasRelationship(player.RelationshipWith(p)))
p.Shroud.AddSource(this, sourceType, uv); p.Shroud.AddSource(this, sourceType, uv);
} }

View File

@@ -131,7 +131,7 @@ namespace OpenRA.Mods.Common.Graphics
Color GetHealthColor(IHealth health) Color GetHealthColor(IHealth health)
{ {
if (Game.Settings.Game.UsePlayerStanceColors) if (Game.Settings.Game.UsePlayerStanceColors)
return actor.Owner.PlayerStanceColor(actor); return actor.Owner.PlayerRelationshipColor(actor);
return health.DamageState == DamageState.Critical ? Color.Red : return health.DamageState == DamageState.Critical ? Color.Red :
health.DamageState == DamageState.Heavy ? Color.Yellow : Color.LimeGreen; health.DamageState == DamageState.Heavy ? Color.Yellow : Color.LimeGreen;

View File

@@ -87,7 +87,7 @@ namespace OpenRA.Mods.Common.Graphics
Color GetHealthColor(IHealth health) Color GetHealthColor(IHealth health)
{ {
if (Game.Settings.Game.UsePlayerStanceColors) if (Game.Settings.Game.UsePlayerStanceColors)
return actor.Owner.PlayerStanceColor(actor); return actor.Owner.PlayerRelationshipColor(actor);
return health.DamageState == DamageState.Critical ? Color.Red : return health.DamageState == DamageState.Critical ? Color.Red :
health.DamageState == DamageState.Heavy ? Color.Yellow : Color.LimeGreen; health.DamageState == DamageState.Heavy ? Color.Yellow : Color.LimeGreen;

View File

@@ -319,7 +319,7 @@ namespace OpenRA.Mods.Common.Projectiles
if (checkTargetType && !Target.FromActor(victim).IsValidFor(firedBy)) if (checkTargetType && !Target.FromActor(victim).IsValidFor(firedBy))
continue; continue;
if (!info.ValidBounceBlockerRelationships.HasStance(firedBy.Owner.RelationshipWith(victim.Owner))) if (!info.ValidBounceBlockerRelationships.HasRelationship(firedBy.Owner.RelationshipWith(victim.Owner)))
continue; continue;
// If the impact position is within any actor's HitShape, we have a direct hit // If the impact position is within any actor's HitShape, we have a direct hit

View File

@@ -429,7 +429,7 @@ namespace OpenRA.Mods.Common.Projectiles
if ((tp.Actor.CenterPosition - pos).HorizontalLengthSquared > tp.Trait.Range.LengthSquared) if ((tp.Actor.CenterPosition - pos).HorizontalLengthSquared > tp.Trait.Range.LengthSquared)
return false; return false;
if (!tp.Trait.DeflectionStances.HasStance(tp.Actor.Owner.RelationshipWith(args.SourceActor.Owner))) if (!tp.Trait.DeflectionStances.HasRelationship(tp.Actor.Owner.RelationshipWith(args.SourceActor.Owner)))
return false; return false;
return tp.Actor.World.SharedRandom.Next(100) < tp.Trait.Chance; return tp.Actor.World.SharedRandom.Next(100) < tp.Trait.Chance;

View File

@@ -377,7 +377,7 @@ namespace OpenRA.Mods.Common.Traits
return Armaments.Where(a => return Armaments.Where(a =>
!a.IsTraitDisabled !a.IsTraitDisabled
&& (owner == null || (forceAttack ? a.Info.ForceTargetRelationships : a.Info.TargetRelationships).HasStance(self.Owner.RelationshipWith(owner))) && (owner == null || (forceAttack ? a.Info.ForceTargetRelationships : a.Info.TargetRelationships).HasRelationship(self.Owner.RelationshipWith(owner)))
&& a.Weapon.IsValidAgainst(t, self.World, self)); && a.Weapon.IsValidAgainst(t, self.World, self));
} }

View File

@@ -325,8 +325,8 @@ namespace OpenRA.Mods.Common.Traits
return activeTargetPriorities.Any(ati => return activeTargetPriorities.Any(ati =>
{ {
// Incompatible stances // Incompatible relationship
if (!ati.ValidRelationships.HasStance(self.Owner.RelationshipWith(owner))) if (!ati.ValidRelationships.HasRelationship(self.Owner.RelationshipWith(owner)))
return false; return false;
// Incompatible target types // Incompatible target types
@@ -393,8 +393,8 @@ namespace OpenRA.Mods.Common.Traits
if (ati.Priority < chosenTargetPriority) if (ati.Priority < chosenTargetPriority)
return false; return false;
// Incompatible stances // Incompatible relationship
if (!ati.ValidRelationships.HasStance(self.Owner.RelationshipWith(owner))) if (!ati.ValidRelationships.HasRelationship(self.Owner.RelationshipWith(owner)))
return false; return false;
// Incompatible target types // Incompatible target types

View File

@@ -133,7 +133,7 @@ namespace OpenRA.Mods.Common.Traits
return; return;
var randPlayer = world.Players.Where(p => !p.Spectating var randPlayer = world.Players.Where(p => !p.Spectating
&& Info.CapturableRelationships.HasStance(player.RelationshipWith(p))).Random(world.LocalRandom); && Info.CapturableRelationships.HasRelationship(player.RelationshipWith(p))).Random(world.LocalRandom);
var targetOptions = Info.CheckCaptureTargetsForVisibility var targetOptions = Info.CheckCaptureTargetsForVisibility
? GetVisibleActorsBelongingToPlayer(randPlayer) ? GetVisibleActorsBelongingToPlayer(randPlayer)

View File

@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Traits
// Actors with FrozenUnderFog should therefore not disable the Capturable trait. // Actors with FrozenUnderFog should therefore not disable the Capturable trait.
var stance = captor.Owner.RelationshipWith(frozenActor.Owner); var stance = captor.Owner.RelationshipWith(frozenActor.Owner);
return frozenActor.Info.TraitInfos<CapturableInfo>() return frozenActor.Info.TraitInfos<CapturableInfo>()
.Any(c => c.ValidRelationships.HasStance(stance) && captures.Info.CaptureTypes.Overlaps(c.Types)); .Any(c => c.ValidRelationships.HasRelationship(stance) && captures.Info.CaptureTypes.Overlaps(c.Types));
} }
} }
@@ -108,13 +108,13 @@ namespace OpenRA.Mods.Common.Traits
allyCapturableTypes = neutralCapturableTypes = enemyCapturableTypes = default(BitSet<CaptureType>); allyCapturableTypes = neutralCapturableTypes = enemyCapturableTypes = default(BitSet<CaptureType>);
foreach (var c in enabledCapturable) foreach (var c in enabledCapturable)
{ {
if (c.Info.ValidRelationships.HasStance(PlayerRelationship.Ally)) if (c.Info.ValidRelationships.HasRelationship(PlayerRelationship.Ally))
allyCapturableTypes = allyCapturableTypes.Union(c.Info.Types); allyCapturableTypes = allyCapturableTypes.Union(c.Info.Types);
if (c.Info.ValidRelationships.HasStance(PlayerRelationship.Neutral)) if (c.Info.ValidRelationships.HasRelationship(PlayerRelationship.Neutral))
neutralCapturableTypes = neutralCapturableTypes.Union(c.Info.Types); neutralCapturableTypes = neutralCapturableTypes.Union(c.Info.Types);
if (c.Info.ValidRelationships.HasStance(PlayerRelationship.Enemy)) if (c.Info.ValidRelationships.HasRelationship(PlayerRelationship.Enemy))
enemyCapturableTypes = enemyCapturableTypes.Union(c.Info.Types); enemyCapturableTypes = enemyCapturableTypes.Union(c.Info.Types);
} }
} }
@@ -128,14 +128,14 @@ namespace OpenRA.Mods.Common.Traits
public bool CanBeTargetedBy(Actor self, Actor captor, CaptureManager captorManager) public bool CanBeTargetedBy(Actor self, Actor captor, CaptureManager captorManager)
{ {
var stance = captor.Owner.RelationshipWith(self.Owner); var relationship = captor.Owner.RelationshipWith(self.Owner);
if (stance.HasStance(PlayerRelationship.Enemy)) if (relationship.HasRelationship(PlayerRelationship.Enemy))
return captorManager.capturesTypes.Overlaps(enemyCapturableTypes); return captorManager.capturesTypes.Overlaps(enemyCapturableTypes);
if (stance.HasStance(PlayerRelationship.Neutral)) if (relationship.HasRelationship(PlayerRelationship.Neutral))
return captorManager.capturesTypes.Overlaps(neutralCapturableTypes); return captorManager.capturesTypes.Overlaps(neutralCapturableTypes);
if (stance.HasStance(PlayerRelationship.Ally)) if (relationship.HasRelationship(PlayerRelationship.Ally))
return captorManager.capturesTypes.Overlaps(allyCapturableTypes); return captorManager.capturesTypes.Overlaps(allyCapturableTypes);
return false; return false;
@@ -146,14 +146,14 @@ namespace OpenRA.Mods.Common.Traits
if (captures.IsTraitDisabled) if (captures.IsTraitDisabled)
return false; return false;
var stance = captor.Owner.RelationshipWith(self.Owner); var relationship = captor.Owner.RelationshipWith(self.Owner);
if (stance.HasStance(PlayerRelationship.Enemy)) if (relationship.HasRelationship(PlayerRelationship.Enemy))
return captures.Info.CaptureTypes.Overlaps(enemyCapturableTypes); return captures.Info.CaptureTypes.Overlaps(enemyCapturableTypes);
if (stance.HasStance(PlayerRelationship.Neutral)) if (relationship.HasRelationship(PlayerRelationship.Neutral))
return captures.Info.CaptureTypes.Overlaps(neutralCapturableTypes); return captures.Info.CaptureTypes.Overlaps(neutralCapturableTypes);
if (stance.HasStance(PlayerRelationship.Ally)) if (relationship.HasRelationship(PlayerRelationship.Ally))
return captures.Info.CaptureTypes.Overlaps(allyCapturableTypes); return captures.Info.CaptureTypes.Overlaps(allyCapturableTypes);
return false; return false;

View File

@@ -110,8 +110,8 @@ namespace OpenRA.Mods.Common.Traits
if (tokens.ContainsKey(a)) if (tokens.ContainsKey(a))
return; return;
var stance = self.Owner.RelationshipWith(a.Owner); var relationship = self.Owner.RelationshipWith(a.Owner);
if (!Info.ValidRelationships.HasStance(stance)) if (!Info.ValidRelationships.HasRelationship(relationship))
return; return;
var external = a.TraitsImplementing<ExternalCondition>() var external = a.TraitsImplementing<ExternalCondition>()
@@ -135,7 +135,7 @@ namespace OpenRA.Mods.Common.Traits
if ((produced.CenterPosition - self.CenterPosition).HorizontalLengthSquared <= Info.Range.LengthSquared) if ((produced.CenterPosition - self.CenterPosition).HorizontalLengthSquared <= Info.Range.LengthSquared)
{ {
var stance = self.Owner.RelationshipWith(produced.Owner); var stance = self.Owner.RelationshipWith(produced.Owner);
if (!Info.ValidRelationships.HasStance(stance)) if (!Info.ValidRelationships.HasRelationship(stance))
return; return;
var external = produced.TraitsImplementing<ExternalCondition>() var external = produced.TraitsImplementing<ExternalCondition>()

View File

@@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Traits
protected override void AddCellsToPlayerShroud(Actor self, Player p, PPos[] uv) protected override void AddCellsToPlayerShroud(Actor self, Player p, PPos[] uv)
{ {
if (!info.ValidRelationships.HasStance(self.Owner.RelationshipWith(p))) if (!info.ValidRelationships.HasRelationship(self.Owner.RelationshipWith(p)))
return; return;
p.Shroud.AddSource(this, Shroud.SourceType.Shroud, uv); p.Shroud.AddSource(this, Shroud.SourceType.Shroud, uv);

View File

@@ -99,7 +99,7 @@ namespace OpenRA.Mods.Common.Traits
public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor) public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
{ {
var targetInfo = target.Info.TraitInfoOrDefault<AcceptsDeliveredCashInfo>(); var targetInfo = target.Info.TraitInfoOrDefault<AcceptsDeliveredCashInfo>();
if (targetInfo == null || !targetInfo.ValidRelationships.HasStance(target.Owner.RelationshipWith(self.Owner))) if (targetInfo == null || !targetInfo.ValidRelationships.HasRelationship(target.Owner.RelationshipWith(self.Owner)))
return false; return false;
if (targetInfo.ValidTypes.Count == 0) if (targetInfo.ValidTypes.Count == 0)
@@ -112,7 +112,7 @@ namespace OpenRA.Mods.Common.Traits
public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor) public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
{ {
var targetInfo = target.Info.TraitInfoOrDefault<AcceptsDeliveredCashInfo>(); var targetInfo = target.Info.TraitInfoOrDefault<AcceptsDeliveredCashInfo>();
if (targetInfo == null || !targetInfo.ValidRelationships.HasStance(target.Owner.RelationshipWith(self.Owner))) if (targetInfo == null || !targetInfo.ValidRelationships.HasRelationship(target.Owner.RelationshipWith(self.Owner)))
return false; return false;
if (targetInfo.ValidTypes.Count == 0) if (targetInfo.ValidTypes.Count == 0)

View File

@@ -109,7 +109,7 @@ namespace OpenRA.Mods.Common.Traits
return false; return false;
var targetInfo = target.Info.TraitInfoOrDefault<AcceptsDeliveredExperienceInfo>(); var targetInfo = target.Info.TraitInfoOrDefault<AcceptsDeliveredExperienceInfo>();
if (targetInfo == null || !targetInfo.ValidRelationships.HasStance(target.Owner.RelationshipWith(self.Owner))) if (targetInfo == null || !targetInfo.ValidRelationships.HasRelationship(target.Owner.RelationshipWith(self.Owner)))
return false; return false;
if (targetInfo.ValidTypes.Count == 0) if (targetInfo.ValidTypes.Count == 0)
@@ -129,7 +129,7 @@ namespace OpenRA.Mods.Common.Traits
return false; return false;
var targetInfo = target.Info.TraitInfoOrDefault<AcceptsDeliveredExperienceInfo>(); var targetInfo = target.Info.TraitInfoOrDefault<AcceptsDeliveredExperienceInfo>();
if (targetInfo == null || !targetInfo.ValidRelationships.HasStance(target.Owner.RelationshipWith(self.Owner))) if (targetInfo == null || !targetInfo.ValidRelationships.HasRelationship(target.Owner.RelationshipWith(self.Owner)))
return false; return false;
if (targetInfo.ValidTypes.Count == 0) if (targetInfo.ValidTypes.Count == 0)

View File

@@ -117,11 +117,11 @@ namespace OpenRA.Mods.Common.Traits
if (modifiers.HasModifier(TargetModifiers.ForceMove)) if (modifiers.HasModifier(TargetModifiers.ForceMove))
return false; return false;
var stance = target.Owner.RelationshipWith(self.Owner); var relationship = target.Owner.RelationshipWith(self.Owner);
if (!info.TargetRelationships.HasStance(stance) && !modifiers.HasModifier(TargetModifiers.ForceAttack)) if (!info.TargetRelationships.HasRelationship(relationship) && !modifiers.HasModifier(TargetModifiers.ForceAttack))
return false; return false;
if (!info.ForceTargetRelationships.HasStance(stance) && modifiers.HasModifier(TargetModifiers.ForceAttack)) if (!info.ForceTargetRelationships.HasRelationship(relationship) && modifiers.HasModifier(TargetModifiers.ForceAttack))
return false; return false;
return target.TraitsImplementing<IDemolishable>().Any(i => i.IsValidTarget(target, self)); return target.TraitsImplementing<IDemolishable>().Any(i => i.IsValidTarget(target, self));
@@ -129,11 +129,11 @@ namespace OpenRA.Mods.Common.Traits
public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor) public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
{ {
var stance = target.Owner.RelationshipWith(self.Owner); var relationship = target.Owner.RelationshipWith(self.Owner);
if (!info.TargetRelationships.HasStance(stance) && !modifiers.HasModifier(TargetModifiers.ForceAttack)) if (!info.TargetRelationships.HasRelationship(relationship) && !modifiers.HasModifier(TargetModifiers.ForceAttack))
return false; return false;
if (!info.ForceTargetRelationships.HasStance(stance) && modifiers.HasModifier(TargetModifiers.ForceAttack)) if (!info.ForceTargetRelationships.HasRelationship(relationship) && modifiers.HasModifier(TargetModifiers.ForceAttack))
return false; return false;
return target.Info.TraitInfos<IDemolishableInfo>().Any(i => i.IsValidTarget(target.Info, self)); return target.Info.TraitInfos<IDemolishableInfo>().Any(i => i.IsValidTarget(target.Info, self));

View File

@@ -117,7 +117,7 @@ namespace OpenRA.Mods.Common.Traits
if (!engineerRepairable.Info.Types.IsEmpty && !engineerRepairable.Info.Types.Overlaps(info.Types)) if (!engineerRepairable.Info.Types.IsEmpty && !engineerRepairable.Info.Types.Overlaps(info.Types))
return false; return false;
if (!info.ValidRelationships.HasStance(target.Owner.RelationshipWith(self.Owner))) if (!info.ValidRelationships.HasRelationship(target.Owner.RelationshipWith(self.Owner)))
return false; return false;
if (target.GetDamageState() == DamageState.Undamaged) if (target.GetDamageState() == DamageState.Undamaged)
@@ -139,7 +139,7 @@ namespace OpenRA.Mods.Common.Traits
if (!engineerRepairable.Types.IsEmpty && !engineerRepairable.Types.Overlaps(info.Types)) if (!engineerRepairable.Types.IsEmpty && !engineerRepairable.Types.Overlaps(info.Types))
return false; return false;
if (!info.ValidRelationships.HasStance(target.Owner.RelationshipWith(self.Owner))) if (!info.ValidRelationships.HasRelationship(target.Owner.RelationshipWith(self.Owner)))
return false; return false;
if (target.DamageState == DamageState.Undamaged) if (target.DamageState == DamageState.Undamaged)

View File

@@ -64,7 +64,7 @@ namespace OpenRA.Mods.Common.Traits
if (e.Attacker == null || e.Attacker.Disposed || IsTraitDisabled) if (e.Attacker == null || e.Attacker.Disposed || IsTraitDisabled)
return; return;
if (!Info.ValidRelationships.HasStance(e.Attacker.Owner.RelationshipWith(self.Owner))) if (!Info.ValidRelationships.HasRelationship(e.Attacker.Owner.RelationshipWith(self.Owner)))
return; return;
if (!Info.DeathTypes.IsEmpty && !e.Damage.DamageTypes.Overlaps(Info.DeathTypes)) if (!Info.DeathTypes.IsEmpty && !e.Damage.DamageTypes.Overlaps(Info.DeathTypes))

View File

@@ -59,7 +59,7 @@ namespace OpenRA.Mods.Common.Traits
if (exp == 0 || e.Attacker == null || e.Attacker.Disposed) if (exp == 0 || e.Attacker == null || e.Attacker.Disposed)
return; return;
if (!info.ValidRelationships.HasStance(e.Attacker.Owner.RelationshipWith(self.Owner))) if (!info.ValidRelationships.HasRelationship(e.Attacker.Owner.RelationshipWith(self.Owner)))
return; return;
exp = Util.ApplyPercentageModifiers(exp, experienceModifiers); exp = Util.ApplyPercentageModifiers(exp, experienceModifiers);

View File

@@ -105,8 +105,8 @@ namespace OpenRA.Mods.Common.Traits
if (byPlayer == null) if (byPlayer == null)
return true; return true;
var stance = self.Owner.RelationshipWith(byPlayer); var relationship = self.Owner.RelationshipWith(byPlayer);
return info.AlwaysVisibleRelationships.HasStance(stance) || IsVisibleInner(self, byPlayer); return info.AlwaysVisibleRelationships.HasRelationship(relationship) || IsVisibleInner(self, byPlayer);
} }
void ITick.Tick(Actor self) void ITick.Tick(Actor self)

View File

@@ -55,8 +55,8 @@ namespace OpenRA.Mods.Common.Traits
if (byPlayer == null) if (byPlayer == null)
return true; return true;
var stance = self.Owner.RelationshipWith(byPlayer); var relationship = self.Owner.RelationshipWith(byPlayer);
return Info.AlwaysVisibleRelationships.HasStance(stance) || IsVisibleInner(self, byPlayer); return Info.AlwaysVisibleRelationships.HasRelationship(relationship) || IsVisibleInner(self, byPlayer);
} }
IEnumerable<IRenderable> IRenderModifier.ModifyRender(Actor self, WorldRenderer wr, IEnumerable<IRenderable> r) IEnumerable<IRenderable> IRenderModifier.ModifyRender(Actor self, WorldRenderer wr, IEnumerable<IRenderable> r)

View File

@@ -42,10 +42,10 @@ namespace OpenRA.Mods.Common.Traits.Radar
public void PopulateRadarSignatureCells(Actor self, List<(CPos Cell, Color Color)> destinationBuffer) public void PopulateRadarSignatureCells(Actor self, List<(CPos Cell, Color Color)> destinationBuffer)
{ {
var viewer = self.World.RenderPlayer ?? self.World.LocalPlayer; var viewer = self.World.RenderPlayer ?? self.World.LocalPlayer;
if (IsTraitDisabled || (viewer != null && !Info.ValidRelationships.HasStance(self.Owner.RelationshipWith(viewer)))) if (IsTraitDisabled || (viewer != null && !Info.ValidRelationships.HasRelationship(self.Owner.RelationshipWith(viewer))))
return; return;
var color = Game.Settings.Game.UsePlayerStanceColors ? self.Owner.PlayerStanceColor(self) : self.Owner.Color; var color = Game.Settings.Game.UsePlayerStanceColors ? self.Owner.PlayerRelationshipColor(self) : self.Owner.Color;
if (modifier != null) if (modifier != null)
color = modifier.RadarColorOverride(self, color); color = modifier.RadarColorOverride(self, color);

View File

@@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Traits.Render
float ISelectionBar.GetValue() float ISelectionBar.GetValue()
{ {
var viewer = self.World.RenderPlayer ?? self.World.LocalPlayer; var viewer = self.World.RenderPlayer ?? self.World.LocalPlayer;
if (viewer != null && !info.DisplayRelationships.HasStance(self.Owner.RelationshipWith(viewer))) if (viewer != null && !info.DisplayRelationships.HasRelationship(self.Owner.RelationshipWith(viewer)))
return 0; return 0;
var complete = cashTricklers.Min(ct => (float)ct.Ticks / ct.Info.Interval); var complete = cashTricklers.Min(ct => (float)ct.Ticks / ct.Info.Interval);

View File

@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Traits.Render
return 0; return 0;
var viewer = self.World.RenderPlayer ?? self.World.LocalPlayer; var viewer = self.World.RenderPlayer ?? self.World.LocalPlayer;
if (viewer != null && !Info.DisplayRelationships.HasStance(self.Owner.RelationshipWith(viewer))) if (viewer != null && !Info.DisplayRelationships.HasRelationship(self.Owner.RelationshipWith(viewer)))
return 0; return 0;
return 1 - (float)power.RemainingTicks / power.TotalTicks; return 1 - (float)power.RemainingTicks / power.TotalTicks;

View File

@@ -81,8 +81,8 @@ namespace OpenRA.Mods.Common.Traits.Render
if (self.World.RenderPlayer != null) if (self.World.RenderPlayer != null)
{ {
var stance = self.Owner.RelationshipWith(self.World.RenderPlayer); var relationship = self.Owner.RelationshipWith(self.World.RenderPlayer);
if (!Info.ValidRelationships.HasStance(stance)) if (!Info.ValidRelationships.HasRelationship(relationship))
return false; return false;
} }

View File

@@ -91,7 +91,7 @@ namespace OpenRA.Mods.Common.Traits.Render
return false; return false;
var p = self.World.RenderPlayer; var p = self.World.RenderPlayer;
return p == null || Info.ValidRelationships.HasStance(self.Owner.RelationshipWith(p)) || (p.Spectating && !p.NonCombatant); return p == null || Info.ValidRelationships.HasRelationship(self.Owner.RelationshipWith(p)) || (p.Spectating && !p.NonCombatant);
} }
} }

View File

@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits
protected void AddCellsToPlayerShroud(Actor self, Player p, PPos[] uv) protected void AddCellsToPlayerShroud(Actor self, Player p, PPos[] uv)
{ {
if (!Info.ValidRelationships.HasStance(self.Owner.RelationshipWith(p))) if (!Info.ValidRelationships.HasRelationship(self.Owner.RelationshipWith(p)))
return; return;
p.Shroud.AddSource(this, type, uv); p.Shroud.AddSource(this, type, uv);

View File

@@ -49,7 +49,7 @@ namespace OpenRA.Mods.Common.Traits
protected override void AddCellsToPlayerShroud(Actor self, Player p, PPos[] uv) protected override void AddCellsToPlayerShroud(Actor self, Player p, PPos[] uv)
{ {
if (!info.ValidRelationships.HasStance(self.Owner.RelationshipWith(p))) if (!info.ValidRelationships.HasRelationship(self.Owner.RelationshipWith(p)))
return; return;
p.Shroud.AddSource(this, type, uv); p.Shroud.AddSource(this, type, uv);

View File

@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Traits.Sound
if (player == null) if (player == null)
return; return;
if (Info.ValidRelationships.HasStance(self.Owner.RelationshipWith(player))) if (Info.ValidRelationships.HasRelationship(self.Owner.RelationshipWith(player)))
self.PlayVoice(Info.Voice); self.PlayVoice(Info.Voice);
else if (Info.PlayToOwner && self.Owner == player) else if (Info.PlayToOwner && self.Owner == player)
self.PlayVoice(Info.Voice); self.PlayVoice(Info.Voice);

View File

@@ -96,7 +96,7 @@ namespace OpenRA.Mods.Common.Traits
return units.Distinct().Where(a => return units.Distinct().Where(a =>
{ {
if (!info.ValidRelationships.HasStance(Self.Owner.RelationshipWith(a.Owner))) if (!info.ValidRelationships.HasRelationship(Self.Owner.RelationshipWith(a.Owner)))
return false; return false;
return a.TraitsImplementing<ExternalCondition>() return a.TraitsImplementing<ExternalCondition>()

View File

@@ -51,18 +51,18 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new Tooltip(init.Self, this); } public override object Create(ActorInitializer init) { return new Tooltip(init.Self, this); }
public string TooltipForPlayerStance(PlayerRelationship stance) public string TooltipForPlayerStance(PlayerRelationship relationship)
{ {
if (stance == PlayerRelationship.None || !GenericVisibility.HasStance(stance)) if (relationship == PlayerRelationship.None || !GenericVisibility.HasRelationship(relationship))
return Name; return Name;
if (GenericStancePrefix && !string.IsNullOrEmpty(AllyPrefix) && stance == PlayerRelationship.Ally) if (GenericStancePrefix && !string.IsNullOrEmpty(AllyPrefix) && relationship == PlayerRelationship.Ally)
return AllyPrefix + " " + GenericName; return AllyPrefix + " " + GenericName;
if (GenericStancePrefix && !string.IsNullOrEmpty(NeutralPrefix) && stance == PlayerRelationship.Neutral) if (GenericStancePrefix && !string.IsNullOrEmpty(NeutralPrefix) && relationship == PlayerRelationship.Neutral)
return NeutralPrefix + " " + GenericName; return NeutralPrefix + " " + GenericName;
if (GenericStancePrefix && !string.IsNullOrEmpty(EnemyPrefix) && stance == PlayerRelationship.Enemy) if (GenericStancePrefix && !string.IsNullOrEmpty(EnemyPrefix) && relationship == PlayerRelationship.Enemy)
return EnemyPrefix + " " + GenericName; return EnemyPrefix + " " + GenericName;
return GenericName; return GenericName;

View File

@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Traits
if (Owner == null || forPlayer == null) if (Owner == null || forPlayer == null)
return false; return false;
return Info.ValidRelationships.HasStance(Owner.RelationshipWith(forPlayer)); return Info.ValidRelationships.HasRelationship(Owner.RelationshipWith(forPlayer));
} }
public string TooltipText public string TooltipText

View File

@@ -79,8 +79,8 @@ namespace OpenRA.Mods.Common.Warheads
// (and to prevent returning ImpactActorType.Invalid on AffectsParent=false) // (and to prevent returning ImpactActorType.Invalid on AffectsParent=false)
public override bool IsValidAgainst(Actor victim, Actor firedBy) public override bool IsValidAgainst(Actor victim, Actor firedBy)
{ {
var stance = firedBy.Owner.RelationshipWith(victim.Owner); var relationship = firedBy.Owner.RelationshipWith(victim.Owner);
if (!ValidRelationships.HasStance(stance)) if (!ValidRelationships.HasRelationship(relationship))
return false; return false;
// A target type is valid if it is in the valid targets list, and not in the invalid targets list. // A target type is valid if it is in the valid targets list, and not in the invalid targets list.

View File

@@ -62,8 +62,8 @@ namespace OpenRA.Mods.Common.Warheads
if (!AffectsParent && victim == firedBy) if (!AffectsParent && victim == firedBy)
return false; return false;
var stance = firedBy.Owner.RelationshipWith(victim.Owner); var relationship = firedBy.Owner.RelationshipWith(victim.Owner);
if (!ValidRelationships.HasStance(stance)) if (!ValidRelationships.HasRelationship(relationship))
return false; return false;
// A target type is valid if it is in the valid targets list, and not in the invalid targets list. // A target type is valid if it is in the valid targets list, and not in the invalid targets list.
@@ -79,9 +79,9 @@ namespace OpenRA.Mods.Common.Warheads
if (!victim.IsValid) if (!victim.IsValid)
return false; return false;
// AffectsParent checks do not make sense for FrozenActors, so skip to stance checks // AffectsParent checks do not make sense for FrozenActors, so skip to relationship checks
var stance = firedBy.Owner.RelationshipWith(victim.Owner); var relationship = firedBy.Owner.RelationshipWith(victim.Owner);
if (!ValidRelationships.HasStance(stance)) if (!ValidRelationships.HasRelationship(relationship))
return false; return false;
// A target type is valid if it is in the valid targets list, and not in the invalid targets list. // A target type is valid if it is in the valid targets list, and not in the invalid targets list.

View File

@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Widgets
{ {
var owner = p.Instances[0].Self.Owner; var owner = p.Instances[0].Self.Owner;
var viewer = owner.World.RenderPlayer ?? owner.World.LocalPlayer; var viewer = owner.World.RenderPlayer ?? owner.World.LocalPlayer;
return viewer == null || p.Info.DisplayTimerRelationships.HasStance(owner.RelationshipWith(viewer)); return viewer == null || p.Info.DisplayTimerRelationships.HasRelationship(owner.RelationshipWith(viewer));
}); });
texts = displayedPowers.Select(p => texts = displayedPowers.Select(p =>
@@ -64,7 +64,7 @@ namespace OpenRA.Mods.Common.Widgets
var playerColor = self.Owner.Color; var playerColor = self.Owner.Color;
if (Game.Settings.Game.UsePlayerStanceColors) if (Game.Settings.Game.UsePlayerStanceColors)
playerColor = self.Owner.PlayerStanceColor(self); playerColor = self.Owner.PlayerRelationshipColor(self);
var color = !p.Ready || Game.LocalTick % 50 < 25 ? playerColor : Color.White; var color = !p.Ready || Game.LocalTick % 50 < 25 ? playerColor : Color.White;