Changes to ExternalCondition.TryRevokeCondition
This commit is contained in:
@@ -50,7 +50,8 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
public void RevokeCondition(int token)
|
public void RevokeCondition(int token)
|
||||||
{
|
{
|
||||||
foreach (var external in externalConditions)
|
foreach (var external in externalConditions)
|
||||||
external.TryRevokeCondition(Self, this, token);
|
if (external.TryRevokeCondition(Self, this, token))
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Desc("Check whether this actor accepts a specific external condition.")]
|
[Desc("Check whether this actor accepts a specific external condition.")]
|
||||||
|
|||||||
@@ -130,10 +130,20 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (conditionManager == null || source == null)
|
if (conditionManager == null || source == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var removed = permanentTokens.GetOrAdd(source).Remove(token) ||
|
HashSet<int> permanentTokensForSource;
|
||||||
timedTokens.GetOrAdd(source).RemoveWhere(t => t.Token == token) > 0;
|
if (permanentTokens.TryGetValue(source, out permanentTokensForSource))
|
||||||
|
{
|
||||||
|
if (!permanentTokensForSource.Remove(token))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HashSet<TimedToken> timedTokensForSource = null;
|
||||||
|
if (timedTokens.TryGetValue(source, out timedTokensForSource) && timedTokensForSource.RemoveWhere(t => t.Token == token) == 0)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (removed && conditionManager.TokenValid(self, token))
|
if (conditionManager.TokenValid(self, token))
|
||||||
conditionManager.RevokeCondition(self, token);
|
conditionManager.RevokeCondition(self, token);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -56,7 +56,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (var external in segment.TraitsImplementing<ExternalCondition>())
|
foreach (var external in segment.TraitsImplementing<ExternalCondition>())
|
||||||
external.TryRevokeCondition(segment, self, token);
|
if (external.TryRevokeCondition(segment, self, token))
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyLineBuildSegmentsChanged.SegmentAdded(Actor self, Actor segment)
|
void INotifyLineBuildSegmentsChanged.SegmentAdded(Actor self, Actor segment)
|
||||||
|
|||||||
@@ -156,7 +156,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
tokens.Remove(a);
|
tokens.Remove(a);
|
||||||
foreach (var external in a.TraitsImplementing<ExternalCondition>())
|
foreach (var external in a.TraitsImplementing<ExternalCondition>())
|
||||||
external.TryRevokeCondition(a, self, token);
|
if (external.TryRevokeCondition(a, self, token))
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user