Merge pull request #12625 from pchote/fix-timed-conditions

Fix timed external conditions being rejected instead of reset.
This commit is contained in:
abcdefg30
2017-01-27 13:53:00 +01:00
committed by GitHub
5 changed files with 11 additions and 7 deletions

View File

@@ -211,7 +211,7 @@ namespace OpenRA.Mods.Common.Traits
}
/// <summary>Returns true if the given external condition will have an effect on this actor.</summary>
public bool AcceptsExternalCondition(Actor self, string condition)
public bool AcceptsExternalCondition(Actor self, string condition, bool timed = false)
{
if (state == null)
throw new InvalidOperationException("AcceptsExternalCondition cannot be queried before the actor has been fully created.");
@@ -219,6 +219,10 @@ namespace OpenRA.Mods.Common.Traits
if (!externalConditions.Contains(condition))
return false;
// A timed condition can always replace an existing timed condition (resetting its duration)
if (timed && timers.ContainsKey(condition))
return true;
string[] sc;
if (stackedConditions.TryGetValue(condition, out sc))
return stackedTokens[condition].Count < sc.Length;

View File

@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Traits
bool AcceptsCondition(Actor a)
{
var cm = a.TraitOrDefault<ConditionManager>();
return cm != null && cm.AcceptsExternalCondition(a, info.Condition);
return cm != null && cm.AcceptsExternalCondition(a, info.Condition, info.Duration > 0);
}
public override int GetSelectionShares(Actor collector)

View File

@@ -91,7 +91,7 @@ namespace OpenRA.Mods.Common.Traits
return false;
var cm = a.TraitOrDefault<ConditionManager>();
return cm != null && cm.AcceptsExternalCondition(a, info.Condition);
return cm != null && cm.AcceptsExternalCondition(a, info.Condition, info.Duration > 0);
});
}