Replace Allow(Allies|Neutral|Enemies) with ValidStances enum.

This commit is contained in:
Paul Chote
2017-10-21 14:34:29 +01:00
committed by reaperrr
parent 1caf982c1f
commit d2f0e5ac2d
2 changed files with 8 additions and 22 deletions

View File

@@ -20,9 +20,8 @@ namespace OpenRA.Mods.Common.Traits
[Desc("CaptureTypes (from the Captures trait) that are able to capture this.")] [Desc("CaptureTypes (from the Captures trait) that are able to capture this.")]
public readonly HashSet<string> Types = new HashSet<string>() { "building" }; public readonly HashSet<string> Types = new HashSet<string>() { "building" };
public readonly bool AllowAllies = false; [Desc("What diplomatic stances can be captured by this actor.")]
public readonly bool AllowNeutral = true; public readonly Stance ValidStances = Stance.Neutral | Stance.Enemy;
public readonly bool AllowEnemies = true;
[Desc("Health percentage the target must be at (or below) before it can be captured.")] [Desc("Health percentage the target must be at (or below) before it can be captured.")]
public readonly int CaptureThreshold = 50; public readonly int CaptureThreshold = 50;
@@ -36,14 +35,8 @@ namespace OpenRA.Mods.Common.Traits
if (c == null) if (c == null)
return false; return false;
var playerRelationship = owner.Stances[captor.Owner]; var stance = owner.Stances[captor.Owner];
if (playerRelationship == Stance.Ally && !AllowAllies) if (!ValidStances.HasStance(stance))
return false;
if (playerRelationship == Stance.Enemy && !AllowEnemies)
return false;
if (playerRelationship == Stance.Neutral && !AllowNeutral)
return false; return false;
if (!c.CaptureTypes.Overlaps(Types)) if (!c.CaptureTypes.Overlaps(Types))

View File

@@ -20,9 +20,8 @@ namespace OpenRA.Mods.Common.Traits
[Desc("CaptureTypes (from the ExternalCaptures trait) that are able to capture this.")] [Desc("CaptureTypes (from the ExternalCaptures trait) that are able to capture this.")]
public readonly HashSet<string> Types = new HashSet<string>() { "building" }; public readonly HashSet<string> Types = new HashSet<string>() { "building" };
public readonly bool AllowAllies = false; [Desc("What diplomatic stances can be captured by this actor.")]
public readonly bool AllowNeutral = true; public readonly Stance ValidStances = Stance.Neutral | Stance.Enemy;
public readonly bool AllowEnemies = true;
[Desc("Seconds it takes to change the owner.", "You might want to add a ExternalCapturableBar: trait, too.")] [Desc("Seconds it takes to change the owner.", "You might want to add a ExternalCapturableBar: trait, too.")]
public readonly int CaptureCompleteTime = 15; public readonly int CaptureCompleteTime = 15;
@@ -36,14 +35,8 @@ namespace OpenRA.Mods.Common.Traits
if (c == null) if (c == null)
return false; return false;
var playerRelationship = owner.Stances[captor.Owner]; var stance = owner.Stances[captor.Owner];
if (playerRelationship == Stance.Ally && !AllowAllies) if (!ValidStances.HasStance(stance))
return false;
if (playerRelationship == Stance.Enemy && !AllowEnemies)
return false;
if (playerRelationship == Stance.Neutral && !AllowNeutral)
return false; return false;
if (!c.CaptureTypes.Overlaps(Types)) if (!c.CaptureTypes.Overlaps(Types))