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

@@ -27,8 +27,7 @@ namespace OpenRA.Mods.Common.Traits
public class AffectedByPowerOutage : ConditionalTrait<AffectedByPowerOutageInfo>, INotifyOwnerChanged, ISelectionBar, INotifyCreated, INotifyAddedToWorld
{
PowerManager playerPower;
ConditionManager conditionManager;
int token = ConditionManager.InvalidConditionToken;
int token = Actor.InvalidConditionToken;
public AffectedByPowerOutage(Actor self, AffectedByPowerOutageInfo info)
: base(info)
@@ -40,13 +39,6 @@ namespace OpenRA.Mods.Common.Traits
protected override void TraitEnabled(Actor self) { UpdateStatus(self); }
protected override void TraitDisabled(Actor self) { Revoke(self); }
protected override void Created(Actor self)
{
conditionManager = self.TraitOrDefault<ConditionManager>();
base.Created(self);
}
float ISelectionBar.GetValue()
{
if (IsTraitDisabled || playerPower.PowerOutageRemainingTicks <= 0)
@@ -72,14 +64,14 @@ namespace OpenRA.Mods.Common.Traits
void Grant(Actor self)
{
if (token == ConditionManager.InvalidConditionToken)
token = conditionManager.GrantCondition(self, Info.Condition);
if (token == Actor.InvalidConditionToken)
token = self.GrantCondition(Info.Condition);
}
void Revoke(Actor self)
{
if (token != ConditionManager.InvalidConditionToken)
token = conditionManager.RevokeCondition(self, token);
if (token != Actor.InvalidConditionToken)
token = self.RevokeCondition(token);
}
void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)