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

@@ -52,7 +52,6 @@ namespace OpenRA.Mods.Common.Traits
int cooldown = 0;
int shotsFired = 0;
ConditionManager manager;
// Only tracked when RevokeOnNewTarget is true.
Target lastTarget = Target.Invalid;
@@ -60,33 +59,26 @@ namespace OpenRA.Mods.Common.Traits
public GrantConditionOnAttack(ActorInitializer init, GrantConditionOnAttackInfo info)
: base(info) { }
protected override void Created(Actor self)
{
base.Created(self);
manager = self.TraitOrDefault<ConditionManager>();
}
void GrantInstance(Actor self, string cond)
{
if (manager == null || string.IsNullOrEmpty(cond))
if (string.IsNullOrEmpty(cond))
return;
tokens.Push(manager.GrantCondition(self, cond));
tokens.Push(self.GrantCondition(cond));
}
void RevokeInstance(Actor self, bool revokeAll)
{
shotsFired = 0;
if (manager == null || tokens.Count == 0)
if (tokens.Count == 0)
return;
if (!revokeAll)
manager.RevokeCondition(self, tokens.Pop());
self.RevokeCondition(tokens.Pop());
else
while (tokens.Count > 0)
manager.RevokeCondition(self, tokens.Pop());
self.RevokeCondition(tokens.Pop());
}
void ITick.Tick(Actor self)