Some internal renamings in power-related traits

This commit is contained in:
reaperrr
2017-11-13 01:34:35 +01:00
committed by Pavel Penev
parent 7f5f2eac6f
commit a7620c97f0
2 changed files with 19 additions and 19 deletions

View File

@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Traits
public class CanPowerDown : ConditionalTrait<CanPowerDownInfo>, IPowerModifier, IResolveOrder, INotifyOwnerChanged public class CanPowerDown : ConditionalTrait<CanPowerDownInfo>, IPowerModifier, IResolveOrder, INotifyOwnerChanged
{ {
[Sync] bool poweredDown = false; [Sync] bool isPoweredDown = false;
PowerManager power; PowerManager power;
ConditionManager conditionManager; ConditionManager conditionManager;
@@ -66,9 +66,9 @@ namespace OpenRA.Mods.Common.Traits
if (conditionManager == null) if (conditionManager == null)
return; return;
if (poweredDown && conditionToken == ConditionManager.InvalidConditionToken) if (isPoweredDown && conditionToken == ConditionManager.InvalidConditionToken)
conditionToken = conditionManager.GrantCondition(self, Info.PowerdownCondition); conditionToken = conditionManager.GrantCondition(self, Info.PowerdownCondition);
else if (!poweredDown && conditionToken != ConditionManager.InvalidConditionToken) else if (!isPoweredDown && conditionToken != ConditionManager.InvalidConditionToken)
conditionToken = conditionManager.RevokeCondition(self, conditionToken); conditionToken = conditionManager.RevokeCondition(self, conditionToken);
} }
@@ -76,18 +76,18 @@ namespace OpenRA.Mods.Common.Traits
{ {
if (!IsTraitDisabled && order.OrderString == "PowerDown") if (!IsTraitDisabled && order.OrderString == "PowerDown")
{ {
poweredDown = !poweredDown; isPoweredDown = !isPoweredDown;
if (Info.PowerupSound != null && poweredDown) if (Info.PowerupSound != null && isPoweredDown)
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Sounds", Info.PowerupSound, self.Owner.Faction.InternalName); Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Sounds", Info.PowerupSound, self.Owner.Faction.InternalName);
if (Info.PowerdownSound != null && !poweredDown) if (Info.PowerdownSound != null && !isPoweredDown)
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Sounds", Info.PowerdownSound, self.Owner.Faction.InternalName); Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Sounds", Info.PowerdownSound, self.Owner.Faction.InternalName);
if (Info.PowerupSpeech != null && poweredDown) if (Info.PowerupSpeech != null && isPoweredDown)
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", Info.PowerupSpeech, self.Owner.Faction.InternalName); Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", Info.PowerupSpeech, self.Owner.Faction.InternalName);
if (Info.PowerdownSpeech != null && !poweredDown) if (Info.PowerdownSpeech != null && !isPoweredDown)
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", Info.PowerdownSpeech, self.Owner.Faction.InternalName); Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", Info.PowerdownSpeech, self.Owner.Faction.InternalName);
Update(self); Update(self);
@@ -97,7 +97,7 @@ namespace OpenRA.Mods.Common.Traits
int IPowerModifier.GetPowerModifier() int IPowerModifier.GetPowerModifier()
{ {
return !IsTraitDisabled && poweredDown ? 0 : 100; return !IsTraitDisabled && isPoweredDown ? 0 : 100;
} }
void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
@@ -107,10 +107,10 @@ namespace OpenRA.Mods.Common.Traits
protected override void TraitDisabled(Actor self) protected override void TraitDisabled(Actor self)
{ {
if (!poweredDown || !Info.CancelWhenDisabled) if (!isPoweredDown || !Info.CancelWhenDisabled)
return; return;
poweredDown = false; isPoweredDown = false;
if (Info.PowerupSound != null) if (Info.PowerupSound != null)
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Sound", Info.PowerupSound, self.Owner.Faction.InternalName); Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Sound", Info.PowerupSound, self.Owner.Faction.InternalName);

View File

@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Traits
public int PowerOutageTotalTicks { get; private set; } public int PowerOutageTotalTicks { get; private set; }
int nextPowerAdviceTime = 0; int nextPowerAdviceTime = 0;
bool lowPower = false; bool isLowPower = false;
bool wasLowPower = false; bool wasLowPower = false;
bool wasHackEnabled; bool wasHackEnabled;
@@ -109,19 +109,19 @@ namespace OpenRA.Mods.Common.Traits
wasHackEnabled = devMode.UnlimitedPower; wasHackEnabled = devMode.UnlimitedPower;
} }
lowPower = ExcessPower < 0; isLowPower = ExcessPower < 0;
if (lowPower != wasLowPower) if (isLowPower != wasLowPower)
UpdateRequiresPowerActors(); UpdatePowerRequiringActors();
if (lowPower && !wasLowPower) if (isLowPower && !wasLowPower)
nextPowerAdviceTime = 0; nextPowerAdviceTime = 0;
wasLowPower = lowPower; wasLowPower = isLowPower;
if (--nextPowerAdviceTime <= 0) if (--nextPowerAdviceTime <= 0)
{ {
if (lowPower) if (isLowPower)
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.SpeechNotification, self.Owner.Faction.InternalName); Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.SpeechNotification, self.Owner.Faction.InternalName);
nextPowerAdviceTime = info.AdviceInterval; nextPowerAdviceTime = info.AdviceInterval;
@@ -156,7 +156,7 @@ namespace OpenRA.Mods.Common.Traits
p.Trait.UpdateStatus(p.Actor); p.Trait.UpdateStatus(p.Actor);
} }
void UpdateRequiresPowerActors() void UpdatePowerRequiringActors()
{ {
var traitPairs = self.World.ActorsWithTrait<INotifyPowerLevelChanged>() var traitPairs = self.World.ActorsWithTrait<INotifyPowerLevelChanged>()
.Where(p => !p.Actor.IsDead && p.Actor.IsInWorld && p.Actor.Owner == self.Owner); .Where(p => !p.Actor.IsDead && p.Actor.IsInWorld && p.Actor.Owner == self.Owner);