diff --git a/OpenRA.Mods.Common/Traits/Capturable.cs b/OpenRA.Mods.Common/Traits/Capturable.cs index 397d9fb891..3f584154af 100644 --- a/OpenRA.Mods.Common/Traits/Capturable.cs +++ b/OpenRA.Mods.Common/Traits/Capturable.cs @@ -20,9 +20,8 @@ namespace OpenRA.Mods.Common.Traits [Desc("CaptureTypes (from the Captures trait) that are able to capture this.")] public readonly HashSet Types = new HashSet() { "building" }; - public readonly bool AllowAllies = false; - public readonly bool AllowNeutral = true; - public readonly bool AllowEnemies = true; + [Desc("What diplomatic stances can be captured by this actor.")] + public readonly Stance ValidStances = Stance.Neutral | Stance.Enemy; [Desc("Health percentage the target must be at (or below) before it can be captured.")] public readonly int CaptureThreshold = 50; @@ -36,14 +35,8 @@ namespace OpenRA.Mods.Common.Traits if (c == null) return false; - var playerRelationship = owner.Stances[captor.Owner]; - if (playerRelationship == Stance.Ally && !AllowAllies) - return false; - - if (playerRelationship == Stance.Enemy && !AllowEnemies) - return false; - - if (playerRelationship == Stance.Neutral && !AllowNeutral) + var stance = owner.Stances[captor.Owner]; + if (!ValidStances.HasStance(stance)) return false; if (!c.CaptureTypes.Overlaps(Types)) diff --git a/OpenRA.Mods.Common/Traits/ExternalCapturable.cs b/OpenRA.Mods.Common/Traits/ExternalCapturable.cs index 8d16955f8d..456d4c9bfe 100644 --- a/OpenRA.Mods.Common/Traits/ExternalCapturable.cs +++ b/OpenRA.Mods.Common/Traits/ExternalCapturable.cs @@ -20,9 +20,8 @@ namespace OpenRA.Mods.Common.Traits [Desc("CaptureTypes (from the ExternalCaptures trait) that are able to capture this.")] public readonly HashSet Types = new HashSet() { "building" }; - public readonly bool AllowAllies = false; - public readonly bool AllowNeutral = true; - public readonly bool AllowEnemies = true; + [Desc("What diplomatic stances can be captured by this actor.")] + public readonly Stance ValidStances = Stance.Neutral | Stance.Enemy; [Desc("Seconds it takes to change the owner.", "You might want to add a ExternalCapturableBar: trait, too.")] public readonly int CaptureCompleteTime = 15; @@ -36,14 +35,8 @@ namespace OpenRA.Mods.Common.Traits if (c == null) return false; - var playerRelationship = owner.Stances[captor.Owner]; - if (playerRelationship == Stance.Ally && !AllowAllies) - return false; - - if (playerRelationship == Stance.Enemy && !AllowEnemies) - return false; - - if (playerRelationship == Stance.Neutral && !AllowNeutral) + var stance = owner.Stances[captor.Owner]; + if (!ValidStances.HasStance(stance)) return false; if (!c.CaptureTypes.Overlaps(Types))