Merge ConditionManager trait directly into Actor

This commit is contained in:
atlimit8
2020-04-18 23:25:05 -05:00
committed by reaperrr
parent e12c1dc9aa
commit 259c8d2c98
65 changed files with 466 additions and 707 deletions

View File

@@ -51,7 +51,6 @@ namespace OpenRA.Mods.Common.Traits
{
public readonly AmmoPoolInfo Info;
readonly Stack<int> tokens = new Stack<int>();
ConditionManager conditionManager;
// HACK: Temporarily needed until Rearm activity is gone for good
[Sync]
@@ -91,7 +90,6 @@ namespace OpenRA.Mods.Common.Traits
void INotifyCreated.Created(Actor self)
{
conditionManager = self.TraitOrDefault<ConditionManager>();
UpdateCondition(self);
// HACK: Temporarily needed until Rearm activity is gone for good
@@ -108,14 +106,14 @@ namespace OpenRA.Mods.Common.Traits
void UpdateCondition(Actor self)
{
if (conditionManager == null || string.IsNullOrEmpty(Info.AmmoCondition))
if (string.IsNullOrEmpty(Info.AmmoCondition))
return;
while (CurrentAmmoCount > tokens.Count && tokens.Count < Info.Ammo)
tokens.Push(conditionManager.GrantCondition(self, Info.AmmoCondition));
tokens.Push(self.GrantCondition(Info.AmmoCondition));
while (CurrentAmmoCount < tokens.Count && tokens.Count > 0)
conditionManager.RevokeCondition(self, tokens.Pop());
self.RevokeCondition(tokens.Pop());
}
}
}