Removed StackedCondition trait
This commit is contained in:
@@ -778,7 +778,6 @@
|
|||||||
<Compile Include="Traits\World\CliffBackImpassabilityLayer.cs" />
|
<Compile Include="Traits\World\CliffBackImpassabilityLayer.cs" />
|
||||||
<Compile Include="Traits\Conditions\GrantCondition.cs" />
|
<Compile Include="Traits\Conditions\GrantCondition.cs" />
|
||||||
<Compile Include="Traits\Conditions\ExternalCondition.cs" />
|
<Compile Include="Traits\Conditions\ExternalCondition.cs" />
|
||||||
<Compile Include="Traits\Conditions\StackedCondition.cs" />
|
|
||||||
<Compile Include="Traits\Buildings\BridgeHut.cs" />
|
<Compile Include="Traits\Buildings\BridgeHut.cs" />
|
||||||
<Compile Include="Traits\Buildings\BridgePlaceholder.cs" />
|
<Compile Include="Traits\Buildings\BridgePlaceholder.cs" />
|
||||||
<Compile Include="Traits\Buildings\GroundLevelBridge.cs" />
|
<Compile Include="Traits\Buildings\GroundLevelBridge.cs" />
|
||||||
|
|||||||
@@ -63,15 +63,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
/// <summary>Each granted condition receives a unique token that is used when revoking.</summary>
|
/// <summary>Each granted condition receives a unique token that is used when revoking.</summary>
|
||||||
Dictionary<int, string> tokens = new Dictionary<int, string>();
|
Dictionary<int, string> tokens = new Dictionary<int, string>();
|
||||||
|
|
||||||
/// <summary>Set of conditions that are monitored for stacked bonuses, and the bonus conditions that they grant.</summary>
|
|
||||||
readonly Dictionary<string, string[]> stackedConditions = new Dictionary<string, string[]>();
|
|
||||||
|
|
||||||
/// <summary>Tokens granted by the stacked condition bonuses defined in stackedConditions.</summary>
|
|
||||||
readonly Dictionary<string, Stack<int>> stackedTokens = new Dictionary<string, Stack<int>>();
|
|
||||||
|
|
||||||
int nextToken = 1;
|
int nextToken = 1;
|
||||||
|
|
||||||
/// <summary>Cache of condition -> enabled state for quick evaluation of boolean conditions.</summary>
|
/// <summary>Cache of condition -> enabled state for quick evaluation of token counter conditions.</summary>
|
||||||
readonly Dictionary<string, int> conditionCache = new Dictionary<string, int>();
|
readonly Dictionary<string, int> conditionCache = new Dictionary<string, int>();
|
||||||
|
|
||||||
/// <summary>Read-only version of conditionCache that is passed to IConditionConsumers.</summary>
|
/// <summary>Read-only version of conditionCache that is passed to IConditionConsumers.</summary>
|
||||||
@@ -111,12 +105,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
conditionCache[kv.Value] = conditionState.Tokens.Count;
|
conditionCache[kv.Value] = conditionState.Tokens.Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var sc in self.Info.TraitInfos<StackedConditionInfo>())
|
|
||||||
{
|
|
||||||
stackedConditions[sc.Condition] = sc.StackedConditions;
|
|
||||||
stackedTokens[sc.Condition] = new Stack<int>();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update all traits with their initial condition state
|
// Update all traits with their initial condition state
|
||||||
foreach (var consumer in allConsumers)
|
foreach (var consumer in allConsumers)
|
||||||
consumer.ConditionsChanged(self, readOnlyConditionCache);
|
consumer.ConditionsChanged(self, readOnlyConditionCache);
|
||||||
@@ -137,26 +125,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
foreach (var t in conditionState.Consumers)
|
foreach (var t in conditionState.Consumers)
|
||||||
t.ConditionsChanged(self, readOnlyConditionCache);
|
t.ConditionsChanged(self, readOnlyConditionCache);
|
||||||
|
|
||||||
string[] sc;
|
|
||||||
if (stackedConditions.TryGetValue(condition, out sc))
|
|
||||||
{
|
|
||||||
var target = (conditionState.Tokens.Count - 1).Clamp(0, sc.Length);
|
|
||||||
var st = stackedTokens[condition];
|
|
||||||
for (var i = st.Count; i < target; i++)
|
|
||||||
{
|
|
||||||
// Empty strings are used to skip unwanted levels
|
|
||||||
var t = !string.IsNullOrEmpty(sc[i]) ? GrantCondition(self, sc[i]) : InvalidConditionToken;
|
|
||||||
st.Push(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var i = st.Count; i > target; i--)
|
|
||||||
{
|
|
||||||
var t = st.Pop();
|
|
||||||
if (t != InvalidConditionToken)
|
|
||||||
RevokeCondition(self, t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Grants a specified condition.</summary>
|
/// <summary>Grants a specified condition.</summary>
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
#region Copyright & License Information
|
|
||||||
/*
|
|
||||||
* Copyright 2007-2017 The OpenRA Developers (see AUTHORS)
|
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
|
||||||
* available to you under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation, either version 3 of
|
|
||||||
* the License, or (at your option) any later version. For more
|
|
||||||
* information, see COPYING.
|
|
||||||
*/
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
using OpenRA.Traits;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits
|
|
||||||
{
|
|
||||||
[Desc("Grant additional conditions when a specified condition has been granted multiple times.")]
|
|
||||||
public class StackedConditionInfo : TraitInfo<StackedCondition>
|
|
||||||
{
|
|
||||||
[FieldLoader.Require]
|
|
||||||
[ConsumedConditionReference]
|
|
||||||
[Desc("Condition to monitor.")]
|
|
||||||
public readonly string Condition = null;
|
|
||||||
|
|
||||||
[FieldLoader.Require]
|
|
||||||
[FieldLoader.AllowEmptyEntries]
|
|
||||||
[GrantedConditionReference]
|
|
||||||
[Desc("Conditions to grant when the monitored condition is granted multiple times.",
|
|
||||||
"The first entry is activated at 2x grants, second entry at 3x grants, and so on.",
|
|
||||||
"Use empty entries to skip levels.")]
|
|
||||||
public readonly string[] StackedConditions = { };
|
|
||||||
}
|
|
||||||
|
|
||||||
public class StackedCondition { }
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user