Merge ConditionManager trait directly into Actor
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user