diff --git a/OpenRA.Game/Player.cs b/OpenRA.Game/Player.cs index 53d6ccfb22..b7904ecfff 100644 --- a/OpenRA.Game/Player.cs +++ b/OpenRA.Game/Player.cs @@ -265,7 +265,7 @@ namespace OpenRA return RelationshipWith(p) == PlayerRelationship.Ally; } - public Color PlayerStanceColor(Actor a) + public Color PlayerRelationshipColor(Actor a) { var player = a.World.RenderPlayer ?? a.World.LocalPlayer; if (player != null && !player.Spectating) diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index 8a0b6ae8af..6c3bcf7c81 100644 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -76,12 +76,12 @@ namespace OpenRA.Traits 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. - return (s & stance) == stance; + return (r & relationship) == relationship; } } diff --git a/OpenRA.Mods.Cnc/Traits/Disguise.cs b/OpenRA.Mods.Cnc/Traits/Disguise.cs index 5d261f98dc..481849c405 100644 --- a/OpenRA.Mods.Cnc/Traits/Disguise.cs +++ b/OpenRA.Mods.Cnc/Traits/Disguise.cs @@ -167,7 +167,7 @@ namespace OpenRA.Mods.Cnc.Traits if (!Disguised || self.Owner.IsAlliedWith(self.World.RenderPlayer)) 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) @@ -298,8 +298,8 @@ namespace OpenRA.Mods.Cnc.Traits public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor) { - var stance = self.Owner.RelationshipWith(target.Owner); - if (!info.ValidRelationships.HasStance(stance)) + var relationship = self.Owner.RelationshipWith(target.Owner); + if (!info.ValidRelationships.HasRelationship(relationship)) return false; 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) { - var stance = self.Owner.RelationshipWith(target.Owner); - if (!info.ValidRelationships.HasStance(stance)) + var relationship = self.Owner.RelationshipWith(target.Owner); + if (!info.ValidRelationships.HasRelationship(relationship)) return false; return info.TargetTypes.Overlaps(target.Info.GetAllTargetTypes()); diff --git a/OpenRA.Mods.Cnc/Traits/Infiltration/InfiltrateForDecoration.cs b/OpenRA.Mods.Cnc/Traits/Infiltration/InfiltrateForDecoration.cs index 2c60684125..53eea71ca4 100644 --- a/OpenRA.Mods.Cnc/Traits/Infiltration/InfiltrateForDecoration.cs +++ b/OpenRA.Mods.Cnc/Traits/Infiltration/InfiltrateForDecoration.cs @@ -48,7 +48,7 @@ namespace OpenRA.Mods.Cnc.Traits 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))); } } } diff --git a/OpenRA.Mods.Cnc/Traits/Infiltration/Infiltrates.cs b/OpenRA.Mods.Cnc/Traits/Infiltration/Infiltrates.cs index 080d4bb3f7..f265899eb1 100644 --- a/OpenRA.Mods.Cnc/Traits/Infiltration/Infiltrates.cs +++ b/OpenRA.Mods.Cnc/Traits/Infiltration/Infiltrates.cs @@ -101,10 +101,10 @@ namespace OpenRA.Mods.Cnc.Traits { case TargetType.Actor: 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: 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: return false; } @@ -136,7 +136,7 @@ namespace OpenRA.Mods.Cnc.Traits public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor) { var stance = self.Owner.RelationshipWith(target.Owner); - if (!info.ValidRelationships.HasStance(stance)) + if (!info.ValidRelationships.HasRelationship(stance)) return false; 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) { var stance = self.Owner.RelationshipWith(target.Owner); - if (!info.ValidRelationships.HasStance(stance)) + if (!info.ValidRelationships.HasRelationship(stance)) return false; return info.Types.Overlaps(target.Info.GetAllTargetTypes()); diff --git a/OpenRA.Mods.Common/Activities/CaptureActor.cs b/OpenRA.Mods.Common/Activities/CaptureActor.cs index 0bf9db924f..5f33123d0a 100644 --- a/OpenRA.Mods.Common/Activities/CaptureActor.cs +++ b/OpenRA.Mods.Common/Activities/CaptureActor.cs @@ -124,7 +124,7 @@ namespace OpenRA.Mods.Common.Activities foreach (var t in enterActor.TraitsImplementing()) 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()?.GiveExperience(captures.Info.PlayerExperience); if (captures.Info.ConsumedByCapture) diff --git a/OpenRA.Mods.Common/Activities/RepairBuilding.cs b/OpenRA.Mods.Common/Activities/RepairBuilding.cs index f997b844c3..3f9e28af67 100644 --- a/OpenRA.Mods.Common/Activities/RepairBuilding.cs +++ b/OpenRA.Mods.Common/Activities/RepairBuilding.cs @@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Activities // Make sure we can still repair the target before entering // (but not before, because this may stop the actor in the middle of nowhere) 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); return false; @@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Activities return; var stance = self.Owner.RelationshipWith(enterActor.Owner); - if (!info.ValidRelationships.HasStance(stance)) + if (!info.ValidRelationships.HasRelationship(stance)) return; if (enterHealth.DamageState == DamageState.Undamaged) diff --git a/OpenRA.Mods.Common/Effects/RevealShroudEffect.cs b/OpenRA.Mods.Common/Effects/RevealShroudEffect.cs index 0999528e82..97e189122a 100644 --- a/OpenRA.Mods.Common/Effects/RevealShroudEffect.cs +++ b/OpenRA.Mods.Common/Effects/RevealShroudEffect.cs @@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Effects void AddCellsToPlayerShroud(Player p, PPos[] uv) { - if (validStances.HasStance(player.RelationshipWith(p))) + if (validStances.HasRelationship(player.RelationshipWith(p))) p.Shroud.AddSource(this, sourceType, uv); } diff --git a/OpenRA.Mods.Common/Graphics/IsometricSelectionBarsAnnotationRenderable.cs b/OpenRA.Mods.Common/Graphics/IsometricSelectionBarsAnnotationRenderable.cs index d92c96e5c7..e16cade155 100644 --- a/OpenRA.Mods.Common/Graphics/IsometricSelectionBarsAnnotationRenderable.cs +++ b/OpenRA.Mods.Common/Graphics/IsometricSelectionBarsAnnotationRenderable.cs @@ -131,7 +131,7 @@ namespace OpenRA.Mods.Common.Graphics Color GetHealthColor(IHealth health) { if (Game.Settings.Game.UsePlayerStanceColors) - return actor.Owner.PlayerStanceColor(actor); + return actor.Owner.PlayerRelationshipColor(actor); return health.DamageState == DamageState.Critical ? Color.Red : health.DamageState == DamageState.Heavy ? Color.Yellow : Color.LimeGreen; diff --git a/OpenRA.Mods.Common/Graphics/SelectionBarsAnnotationRenderable.cs b/OpenRA.Mods.Common/Graphics/SelectionBarsAnnotationRenderable.cs index f47b629d92..f4f49e510f 100644 --- a/OpenRA.Mods.Common/Graphics/SelectionBarsAnnotationRenderable.cs +++ b/OpenRA.Mods.Common/Graphics/SelectionBarsAnnotationRenderable.cs @@ -87,7 +87,7 @@ namespace OpenRA.Mods.Common.Graphics Color GetHealthColor(IHealth health) { if (Game.Settings.Game.UsePlayerStanceColors) - return actor.Owner.PlayerStanceColor(actor); + return actor.Owner.PlayerRelationshipColor(actor); return health.DamageState == DamageState.Critical ? Color.Red : health.DamageState == DamageState.Heavy ? Color.Yellow : Color.LimeGreen; diff --git a/OpenRA.Mods.Common/Projectiles/Bullet.cs b/OpenRA.Mods.Common/Projectiles/Bullet.cs index f2a35ad808..575ccd34cb 100644 --- a/OpenRA.Mods.Common/Projectiles/Bullet.cs +++ b/OpenRA.Mods.Common/Projectiles/Bullet.cs @@ -319,7 +319,7 @@ namespace OpenRA.Mods.Common.Projectiles if (checkTargetType && !Target.FromActor(victim).IsValidFor(firedBy)) continue; - if (!info.ValidBounceBlockerRelationships.HasStance(firedBy.Owner.RelationshipWith(victim.Owner))) + if (!info.ValidBounceBlockerRelationships.HasRelationship(firedBy.Owner.RelationshipWith(victim.Owner))) continue; // If the impact position is within any actor's HitShape, we have a direct hit diff --git a/OpenRA.Mods.Common/Projectiles/Missile.cs b/OpenRA.Mods.Common/Projectiles/Missile.cs index 98ad379a1a..af5906166e 100644 --- a/OpenRA.Mods.Common/Projectiles/Missile.cs +++ b/OpenRA.Mods.Common/Projectiles/Missile.cs @@ -429,7 +429,7 @@ namespace OpenRA.Mods.Common.Projectiles if ((tp.Actor.CenterPosition - pos).HorizontalLengthSquared > tp.Trait.Range.LengthSquared) 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 tp.Actor.World.SharedRandom.Next(100) < tp.Trait.Chance; diff --git a/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs b/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs index 3047d04f06..39b32f310e 100644 --- a/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs +++ b/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs @@ -377,7 +377,7 @@ namespace OpenRA.Mods.Common.Traits return Armaments.Where(a => !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)); } diff --git a/OpenRA.Mods.Common/Traits/AutoTarget.cs b/OpenRA.Mods.Common/Traits/AutoTarget.cs index 7f77c856a6..e0d922da4c 100644 --- a/OpenRA.Mods.Common/Traits/AutoTarget.cs +++ b/OpenRA.Mods.Common/Traits/AutoTarget.cs @@ -325,8 +325,8 @@ namespace OpenRA.Mods.Common.Traits return activeTargetPriorities.Any(ati => { - // Incompatible stances - if (!ati.ValidRelationships.HasStance(self.Owner.RelationshipWith(owner))) + // Incompatible relationship + if (!ati.ValidRelationships.HasRelationship(self.Owner.RelationshipWith(owner))) return false; // Incompatible target types @@ -393,8 +393,8 @@ namespace OpenRA.Mods.Common.Traits if (ati.Priority < chosenTargetPriority) return false; - // Incompatible stances - if (!ati.ValidRelationships.HasStance(self.Owner.RelationshipWith(owner))) + // Incompatible relationship + if (!ati.ValidRelationships.HasRelationship(self.Owner.RelationshipWith(owner))) return false; // Incompatible target types diff --git a/OpenRA.Mods.Common/Traits/BotModules/CaptureManagerBotModule.cs b/OpenRA.Mods.Common/Traits/BotModules/CaptureManagerBotModule.cs index c58bdde86a..6bafdc3de0 100644 --- a/OpenRA.Mods.Common/Traits/BotModules/CaptureManagerBotModule.cs +++ b/OpenRA.Mods.Common/Traits/BotModules/CaptureManagerBotModule.cs @@ -133,7 +133,7 @@ namespace OpenRA.Mods.Common.Traits return; 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 ? GetVisibleActorsBelongingToPlayer(randPlayer) diff --git a/OpenRA.Mods.Common/Traits/CaptureManager.cs b/OpenRA.Mods.Common/Traits/CaptureManager.cs index 0ebf7a24f4..9a45534027 100644 --- a/OpenRA.Mods.Common/Traits/CaptureManager.cs +++ b/OpenRA.Mods.Common/Traits/CaptureManager.cs @@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Traits // Actors with FrozenUnderFog should therefore not disable the Capturable trait. var stance = captor.Owner.RelationshipWith(frozenActor.Owner); return frozenActor.Info.TraitInfos() - .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); 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); - if (c.Info.ValidRelationships.HasStance(PlayerRelationship.Neutral)) + if (c.Info.ValidRelationships.HasRelationship(PlayerRelationship.Neutral)) 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); } } @@ -128,14 +128,14 @@ namespace OpenRA.Mods.Common.Traits public bool CanBeTargetedBy(Actor self, Actor captor, CaptureManager captorManager) { - var stance = captor.Owner.RelationshipWith(self.Owner); - if (stance.HasStance(PlayerRelationship.Enemy)) + var relationship = captor.Owner.RelationshipWith(self.Owner); + if (relationship.HasRelationship(PlayerRelationship.Enemy)) return captorManager.capturesTypes.Overlaps(enemyCapturableTypes); - if (stance.HasStance(PlayerRelationship.Neutral)) + if (relationship.HasRelationship(PlayerRelationship.Neutral)) return captorManager.capturesTypes.Overlaps(neutralCapturableTypes); - if (stance.HasStance(PlayerRelationship.Ally)) + if (relationship.HasRelationship(PlayerRelationship.Ally)) return captorManager.capturesTypes.Overlaps(allyCapturableTypes); return false; @@ -146,14 +146,14 @@ namespace OpenRA.Mods.Common.Traits if (captures.IsTraitDisabled) return false; - var stance = captor.Owner.RelationshipWith(self.Owner); - if (stance.HasStance(PlayerRelationship.Enemy)) + var relationship = captor.Owner.RelationshipWith(self.Owner); + if (relationship.HasRelationship(PlayerRelationship.Enemy)) return captures.Info.CaptureTypes.Overlaps(enemyCapturableTypes); - if (stance.HasStance(PlayerRelationship.Neutral)) + if (relationship.HasRelationship(PlayerRelationship.Neutral)) return captures.Info.CaptureTypes.Overlaps(neutralCapturableTypes); - if (stance.HasStance(PlayerRelationship.Ally)) + if (relationship.HasRelationship(PlayerRelationship.Ally)) return captures.Info.CaptureTypes.Overlaps(allyCapturableTypes); return false; diff --git a/OpenRA.Mods.Common/Traits/Conditions/ProximityExternalCondition.cs b/OpenRA.Mods.Common/Traits/Conditions/ProximityExternalCondition.cs index 1f2b727db0..1e2450ab39 100644 --- a/OpenRA.Mods.Common/Traits/Conditions/ProximityExternalCondition.cs +++ b/OpenRA.Mods.Common/Traits/Conditions/ProximityExternalCondition.cs @@ -110,8 +110,8 @@ namespace OpenRA.Mods.Common.Traits if (tokens.ContainsKey(a)) return; - var stance = self.Owner.RelationshipWith(a.Owner); - if (!Info.ValidRelationships.HasStance(stance)) + var relationship = self.Owner.RelationshipWith(a.Owner); + if (!Info.ValidRelationships.HasRelationship(relationship)) return; var external = a.TraitsImplementing() @@ -135,7 +135,7 @@ namespace OpenRA.Mods.Common.Traits if ((produced.CenterPosition - self.CenterPosition).HorizontalLengthSquared <= Info.Range.LengthSquared) { var stance = self.Owner.RelationshipWith(produced.Owner); - if (!Info.ValidRelationships.HasStance(stance)) + if (!Info.ValidRelationships.HasRelationship(stance)) return; var external = produced.TraitsImplementing() diff --git a/OpenRA.Mods.Common/Traits/CreatesShroud.cs b/OpenRA.Mods.Common/Traits/CreatesShroud.cs index d3286a8928..5b7d3ca817 100644 --- a/OpenRA.Mods.Common/Traits/CreatesShroud.cs +++ b/OpenRA.Mods.Common/Traits/CreatesShroud.cs @@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Traits 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; p.Shroud.AddSource(this, Shroud.SourceType.Shroud, uv); diff --git a/OpenRA.Mods.Common/Traits/DeliversCash.cs b/OpenRA.Mods.Common/Traits/DeliversCash.cs index deb8b2a7a3..1bb49fde43 100644 --- a/OpenRA.Mods.Common/Traits/DeliversCash.cs +++ b/OpenRA.Mods.Common/Traits/DeliversCash.cs @@ -99,7 +99,7 @@ namespace OpenRA.Mods.Common.Traits public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor) { var targetInfo = target.Info.TraitInfoOrDefault(); - if (targetInfo == null || !targetInfo.ValidRelationships.HasStance(target.Owner.RelationshipWith(self.Owner))) + if (targetInfo == null || !targetInfo.ValidRelationships.HasRelationship(target.Owner.RelationshipWith(self.Owner))) return false; 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) { var targetInfo = target.Info.TraitInfoOrDefault(); - if (targetInfo == null || !targetInfo.ValidRelationships.HasStance(target.Owner.RelationshipWith(self.Owner))) + if (targetInfo == null || !targetInfo.ValidRelationships.HasRelationship(target.Owner.RelationshipWith(self.Owner))) return false; if (targetInfo.ValidTypes.Count == 0) diff --git a/OpenRA.Mods.Common/Traits/DeliversExperience.cs b/OpenRA.Mods.Common/Traits/DeliversExperience.cs index 9c1e9b4503..4f94009fb3 100644 --- a/OpenRA.Mods.Common/Traits/DeliversExperience.cs +++ b/OpenRA.Mods.Common/Traits/DeliversExperience.cs @@ -109,7 +109,7 @@ namespace OpenRA.Mods.Common.Traits return false; var targetInfo = target.Info.TraitInfoOrDefault(); - if (targetInfo == null || !targetInfo.ValidRelationships.HasStance(target.Owner.RelationshipWith(self.Owner))) + if (targetInfo == null || !targetInfo.ValidRelationships.HasRelationship(target.Owner.RelationshipWith(self.Owner))) return false; if (targetInfo.ValidTypes.Count == 0) @@ -129,7 +129,7 @@ namespace OpenRA.Mods.Common.Traits return false; var targetInfo = target.Info.TraitInfoOrDefault(); - if (targetInfo == null || !targetInfo.ValidRelationships.HasStance(target.Owner.RelationshipWith(self.Owner))) + if (targetInfo == null || !targetInfo.ValidRelationships.HasRelationship(target.Owner.RelationshipWith(self.Owner))) return false; if (targetInfo.ValidTypes.Count == 0) diff --git a/OpenRA.Mods.Common/Traits/Demolition.cs b/OpenRA.Mods.Common/Traits/Demolition.cs index 488ee75b7c..ef2240690d 100644 --- a/OpenRA.Mods.Common/Traits/Demolition.cs +++ b/OpenRA.Mods.Common/Traits/Demolition.cs @@ -117,11 +117,11 @@ namespace OpenRA.Mods.Common.Traits if (modifiers.HasModifier(TargetModifiers.ForceMove)) return false; - var stance = target.Owner.RelationshipWith(self.Owner); - if (!info.TargetRelationships.HasStance(stance) && !modifiers.HasModifier(TargetModifiers.ForceAttack)) + var relationship = target.Owner.RelationshipWith(self.Owner); + if (!info.TargetRelationships.HasRelationship(relationship) && !modifiers.HasModifier(TargetModifiers.ForceAttack)) return false; - if (!info.ForceTargetRelationships.HasStance(stance) && modifiers.HasModifier(TargetModifiers.ForceAttack)) + if (!info.ForceTargetRelationships.HasRelationship(relationship) && modifiers.HasModifier(TargetModifiers.ForceAttack)) return false; return target.TraitsImplementing().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) { - var stance = target.Owner.RelationshipWith(self.Owner); - if (!info.TargetRelationships.HasStance(stance) && !modifiers.HasModifier(TargetModifiers.ForceAttack)) + var relationship = target.Owner.RelationshipWith(self.Owner); + if (!info.TargetRelationships.HasRelationship(relationship) && !modifiers.HasModifier(TargetModifiers.ForceAttack)) return false; - if (!info.ForceTargetRelationships.HasStance(stance) && modifiers.HasModifier(TargetModifiers.ForceAttack)) + if (!info.ForceTargetRelationships.HasRelationship(relationship) && modifiers.HasModifier(TargetModifiers.ForceAttack)) return false; return target.Info.TraitInfos().Any(i => i.IsValidTarget(target.Info, self)); diff --git a/OpenRA.Mods.Common/Traits/EngineerRepair.cs b/OpenRA.Mods.Common/Traits/EngineerRepair.cs index 80f78e1289..9f72fe918a 100644 --- a/OpenRA.Mods.Common/Traits/EngineerRepair.cs +++ b/OpenRA.Mods.Common/Traits/EngineerRepair.cs @@ -117,7 +117,7 @@ namespace OpenRA.Mods.Common.Traits if (!engineerRepairable.Info.Types.IsEmpty && !engineerRepairable.Info.Types.Overlaps(info.Types)) return false; - if (!info.ValidRelationships.HasStance(target.Owner.RelationshipWith(self.Owner))) + if (!info.ValidRelationships.HasRelationship(target.Owner.RelationshipWith(self.Owner))) return false; if (target.GetDamageState() == DamageState.Undamaged) @@ -139,7 +139,7 @@ namespace OpenRA.Mods.Common.Traits if (!engineerRepairable.Types.IsEmpty && !engineerRepairable.Types.Overlaps(info.Types)) return false; - if (!info.ValidRelationships.HasStance(target.Owner.RelationshipWith(self.Owner))) + if (!info.ValidRelationships.HasRelationship(target.Owner.RelationshipWith(self.Owner))) return false; if (target.DamageState == DamageState.Undamaged) diff --git a/OpenRA.Mods.Common/Traits/GivesBounty.cs b/OpenRA.Mods.Common/Traits/GivesBounty.cs index 2ec98aab32..da2b6e9d1b 100644 --- a/OpenRA.Mods.Common/Traits/GivesBounty.cs +++ b/OpenRA.Mods.Common/Traits/GivesBounty.cs @@ -64,7 +64,7 @@ namespace OpenRA.Mods.Common.Traits if (e.Attacker == null || e.Attacker.Disposed || IsTraitDisabled) return; - if (!Info.ValidRelationships.HasStance(e.Attacker.Owner.RelationshipWith(self.Owner))) + if (!Info.ValidRelationships.HasRelationship(e.Attacker.Owner.RelationshipWith(self.Owner))) return; if (!Info.DeathTypes.IsEmpty && !e.Damage.DamageTypes.Overlaps(Info.DeathTypes)) diff --git a/OpenRA.Mods.Common/Traits/GivesExperience.cs b/OpenRA.Mods.Common/Traits/GivesExperience.cs index c03fbacaf0..916dbac92f 100644 --- a/OpenRA.Mods.Common/Traits/GivesExperience.cs +++ b/OpenRA.Mods.Common/Traits/GivesExperience.cs @@ -59,7 +59,7 @@ namespace OpenRA.Mods.Common.Traits if (exp == 0 || e.Attacker == null || e.Attacker.Disposed) return; - if (!info.ValidRelationships.HasStance(e.Attacker.Owner.RelationshipWith(self.Owner))) + if (!info.ValidRelationships.HasRelationship(e.Attacker.Owner.RelationshipWith(self.Owner))) return; exp = Util.ApplyPercentageModifiers(exp, experienceModifiers); diff --git a/OpenRA.Mods.Common/Traits/Modifiers/FrozenUnderFog.cs b/OpenRA.Mods.Common/Traits/Modifiers/FrozenUnderFog.cs index c6651937f5..35191d91cc 100644 --- a/OpenRA.Mods.Common/Traits/Modifiers/FrozenUnderFog.cs +++ b/OpenRA.Mods.Common/Traits/Modifiers/FrozenUnderFog.cs @@ -105,8 +105,8 @@ namespace OpenRA.Mods.Common.Traits if (byPlayer == null) return true; - var stance = self.Owner.RelationshipWith(byPlayer); - return info.AlwaysVisibleRelationships.HasStance(stance) || IsVisibleInner(self, byPlayer); + var relationship = self.Owner.RelationshipWith(byPlayer); + return info.AlwaysVisibleRelationships.HasRelationship(relationship) || IsVisibleInner(self, byPlayer); } void ITick.Tick(Actor self) diff --git a/OpenRA.Mods.Common/Traits/Modifiers/HiddenUnderShroud.cs b/OpenRA.Mods.Common/Traits/Modifiers/HiddenUnderShroud.cs index 60eac4cda8..6ed4983c08 100644 --- a/OpenRA.Mods.Common/Traits/Modifiers/HiddenUnderShroud.cs +++ b/OpenRA.Mods.Common/Traits/Modifiers/HiddenUnderShroud.cs @@ -55,8 +55,8 @@ namespace OpenRA.Mods.Common.Traits if (byPlayer == null) return true; - var stance = self.Owner.RelationshipWith(byPlayer); - return Info.AlwaysVisibleRelationships.HasStance(stance) || IsVisibleInner(self, byPlayer); + var relationship = self.Owner.RelationshipWith(byPlayer); + return Info.AlwaysVisibleRelationships.HasRelationship(relationship) || IsVisibleInner(self, byPlayer); } IEnumerable IRenderModifier.ModifyRender(Actor self, WorldRenderer wr, IEnumerable r) diff --git a/OpenRA.Mods.Common/Traits/Radar/AppearsOnRadar.cs b/OpenRA.Mods.Common/Traits/Radar/AppearsOnRadar.cs index eb3d2bb5f7..5883604e65 100644 --- a/OpenRA.Mods.Common/Traits/Radar/AppearsOnRadar.cs +++ b/OpenRA.Mods.Common/Traits/Radar/AppearsOnRadar.cs @@ -42,10 +42,10 @@ namespace OpenRA.Mods.Common.Traits.Radar public void PopulateRadarSignatureCells(Actor self, List<(CPos Cell, Color Color)> destinationBuffer) { 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; - 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) color = modifier.RadarColorOverride(self, color); diff --git a/OpenRA.Mods.Common/Traits/Render/CashTricklerBar.cs b/OpenRA.Mods.Common/Traits/Render/CashTricklerBar.cs index c30ffe1406..50722c01c6 100644 --- a/OpenRA.Mods.Common/Traits/Render/CashTricklerBar.cs +++ b/OpenRA.Mods.Common/Traits/Render/CashTricklerBar.cs @@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Traits.Render float ISelectionBar.GetValue() { 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; var complete = cashTricklers.Min(ct => (float)ct.Ticks / ct.Info.Interval); diff --git a/OpenRA.Mods.Common/Traits/Render/SupportPowerChargeBar.cs b/OpenRA.Mods.Common/Traits/Render/SupportPowerChargeBar.cs index 791a03b36b..b954209987 100644 --- a/OpenRA.Mods.Common/Traits/Render/SupportPowerChargeBar.cs +++ b/OpenRA.Mods.Common/Traits/Render/SupportPowerChargeBar.cs @@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Traits.Render return 0; 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 1 - (float)power.RemainingTicks / power.TotalTicks; diff --git a/OpenRA.Mods.Common/Traits/Render/WithDecorationBase.cs b/OpenRA.Mods.Common/Traits/Render/WithDecorationBase.cs index 90762e2faf..84097c9d5f 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithDecorationBase.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithDecorationBase.cs @@ -81,8 +81,8 @@ namespace OpenRA.Mods.Common.Traits.Render if (self.World.RenderPlayer != null) { - var stance = self.Owner.RelationshipWith(self.World.RenderPlayer); - if (!Info.ValidRelationships.HasStance(stance)) + var relationship = self.Owner.RelationshipWith(self.World.RenderPlayer); + if (!Info.ValidRelationships.HasRelationship(relationship)) return false; } diff --git a/OpenRA.Mods.Common/Traits/Render/WithRangeCircle.cs b/OpenRA.Mods.Common/Traits/Render/WithRangeCircle.cs index 6b15459c6f..b99bc03a3e 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithRangeCircle.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithRangeCircle.cs @@ -91,7 +91,7 @@ namespace OpenRA.Mods.Common.Traits.Render return false; 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); } } diff --git a/OpenRA.Mods.Common/Traits/RevealsMap.cs b/OpenRA.Mods.Common/Traits/RevealsMap.cs index 9d974f2c70..ee87ee7897 100644 --- a/OpenRA.Mods.Common/Traits/RevealsMap.cs +++ b/OpenRA.Mods.Common/Traits/RevealsMap.cs @@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits 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; p.Shroud.AddSource(this, type, uv); diff --git a/OpenRA.Mods.Common/Traits/RevealsShroud.cs b/OpenRA.Mods.Common/Traits/RevealsShroud.cs index 14646464a6..5bf298360a 100644 --- a/OpenRA.Mods.Common/Traits/RevealsShroud.cs +++ b/OpenRA.Mods.Common/Traits/RevealsShroud.cs @@ -49,7 +49,7 @@ namespace OpenRA.Mods.Common.Traits 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; p.Shroud.AddSource(this, type, uv); diff --git a/OpenRA.Mods.Common/Traits/Sound/VoiceAnnouncement.cs b/OpenRA.Mods.Common/Traits/Sound/VoiceAnnouncement.cs index 6c2fd32bf0..969b634438 100644 --- a/OpenRA.Mods.Common/Traits/Sound/VoiceAnnouncement.cs +++ b/OpenRA.Mods.Common/Traits/Sound/VoiceAnnouncement.cs @@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Traits.Sound if (player == null) return; - if (Info.ValidRelationships.HasStance(self.Owner.RelationshipWith(player))) + if (Info.ValidRelationships.HasRelationship(self.Owner.RelationshipWith(player))) self.PlayVoice(Info.Voice); else if (Info.PlayToOwner && self.Owner == player) self.PlayVoice(Info.Voice); diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/GrantExternalConditionPower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/GrantExternalConditionPower.cs index 3ac0e372ab..706732db66 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/GrantExternalConditionPower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/GrantExternalConditionPower.cs @@ -96,7 +96,7 @@ namespace OpenRA.Mods.Common.Traits 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 a.TraitsImplementing() diff --git a/OpenRA.Mods.Common/Traits/Tooltip.cs b/OpenRA.Mods.Common/Traits/Tooltip.cs index ee09e88488..056c670a27 100644 --- a/OpenRA.Mods.Common/Traits/Tooltip.cs +++ b/OpenRA.Mods.Common/Traits/Tooltip.cs @@ -51,18 +51,18 @@ namespace OpenRA.Mods.Common.Traits 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; - if (GenericStancePrefix && !string.IsNullOrEmpty(AllyPrefix) && stance == PlayerRelationship.Ally) + if (GenericStancePrefix && !string.IsNullOrEmpty(AllyPrefix) && relationship == PlayerRelationship.Ally) return AllyPrefix + " " + GenericName; - if (GenericStancePrefix && !string.IsNullOrEmpty(NeutralPrefix) && stance == PlayerRelationship.Neutral) + if (GenericStancePrefix && !string.IsNullOrEmpty(NeutralPrefix) && relationship == PlayerRelationship.Neutral) return NeutralPrefix + " " + GenericName; - if (GenericStancePrefix && !string.IsNullOrEmpty(EnemyPrefix) && stance == PlayerRelationship.Enemy) + if (GenericStancePrefix && !string.IsNullOrEmpty(EnemyPrefix) && relationship == PlayerRelationship.Enemy) return EnemyPrefix + " " + GenericName; return GenericName; diff --git a/OpenRA.Mods.Common/Traits/TooltipDescription.cs b/OpenRA.Mods.Common/Traits/TooltipDescription.cs index d552c45f02..9cde8948fe 100644 --- a/OpenRA.Mods.Common/Traits/TooltipDescription.cs +++ b/OpenRA.Mods.Common/Traits/TooltipDescription.cs @@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Traits if (Owner == null || forPlayer == null) return false; - return Info.ValidRelationships.HasStance(Owner.RelationshipWith(forPlayer)); + return Info.ValidRelationships.HasRelationship(Owner.RelationshipWith(forPlayer)); } public string TooltipText diff --git a/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs b/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs index b32d53c4e4..7c7c4d3f7e 100644 --- a/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs +++ b/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs @@ -79,8 +79,8 @@ namespace OpenRA.Mods.Common.Warheads // (and to prevent returning ImpactActorType.Invalid on AffectsParent=false) public override bool IsValidAgainst(Actor victim, Actor firedBy) { - var stance = firedBy.Owner.RelationshipWith(victim.Owner); - if (!ValidRelationships.HasStance(stance)) + var relationship = firedBy.Owner.RelationshipWith(victim.Owner); + if (!ValidRelationships.HasRelationship(relationship)) return false; // A target type is valid if it is in the valid targets list, and not in the invalid targets list. diff --git a/OpenRA.Mods.Common/Warheads/Warhead.cs b/OpenRA.Mods.Common/Warheads/Warhead.cs index 3e82722cc1..69b19a2033 100644 --- a/OpenRA.Mods.Common/Warheads/Warhead.cs +++ b/OpenRA.Mods.Common/Warheads/Warhead.cs @@ -62,8 +62,8 @@ namespace OpenRA.Mods.Common.Warheads if (!AffectsParent && victim == firedBy) return false; - var stance = firedBy.Owner.RelationshipWith(victim.Owner); - if (!ValidRelationships.HasStance(stance)) + var relationship = firedBy.Owner.RelationshipWith(victim.Owner); + if (!ValidRelationships.HasRelationship(relationship)) return false; // 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) return false; - // AffectsParent checks do not make sense for FrozenActors, so skip to stance checks - var stance = firedBy.Owner.RelationshipWith(victim.Owner); - if (!ValidRelationships.HasStance(stance)) + // AffectsParent checks do not make sense for FrozenActors, so skip to relationship checks + var relationship = firedBy.Owner.RelationshipWith(victim.Owner); + if (!ValidRelationships.HasRelationship(relationship)) return false; // A target type is valid if it is in the valid targets list, and not in the invalid targets list. diff --git a/OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs b/OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs index 7b5ccd517c..40c1b2f411 100644 --- a/OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs +++ b/OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs @@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Widgets { var owner = p.Instances[0].Self.Owner; 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 => @@ -64,7 +64,7 @@ namespace OpenRA.Mods.Common.Widgets var playerColor = self.Owner.Color; 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;