From d2f0e5ac2dc0f743ce02540f68c87a056c8baff3 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 21 Oct 2017 14:34:29 +0100 Subject: [PATCH] Replace Allow(Allies|Neutral|Enemies) with ValidStances enum. --- OpenRA.Mods.Common/Traits/Capturable.cs | 15 ++++----------- OpenRA.Mods.Common/Traits/ExternalCapturable.cs | 15 ++++----------- 2 files changed, 8 insertions(+), 22 deletions(-) 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))