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.")]
public readonly HashSet<string> Types = new HashSet<string>() { "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))

View File

@@ -20,9 +20,8 @@ namespace OpenRA.Mods.Common.Traits
[Desc("CaptureTypes (from the ExternalCaptures trait) that are able to capture this.")]
public readonly HashSet<string> Types = new HashSet<string>() { "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))