Rename ConditionManager variables.

This commit is contained in:
Paul Chote
2016-12-23 15:02:52 +00:00
parent dcad5c3f7c
commit f360c10569
21 changed files with 123 additions and 123 deletions

View File

@@ -22,13 +22,13 @@ namespace OpenRA.Mods.Common.Scripting
[ScriptPropertyGroup("General")] [ScriptPropertyGroup("General")]
public class ConditionProperties : ScriptActorProperties, Requires<ConditionManagerInfo> public class ConditionProperties : ScriptActorProperties, Requires<ConditionManagerInfo>
{ {
readonly ConditionManager um; readonly ConditionManager conditionManager;
readonly Dictionary<string, Stack<int>> legacyShim = new Dictionary<string, Stack<int>>(); readonly Dictionary<string, Stack<int>> legacyShim = new Dictionary<string, Stack<int>>();
public ConditionProperties(ScriptContext context, Actor self) public ConditionProperties(ScriptContext context, Actor self)
: base(context, self) : base(context, self)
{ {
um = self.Trait<ConditionManager>(); conditionManager = self.Trait<ConditionManager>();
} }
[Desc("Grant an external condition on this actor and return the revocation token.", [Desc("Grant an external condition on this actor and return the revocation token.",
@@ -36,22 +36,22 @@ namespace OpenRA.Mods.Common.Scripting
"If duration > 0 the condition will be automatically revoked after the defined number of ticks")] "If duration > 0 the condition will be automatically revoked after the defined number of ticks")]
public int GrantCondition(string condition, int duration = 0) public int GrantCondition(string condition, int duration = 0)
{ {
if (!um.AcceptsExternalCondition(Self, condition)) if (!conditionManager.AcceptsExternalCondition(Self, condition))
throw new InvalidDataException("Condition `{0}` has not been listed on an ExternalConditions trait".F(condition)); throw new InvalidDataException("Condition `{0}` has not been listed on an ExternalConditions trait".F(condition));
return um.GrantCondition(Self, condition, true, duration); return conditionManager.GrantCondition(Self, condition, true, duration);
} }
[Desc("Revoke a condition using the token returned by GrantCondition.")] [Desc("Revoke a condition using the token returned by GrantCondition.")]
public void RevokeCondition(int token) public void RevokeCondition(int token)
{ {
um.RevokeCondition(Self, token); conditionManager.RevokeCondition(Self, token);
} }
[Desc("Check whether this actor accepts a specific external condition.")] [Desc("Check whether this actor accepts a specific external condition.")]
public bool AcceptsCondition(string condition) public bool AcceptsCondition(string condition)
{ {
return um.AcceptsExternalCondition(Self, condition); return conditionManager.AcceptsExternalCondition(Self, condition);
} }
[Desc("Grant an upgrade to this actor. DEPRECATED! Will be removed.")] [Desc("Grant an upgrade to this actor. DEPRECATED! Will be removed.")]

View File

@@ -105,7 +105,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly AircraftInfo Info; public readonly AircraftInfo Info;
readonly Actor self; readonly Actor self;
ConditionManager um; ConditionManager conditionManager;
IDisposable reservation; IDisposable reservation;
IEnumerable<int> speedModifiers; IEnumerable<int> speedModifiers;
@@ -146,7 +146,7 @@ namespace OpenRA.Mods.Common.Traits
public void Created(Actor self) public void Created(Actor self)
{ {
um = self.TraitOrDefault<ConditionManager>(); conditionManager = self.TraitOrDefault<ConditionManager>();
speedModifiers = self.TraitsImplementing<ISpeedModifier>().ToArray().Select(sm => sm.GetSpeedModifier()); speedModifiers = self.TraitsImplementing<ISpeedModifier>().ToArray().Select(sm => sm.GetSpeedModifier());
cachedPosition = self.CenterPosition; cachedPosition = self.CenterPosition;
} }
@@ -669,8 +669,8 @@ namespace OpenRA.Mods.Common.Traits
return; return;
airborne = true; airborne = true;
if (um != null && !string.IsNullOrEmpty(Info.AirborneCondition) && airborneToken == ConditionManager.InvalidConditionToken) if (conditionManager != null && !string.IsNullOrEmpty(Info.AirborneCondition) && airborneToken == ConditionManager.InvalidConditionToken)
airborneToken = um.GrantCondition(self, Info.AirborneCondition); airborneToken = conditionManager.GrantCondition(self, Info.AirborneCondition);
} }
void OnAirborneAltitudeLeft() void OnAirborneAltitudeLeft()
@@ -679,8 +679,8 @@ namespace OpenRA.Mods.Common.Traits
return; return;
airborne = false; airborne = false;
if (um != null && airborneToken != ConditionManager.InvalidConditionToken) if (conditionManager != null && airborneToken != ConditionManager.InvalidConditionToken)
airborneToken = um.RevokeCondition(self, airborneToken); airborneToken = conditionManager.RevokeCondition(self, airborneToken);
} }
#endregion #endregion
@@ -693,8 +693,8 @@ namespace OpenRA.Mods.Common.Traits
return; return;
cruising = true; cruising = true;
if (um != null && !string.IsNullOrEmpty(Info.CruisingCondition) && cruisingToken == ConditionManager.InvalidConditionToken) if (conditionManager != null && !string.IsNullOrEmpty(Info.CruisingCondition) && cruisingToken == ConditionManager.InvalidConditionToken)
cruisingToken = um.GrantCondition(self, Info.CruisingCondition); cruisingToken = conditionManager.GrantCondition(self, Info.CruisingCondition);
} }
void OnCruisingAltitudeLeft() void OnCruisingAltitudeLeft()
@@ -702,8 +702,8 @@ namespace OpenRA.Mods.Common.Traits
if (!cruising) if (!cruising)
return; return;
cruising = false; cruising = false;
if (um != null && cruisingToken != ConditionManager.InvalidConditionToken) if (conditionManager != null && cruisingToken != ConditionManager.InvalidConditionToken)
cruisingToken = um.RevokeCondition(self, cruisingToken); cruisingToken = conditionManager.RevokeCondition(self, cruisingToken);
} }
#endregion #endregion

View File

@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Traits
public class PrimaryBuilding : INotifyCreated, IIssueOrder, IResolveOrder public class PrimaryBuilding : INotifyCreated, IIssueOrder, IResolveOrder
{ {
readonly PrimaryBuildingInfo info; readonly PrimaryBuildingInfo info;
ConditionManager um; ConditionManager conditionManager;
int primaryToken = ConditionManager.InvalidConditionToken; int primaryToken = ConditionManager.InvalidConditionToken;
public bool IsPrimary { get; private set; } public bool IsPrimary { get; private set; }
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Traits
void INotifyCreated.Created(Actor self) void INotifyCreated.Created(Actor self)
{ {
um = self.TraitOrDefault<ConditionManager>(); conditionManager = self.TraitOrDefault<ConditionManager>();
} }
IEnumerable<IOrderTargeter> IIssueOrder.Orders IEnumerable<IOrderTargeter> IIssueOrder.Orders
@@ -95,13 +95,13 @@ namespace OpenRA.Mods.Common.Traits
b.Trait.SetPrimaryProducer(b.Actor, false); b.Trait.SetPrimaryProducer(b.Actor, false);
} }
if (um != null && primaryToken == ConditionManager.InvalidConditionToken && !string.IsNullOrEmpty(info.PrimaryCondition)) if (conditionManager != null && primaryToken == ConditionManager.InvalidConditionToken && !string.IsNullOrEmpty(info.PrimaryCondition))
primaryToken = um.GrantCondition(self, info.PrimaryCondition); primaryToken = conditionManager.GrantCondition(self, info.PrimaryCondition);
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.SelectionNotification, self.Owner.Faction.InternalName); Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.SelectionNotification, self.Owner.Faction.InternalName);
} }
else if (primaryToken != ConditionManager.InvalidConditionToken) else if (primaryToken != ConditionManager.InvalidConditionToken)
primaryToken = um.RevokeCondition(self, primaryToken); primaryToken = conditionManager.RevokeCondition(self, primaryToken);
} }
} }
} }

View File

@@ -88,7 +88,7 @@ namespace OpenRA.Mods.Common.Traits
int totalWeight = 0; int totalWeight = 0;
int reservedWeight = 0; int reservedWeight = 0;
Aircraft aircraft; Aircraft aircraft;
ConditionManager upgradeManager; ConditionManager conditionManager;
int loadingToken = ConditionManager.InvalidConditionToken; int loadingToken = ConditionManager.InvalidConditionToken;
Stack<int> loadedTokens = new Stack<int>(); Stack<int> loadedTokens = new Stack<int>();
@@ -141,7 +141,7 @@ namespace OpenRA.Mods.Common.Traits
void INotifyCreated.Created(Actor self) void INotifyCreated.Created(Actor self)
{ {
aircraft = self.TraitOrDefault<Aircraft>(); aircraft = self.TraitOrDefault<Aircraft>();
upgradeManager = self.Trait<ConditionManager>(); conditionManager = self.Trait<ConditionManager>();
} }
static int GetWeight(Actor a) { return a.Info.TraitInfo<PassengerInfo>().Weight; } static int GetWeight(Actor a) { return a.Info.TraitInfo<PassengerInfo>().Weight; }
@@ -208,8 +208,8 @@ namespace OpenRA.Mods.Common.Traits
if (!HasSpace(w)) if (!HasSpace(w))
return false; return false;
if (upgradeManager != null && loadingToken == ConditionManager.InvalidConditionToken && !string.IsNullOrEmpty(Info.LoadingCondition)) if (conditionManager != null && loadingToken == ConditionManager.InvalidConditionToken && !string.IsNullOrEmpty(Info.LoadingCondition))
loadingToken = upgradeManager.GrantCondition(self, Info.LoadingCondition); loadingToken = conditionManager.GrantCondition(self, Info.LoadingCondition);
reserves.Add(a); reserves.Add(a);
reservedWeight += w; reservedWeight += w;
@@ -226,7 +226,7 @@ namespace OpenRA.Mods.Common.Traits
reserves.Remove(a); reserves.Remove(a);
if (loadingToken != ConditionManager.InvalidConditionToken) if (loadingToken != ConditionManager.InvalidConditionToken)
loadingToken = upgradeManager.RevokeCondition(self, loadingToken); loadingToken = conditionManager.RevokeCondition(self, loadingToken);
} }
public string CursorForOrder(Actor self, Order order) public string CursorForOrder(Actor self, Order order)
@@ -266,10 +266,10 @@ namespace OpenRA.Mods.Common.Traits
Stack<int> passengerToken; Stack<int> passengerToken;
if (passengerTokens.TryGetValue(a.Info.Name, out passengerToken) && passengerToken.Any()) if (passengerTokens.TryGetValue(a.Info.Name, out passengerToken) && passengerToken.Any())
upgradeManager.RevokeCondition(self, passengerToken.Pop()); conditionManager.RevokeCondition(self, passengerToken.Pop());
if (loadedTokens.Any()) if (loadedTokens.Any())
upgradeManager.RevokeCondition(self, loadedTokens.Pop()); conditionManager.RevokeCondition(self, loadedTokens.Pop());
return a; return a;
} }
@@ -322,7 +322,7 @@ namespace OpenRA.Mods.Common.Traits
reserves.Remove(a); reserves.Remove(a);
if (loadingToken != ConditionManager.InvalidConditionToken) if (loadingToken != ConditionManager.InvalidConditionToken)
loadingToken = upgradeManager.RevokeCondition(self, loadingToken); loadingToken = conditionManager.RevokeCondition(self, loadingToken);
} }
// If not initialized then this will be notified in the first tick // If not initialized then this will be notified in the first tick
@@ -334,11 +334,11 @@ namespace OpenRA.Mods.Common.Traits
p.Transport = self; p.Transport = self;
string passengerCondition; string passengerCondition;
if (upgradeManager != null && Info.PassengerConditions.TryGetValue(a.Info.Name, out passengerCondition)) if (conditionManager != null && Info.PassengerConditions.TryGetValue(a.Info.Name, out passengerCondition))
passengerTokens.GetOrAdd(a.Info.Name).Push(upgradeManager.GrantCondition(self, passengerCondition)); passengerTokens.GetOrAdd(a.Info.Name).Push(conditionManager.GrantCondition(self, passengerCondition));
if (upgradeManager != null && !string.IsNullOrEmpty(Info.LoadedCondition)) if (conditionManager != null && !string.IsNullOrEmpty(Info.LoadedCondition))
loadedTokens.Push(upgradeManager.GrantCondition(self, Info.LoadedCondition)); loadedTokens.Push(conditionManager.GrantCondition(self, Info.LoadedCondition));
} }
void INotifyKilled.Killed(Actor self, AttackInfo e) void INotifyKilled.Killed(Actor self, AttackInfo e)

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Traits
public class Carryable : UpgradableTrait<CarryableInfo> public class Carryable : UpgradableTrait<CarryableInfo>
{ {
ConditionManager upgradeManager; ConditionManager conditionManager;
int reservedToken = ConditionManager.InvalidConditionToken; int reservedToken = ConditionManager.InvalidConditionToken;
int carriedToken = ConditionManager.InvalidConditionToken; int carriedToken = ConditionManager.InvalidConditionToken;
@@ -51,7 +51,7 @@ namespace OpenRA.Mods.Common.Traits
protected override void Created(Actor self) protected override void Created(Actor self)
{ {
upgradeManager = self.Trait<ConditionManager>(); conditionManager = self.Trait<ConditionManager>();
base.Created(self); base.Created(self);
} }
@@ -64,7 +64,7 @@ namespace OpenRA.Mods.Common.Traits
attached = true; attached = true;
if (carriedToken == ConditionManager.InvalidConditionToken && !string.IsNullOrEmpty(Info.CarriedCondition)) if (carriedToken == ConditionManager.InvalidConditionToken && !string.IsNullOrEmpty(Info.CarriedCondition))
carriedToken = upgradeManager.GrantCondition(self, Info.CarriedCondition); carriedToken = conditionManager.GrantCondition(self, Info.CarriedCondition);
} }
// This gets called by carrier after we touched down // This gets called by carrier after we touched down
@@ -76,7 +76,7 @@ namespace OpenRA.Mods.Common.Traits
attached = false; attached = false;
if (carriedToken != ConditionManager.InvalidConditionToken) if (carriedToken != ConditionManager.InvalidConditionToken)
carriedToken = upgradeManager.RevokeCondition(self, carriedToken); carriedToken = conditionManager.RevokeCondition(self, carriedToken);
} }
public virtual bool Reserve(Actor self, Actor carrier) public virtual bool Reserve(Actor self, Actor carrier)
@@ -88,7 +88,7 @@ namespace OpenRA.Mods.Common.Traits
Carrier = carrier; Carrier = carrier;
if (reservedToken == ConditionManager.InvalidConditionToken && !string.IsNullOrEmpty(Info.ReservedCondition)) if (reservedToken == ConditionManager.InvalidConditionToken && !string.IsNullOrEmpty(Info.ReservedCondition))
reservedToken = upgradeManager.GrantCondition(self, Info.ReservedCondition); reservedToken = conditionManager.GrantCondition(self, Info.ReservedCondition);
return true; return true;
} }
@@ -99,7 +99,7 @@ namespace OpenRA.Mods.Common.Traits
Carrier = null; Carrier = null;
if (reservedToken != ConditionManager.InvalidConditionToken) if (reservedToken != ConditionManager.InvalidConditionToken)
reservedToken = upgradeManager.RevokeCondition(self, reservedToken); reservedToken = conditionManager.RevokeCondition(self, reservedToken);
} }
// Prepare for transport pickup // Prepare for transport pickup

View File

@@ -66,7 +66,7 @@ namespace OpenRA.Mods.Common.Traits
[Sync] int remainingTime; [Sync] int remainingTime;
[Sync] bool damageDisabled; [Sync] bool damageDisabled;
bool isDocking; bool isDocking;
ConditionManager upgradeManager; ConditionManager conditionManager;
CPos? lastPos; CPos? lastPos;
bool wasCloaked = false; bool wasCloaked = false;
@@ -80,13 +80,13 @@ namespace OpenRA.Mods.Common.Traits
void INotifyCreated.Created(Actor self) void INotifyCreated.Created(Actor self)
{ {
upgradeManager = self.TraitOrDefault<ConditionManager>(); conditionManager = self.TraitOrDefault<ConditionManager>();
if (Cloaked) if (Cloaked)
{ {
wasCloaked = true; wasCloaked = true;
if (upgradeManager != null && cloakedToken == ConditionManager.InvalidConditionToken && !string.IsNullOrEmpty(Info.CloakedCondition)) if (conditionManager != null && cloakedToken == ConditionManager.InvalidConditionToken && !string.IsNullOrEmpty(Info.CloakedCondition))
cloakedToken = upgradeManager.GrantCondition(self, Info.CloakedCondition); cloakedToken = conditionManager.GrantCondition(self, Info.CloakedCondition);
} }
} }
@@ -144,8 +144,8 @@ namespace OpenRA.Mods.Common.Traits
var isCloaked = Cloaked; var isCloaked = Cloaked;
if (isCloaked && !wasCloaked) if (isCloaked && !wasCloaked)
{ {
if (upgradeManager != null && cloakedToken == ConditionManager.InvalidConditionToken && !string.IsNullOrEmpty(Info.CloakedCondition)) if (conditionManager != null && cloakedToken == ConditionManager.InvalidConditionToken && !string.IsNullOrEmpty(Info.CloakedCondition))
cloakedToken = upgradeManager.GrantCondition(self, Info.CloakedCondition); cloakedToken = conditionManager.GrantCondition(self, Info.CloakedCondition);
if (!self.TraitsImplementing<Cloak>().Any(a => a != this && a.Cloaked)) if (!self.TraitsImplementing<Cloak>().Any(a => a != this && a.Cloaked))
Game.Sound.Play(SoundType.World, Info.CloakSound, self.CenterPosition); Game.Sound.Play(SoundType.World, Info.CloakSound, self.CenterPosition);
@@ -153,7 +153,7 @@ namespace OpenRA.Mods.Common.Traits
else if (!isCloaked && wasCloaked) else if (!isCloaked && wasCloaked)
{ {
if (cloakedToken != ConditionManager.InvalidConditionToken) if (cloakedToken != ConditionManager.InvalidConditionToken)
cloakedToken = upgradeManager.RevokeCondition(self, cloakedToken); cloakedToken = conditionManager.RevokeCondition(self, cloakedToken);
if (!self.TraitsImplementing<Cloak>().Any(a => a != this && a.Cloaked)) if (!self.TraitsImplementing<Cloak>().Any(a => a != this && a.Cloaked))
Game.Sound.Play(SoundType.World, Info.UncloakSound, self.CenterPosition); Game.Sound.Play(SoundType.World, Info.UncloakSound, self.CenterPosition);

View File

@@ -47,8 +47,8 @@ namespace OpenRA.Mods.Common.Traits
bool AcceptsCondition(Actor a) bool AcceptsCondition(Actor a)
{ {
var um = a.TraitOrDefault<ConditionManager>(); var cm = a.TraitOrDefault<ConditionManager>();
return um != null && um.AcceptsExternalCondition(a, info.Condition); return cm != null && cm.AcceptsExternalCondition(a, info.Condition);
} }
public override int GetSelectionShares(Actor collector) public override int GetSelectionShares(Actor collector)
@@ -71,11 +71,11 @@ namespace OpenRA.Mods.Common.Traits
if (!a.IsInWorld || a.IsDead) if (!a.IsInWorld || a.IsDead)
continue; continue;
var um = a.TraitOrDefault<ConditionManager>(); var cm = a.TraitOrDefault<ConditionManager>();
// Condition token is ignored because we never revoke this condition. // Condition token is ignored because we never revoke this condition.
if (um != null) if (cm != null)
um.GrantCondition(a, info.Condition, true, info.Duration); cm.GrantCondition(a, info.Condition, true, info.Duration);
} }
}); });

View File

@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Traits
readonly int initialExperience; readonly int initialExperience;
readonly List<Pair<int, string>> nextLevel = new List<Pair<int, string>>(); readonly List<Pair<int, string>> nextLevel = new List<Pair<int, string>>();
ConditionManager um; ConditionManager conditionManager;
// Stored as a percentage of our value // Stored as a percentage of our value
[Sync] int experience = 0; [Sync] int experience = 0;
@@ -70,7 +70,7 @@ namespace OpenRA.Mods.Common.Traits
void INotifyCreated.Created(Actor self) void INotifyCreated.Created(Actor self)
{ {
um = self.TraitOrDefault<ConditionManager>(); conditionManager = self.TraitOrDefault<ConditionManager>();
if (initialExperience > 0) if (initialExperience > 0)
GiveExperience(initialExperience, info.SuppressLevelupAnimation); GiveExperience(initialExperience, info.SuppressLevelupAnimation);
} }
@@ -92,8 +92,8 @@ namespace OpenRA.Mods.Common.Traits
while (Level < MaxLevel && experience >= nextLevel[Level].First) while (Level < MaxLevel && experience >= nextLevel[Level].First)
{ {
if (um != null) if (conditionManager != null)
um.GrantCondition(self, nextLevel[Level].Second); conditionManager.GrantCondition(self, nextLevel[Level].Second);
Level++; Level++;

View File

@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Traits
readonly GrantConditionOnPrerequisiteInfo info; readonly GrantConditionOnPrerequisiteInfo info;
readonly GrantConditionOnPrerequisiteManager globalManager; readonly GrantConditionOnPrerequisiteManager globalManager;
ConditionManager manager; ConditionManager conditionManager;
int conditionToken = ConditionManager.InvalidConditionToken; int conditionToken = ConditionManager.InvalidConditionToken;
bool wasAvailable; bool wasAvailable;
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.Common.Traits
void INotifyCreated.Created(Actor self) void INotifyCreated.Created(Actor self)
{ {
manager = self.TraitOrDefault<ConditionManager>(); conditionManager = self.TraitOrDefault<ConditionManager>();
} }
void INotifyAddedToWorld.AddedToWorld(Actor self) void INotifyAddedToWorld.AddedToWorld(Actor self)
@@ -64,13 +64,13 @@ namespace OpenRA.Mods.Common.Traits
public void PrerequisitesUpdated(Actor self, bool available) public void PrerequisitesUpdated(Actor self, bool available)
{ {
if (available == wasAvailable || manager == null) if (available == wasAvailable || conditionManager == null)
return; return;
if (available && conditionToken == ConditionManager.InvalidConditionToken) if (available && conditionToken == ConditionManager.InvalidConditionToken)
conditionToken = manager.GrantCondition(self, info.Condition); conditionToken = conditionManager.GrantCondition(self, info.Condition);
else if (!available && conditionToken != ConditionManager.InvalidConditionToken) else if (!available && conditionToken != ConditionManager.InvalidConditionToken)
conditionToken = manager.RevokeCondition(self, conditionToken); conditionToken = conditionManager.RevokeCondition(self, conditionToken);
wasAvailable = available; wasAvailable = available;
} }

View File

@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Traits
readonly ParachutableInfo info; readonly ParachutableInfo info;
readonly IPositionable positionable; readonly IPositionable positionable;
ConditionManager um; ConditionManager conditionManager;
int parachutingToken = ConditionManager.InvalidConditionToken; int parachutingToken = ConditionManager.InvalidConditionToken;
public Parachutable(Actor self, ParachutableInfo info) public Parachutable(Actor self, ParachutableInfo info)
@@ -61,19 +61,19 @@ namespace OpenRA.Mods.Common.Traits
void INotifyCreated.Created(Actor self) void INotifyCreated.Created(Actor self)
{ {
um = self.TraitOrDefault<ConditionManager>(); conditionManager = self.TraitOrDefault<ConditionManager>();
} }
void INotifyParachute.OnParachute(Actor self) void INotifyParachute.OnParachute(Actor self)
{ {
if (um != null && parachutingToken == ConditionManager.InvalidConditionToken && !string.IsNullOrEmpty(info.ParachutingCondition)) if (conditionManager != null && parachutingToken == ConditionManager.InvalidConditionToken && !string.IsNullOrEmpty(info.ParachutingCondition))
parachutingToken = um.GrantCondition(self, info.ParachutingCondition); parachutingToken = conditionManager.GrantCondition(self, info.ParachutingCondition);
} }
void INotifyParachute.OnLanded(Actor self, Actor ignore) void INotifyParachute.OnLanded(Actor self, Actor ignore)
{ {
if (parachutingToken != ConditionManager.InvalidConditionToken) if (parachutingToken != ConditionManager.InvalidConditionToken)
parachutingToken = um.RevokeCondition(self, parachutingToken); parachutingToken = conditionManager.RevokeCondition(self, parachutingToken);
if (!info.KilledOnImpassableTerrain) if (!info.KilledOnImpassableTerrain)
return; return;

View File

@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly PluggableInfo Info; public readonly PluggableInfo Info;
readonly string initialPlug; readonly string initialPlug;
ConditionManager upgradeManager; ConditionManager conditionManager;
int conditionToken = ConditionManager.InvalidConditionToken; int conditionToken = ConditionManager.InvalidConditionToken;
string active; string active;
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Traits
public void Created(Actor self) public void Created(Actor self)
{ {
upgradeManager = self.TraitOrDefault<ConditionManager>(); conditionManager = self.TraitOrDefault<ConditionManager>();
if (!string.IsNullOrEmpty(initialPlug)) if (!string.IsNullOrEmpty(initialPlug))
EnablePlug(self, initialPlug); EnablePlug(self, initialPlug);
@@ -67,7 +67,7 @@ namespace OpenRA.Mods.Common.Traits
if (!Info.Conditions.TryGetValue(type, out condition)) if (!Info.Conditions.TryGetValue(type, out condition))
return; return;
conditionToken = upgradeManager.GrantCondition(self, condition); conditionToken = conditionManager.GrantCondition(self, condition);
active = type; active = type;
} }
@@ -77,7 +77,7 @@ namespace OpenRA.Mods.Common.Traits
return; return;
if (conditionToken != ConditionManager.InvalidConditionToken) if (conditionToken != ConditionManager.InvalidConditionToken)
conditionToken = upgradeManager.RevokeCondition(self, conditionToken); conditionToken = conditionManager.RevokeCondition(self, conditionToken);
active = null; active = null;
} }

View File

@@ -69,11 +69,11 @@ namespace OpenRA.Mods.Common.Traits
foreach (var a in UnitsInRange(order.TargetLocation)) foreach (var a in UnitsInRange(order.TargetLocation))
{ {
var um = a.TraitOrDefault<ConditionManager>(); var cm = a.TraitOrDefault<ConditionManager>();
// Condition token is ignored because we never revoke this condition. // Condition token is ignored because we never revoke this condition.
if (um != null) if (cm != null)
um.GrantCondition(a, info.Condition, true, info.Duration); cm.GrantCondition(a, info.Condition, true, info.Duration);
} }
} }
@@ -90,8 +90,8 @@ namespace OpenRA.Mods.Common.Traits
if (!a.Owner.IsAlliedWith(Self.Owner)) if (!a.Owner.IsAlliedWith(Self.Owner))
return false; return false;
var um = a.TraitOrDefault<ConditionManager>(); var cm = a.TraitOrDefault<ConditionManager>();
return um != null && um.AcceptsExternalCondition(a, info.Condition); return cm != null && cm.AcceptsExternalCondition(a, info.Condition);
}); });
} }

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits
class GrantCondition : UpgradableTrait<GrantConditionInfo> class GrantCondition : UpgradableTrait<GrantConditionInfo>
{ {
ConditionManager manager; ConditionManager conditionManager;
int conditionToken = ConditionManager.InvalidConditionToken; int conditionToken = ConditionManager.InvalidConditionToken;
public GrantCondition(GrantConditionInfo info) public GrantCondition(GrantConditionInfo info)
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Traits
protected override void Created(Actor self) protected override void Created(Actor self)
{ {
manager = self.Trait<ConditionManager>(); conditionManager = self.Trait<ConditionManager>();
base.Created(self); base.Created(self);
} }
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Traits
protected override void TraitEnabled(Actor self) protected override void TraitEnabled(Actor self)
{ {
if (conditionToken == ConditionManager.InvalidConditionToken) if (conditionToken == ConditionManager.InvalidConditionToken)
conditionToken = manager.GrantCondition(self, Info.Condition); conditionToken = conditionManager.GrantCondition(self, Info.Condition);
} }
protected override void TraitDisabled(Actor self) protected override void TraitDisabled(Actor self)
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Traits
if (conditionToken == ConditionManager.InvalidConditionToken) if (conditionToken == ConditionManager.InvalidConditionToken)
return; return;
conditionToken = manager.RevokeCondition(self, conditionToken); conditionToken = conditionManager.RevokeCondition(self, conditionToken);
} }
} }
} }

View File

@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Traits
readonly GrantConditionOnDamageStateInfo info; readonly GrantConditionOnDamageStateInfo info;
readonly Health health; readonly Health health;
ConditionManager manager; ConditionManager conditionManager;
int conditionToken = ConditionManager.InvalidConditionToken; int conditionToken = ConditionManager.InvalidConditionToken;
public GrantConditionOnDamageState(Actor self, GrantConditionOnDamageStateInfo info) public GrantConditionOnDamageState(Actor self, GrantConditionOnDamageStateInfo info)
@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Traits
void INotifyCreated.Created(Actor self) void INotifyCreated.Created(Actor self)
{ {
manager = self.TraitOrDefault<ConditionManager>(); conditionManager = self.TraitOrDefault<ConditionManager>();
GrantUpgradeOnValidDamageState(self, health.DamageState); GrantUpgradeOnValidDamageState(self, health.DamageState);
} }
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Traits
if (!info.ValidDamageStates.HasFlag(state) || conditionToken != ConditionManager.InvalidConditionToken) if (!info.ValidDamageStates.HasFlag(state) || conditionToken != ConditionManager.InvalidConditionToken)
return; return;
conditionToken = manager.GrantCondition(self, info.Condition); conditionToken = conditionManager.GrantCondition(self, info.Condition);
var sound = info.EnabledSounds.RandomOrDefault(Game.CosmeticRandom); var sound = info.EnabledSounds.RandomOrDefault(Game.CosmeticRandom);
Game.Sound.Play(SoundType.World, sound, self.CenterPosition); Game.Sound.Play(SoundType.World, sound, self.CenterPosition);
@@ -70,14 +70,14 @@ namespace OpenRA.Mods.Common.Traits
void INotifyDamageStateChanged.DamageStateChanged(Actor self, AttackInfo e) void INotifyDamageStateChanged.DamageStateChanged(Actor self, AttackInfo e)
{ {
var granted = conditionToken != ConditionManager.InvalidConditionToken; var granted = conditionToken != ConditionManager.InvalidConditionToken;
if ((granted && info.GrantPermanently) || manager == null) if ((granted && info.GrantPermanently) || conditionManager == null)
return; return;
if (!granted && !info.ValidDamageStates.HasFlag(e.PreviousDamageState)) if (!granted && !info.ValidDamageStates.HasFlag(e.PreviousDamageState))
GrantUpgradeOnValidDamageState(self, health.DamageState); GrantUpgradeOnValidDamageState(self, health.DamageState);
else if (granted && !info.ValidDamageStates.HasFlag(e.DamageState) && info.ValidDamageStates.HasFlag(e.PreviousDamageState)) else if (granted && !info.ValidDamageStates.HasFlag(e.DamageState) && info.ValidDamageStates.HasFlag(e.PreviousDamageState))
{ {
conditionToken = manager.RevokeCondition(self, conditionToken); conditionToken = conditionManager.RevokeCondition(self, conditionToken);
var sound = info.DisabledSounds.RandomOrDefault(Game.CosmeticRandom); var sound = info.DisabledSounds.RandomOrDefault(Game.CosmeticRandom);
Game.Sound.Play(SoundType.World, sound, self.CenterPosition); Game.Sound.Play(SoundType.World, sound, self.CenterPosition);

View File

@@ -72,7 +72,7 @@ namespace OpenRA.Mods.Common.Traits
readonly Lazy<WithSpriteBody> body; readonly Lazy<WithSpriteBody> body;
DeployState deployState; DeployState deployState;
ConditionManager manager; ConditionManager conditionManager;
int deployedToken = ConditionManager.InvalidConditionToken; int deployedToken = ConditionManager.InvalidConditionToken;
int undeployedToken = ConditionManager.InvalidConditionToken; int undeployedToken = ConditionManager.InvalidConditionToken;
@@ -89,7 +89,7 @@ namespace OpenRA.Mods.Common.Traits
public void Created(Actor self) public void Created(Actor self)
{ {
manager = self.TraitOrDefault<ConditionManager>(); conditionManager = self.TraitOrDefault<ConditionManager>();
switch (deployState) switch (deployState)
{ {
@@ -244,15 +244,15 @@ namespace OpenRA.Mods.Common.Traits
void OnDeployStarted() void OnDeployStarted()
{ {
if (undeployedToken != ConditionManager.InvalidConditionToken) if (undeployedToken != ConditionManager.InvalidConditionToken)
undeployedToken = manager.RevokeCondition(self, undeployedToken); undeployedToken = conditionManager.RevokeCondition(self, undeployedToken);
deployState = DeployState.Deploying; deployState = DeployState.Deploying;
} }
void OnDeployCompleted() void OnDeployCompleted()
{ {
if (manager != null && !string.IsNullOrEmpty(info.DeployedCondition) && deployedToken == ConditionManager.InvalidConditionToken) if (conditionManager != null && !string.IsNullOrEmpty(info.DeployedCondition) && deployedToken == ConditionManager.InvalidConditionToken)
deployedToken = manager.GrantCondition(self, info.DeployedCondition); deployedToken = conditionManager.GrantCondition(self, info.DeployedCondition);
deployState = DeployState.Deployed; deployState = DeployState.Deployed;
} }
@@ -260,15 +260,15 @@ namespace OpenRA.Mods.Common.Traits
void OnUndeployStarted() void OnUndeployStarted()
{ {
if (deployedToken != ConditionManager.InvalidConditionToken) if (deployedToken != ConditionManager.InvalidConditionToken)
deployedToken = manager.RevokeCondition(self, deployedToken); deployedToken = conditionManager.RevokeCondition(self, deployedToken);
deployState = DeployState.Deploying; deployState = DeployState.Deploying;
} }
void OnUndeployCompleted() void OnUndeployCompleted()
{ {
if (manager != null && !string.IsNullOrEmpty(info.UndeployedCondition) && undeployedToken == ConditionManager.InvalidConditionToken) if (conditionManager != null && !string.IsNullOrEmpty(info.UndeployedCondition) && undeployedToken == ConditionManager.InvalidConditionToken)
undeployedToken = manager.GrantCondition(self, info.UndeployedCondition); undeployedToken = conditionManager.GrantCondition(self, info.UndeployedCondition);
deployState = DeployState.Undeployed; deployState = DeployState.Undeployed;
} }

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
readonly IMove movement; readonly IMove movement;
ConditionManager manager; ConditionManager conditionManager;
int conditionToken = ConditionManager.InvalidConditionToken; int conditionToken = ConditionManager.InvalidConditionToken;
public GrantConditionOnMovement(Actor self, GrantConditionOnMovementInfo info) public GrantConditionOnMovement(Actor self, GrantConditionOnMovementInfo info)
@@ -42,21 +42,21 @@ namespace OpenRA.Mods.Common.Traits
protected override void Created(Actor self) protected override void Created(Actor self)
{ {
manager = self.TraitOrDefault<ConditionManager>(); conditionManager = self.TraitOrDefault<ConditionManager>();
base.Created(self); base.Created(self);
} }
void ITick.Tick(Actor self) void ITick.Tick(Actor self)
{ {
if (manager == null) if (conditionManager == null)
return; return;
var isMovingVertically = Info.ConsiderVerticalMovement ? movement.IsMovingVertically : false; var isMovingVertically = Info.ConsiderVerticalMovement ? movement.IsMovingVertically : false;
var isMoving = !IsTraitDisabled && !self.IsDead && (movement.IsMoving || isMovingVertically); var isMoving = !IsTraitDisabled && !self.IsDead && (movement.IsMoving || isMovingVertically);
if (isMoving && conditionToken == ConditionManager.InvalidConditionToken) if (isMoving && conditionToken == ConditionManager.InvalidConditionToken)
conditionToken = manager.GrantCondition(self, Info.Condition); conditionToken = conditionManager.GrantCondition(self, Info.Condition);
else if (!isMoving && conditionToken != ConditionManager.InvalidConditionToken) else if (!isMoving && conditionToken != ConditionManager.InvalidConditionToken)
conditionToken = manager.RevokeCondition(self, conditionToken); conditionToken = conditionManager.RevokeCondition(self, conditionToken);
} }
} }
} }

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
readonly GrantConditionOnTerrainInfo info; readonly GrantConditionOnTerrainInfo info;
ConditionManager manager; ConditionManager conditionManager;
int conditionToken = ConditionManager.InvalidConditionToken; int conditionToken = ConditionManager.InvalidConditionToken;
string previousTerrain; string previousTerrain;
@@ -43,12 +43,12 @@ namespace OpenRA.Mods.Common.Traits
void INotifyCreated.Created(Actor self) void INotifyCreated.Created(Actor self)
{ {
manager = self.TraitOrDefault<ConditionManager>(); conditionManager = self.TraitOrDefault<ConditionManager>();
} }
public void Tick(Actor self) public void Tick(Actor self)
{ {
if (manager == null) if (conditionManager == null)
return; return;
var currentTerrain = self.World.Map.GetTerrainInfo(self.Location).Type; var currentTerrain = self.World.Map.GetTerrainInfo(self.Location).Type;
@@ -56,9 +56,9 @@ namespace OpenRA.Mods.Common.Traits
if (currentTerrain != previousTerrain) if (currentTerrain != previousTerrain)
{ {
if (wantsGranted && conditionToken == ConditionManager.InvalidConditionToken) if (wantsGranted && conditionToken == ConditionManager.InvalidConditionToken)
conditionToken = manager.GrantCondition(self, info.Condition); conditionToken = conditionManager.GrantCondition(self, info.Condition);
else if (!wantsGranted && conditionToken != ConditionManager.InvalidConditionToken) else if (!wantsGranted && conditionToken != ConditionManager.InvalidConditionToken)
conditionToken = manager.RevokeCondition(self, conditionToken); conditionToken = conditionManager.RevokeCondition(self, conditionToken);
} }
previousTerrain = currentTerrain; previousTerrain = currentTerrain;

View File

@@ -108,9 +108,9 @@ namespace OpenRA.Mods.Common.Traits
if (!info.ValidStances.HasStance(stance)) if (!info.ValidStances.HasStance(stance))
return; return;
var um = a.TraitOrDefault<ConditionManager>(); var cm = a.TraitOrDefault<ConditionManager>();
if (um != null && !tokens.ContainsKey(a) && um.AcceptsExternalCondition(a, info.Condition)) if (cm != null && !tokens.ContainsKey(a) && cm.AcceptsExternalCondition(a, info.Condition))
tokens[a] = um.GrantCondition(a, info.Condition, true); tokens[a] = cm.GrantCondition(a, info.Condition, true);
} }
public void UnitProducedByOther(Actor self, Actor producer, Actor produced) public void UnitProducedByOther(Actor self, Actor producer, Actor produced)
@@ -130,9 +130,9 @@ namespace OpenRA.Mods.Common.Traits
if (!info.ValidStances.HasStance(stance)) if (!info.ValidStances.HasStance(stance))
return; return;
var um = produced.TraitOrDefault<ConditionManager>(); var cm = produced.TraitOrDefault<ConditionManager>();
if (um != null && um.AcceptsExternalCondition(produced, info.Condition)) if (cm != null && cm.AcceptsExternalCondition(produced, info.Condition))
tokens[produced] = um.GrantCondition(produced, info.Condition, true); tokens[produced] = cm.GrantCondition(produced, info.Condition, true);
} }
} }
@@ -146,9 +146,9 @@ namespace OpenRA.Mods.Common.Traits
return; return;
tokens.Remove(a); tokens.Remove(a);
var um = a.TraitOrDefault<ConditionManager>(); var cm = a.TraitOrDefault<ConditionManager>();
if (um != null) if (cm != null)
um.RevokeCondition(a, token); cm.RevokeCondition(a, token);
} }
} }
} }

View File

@@ -36,11 +36,11 @@ namespace OpenRA.Mods.Common.Warheads
if (!IsValidAgainst(a, firedBy)) if (!IsValidAgainst(a, firedBy))
continue; continue;
var um = a.TraitOrDefault<ConditionManager>(); var cm = a.TraitOrDefault<ConditionManager>();
// Condition token is ignored because we never revoke this condition. // Condition token is ignored because we never revoke this condition.
if (um != null && um.AcceptsExternalCondition(a, Condition)) if (cm != null && cm.AcceptsExternalCondition(a, Condition))
um.GrantCondition(a, Condition, true, Duration); cm.GrantCondition(a, Condition, true, Duration);
} }
} }
} }

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.D2k.Activities
readonly Target target; readonly Target target;
readonly Sandworm sandworm; readonly Sandworm sandworm;
readonly ConditionManager manager; readonly ConditionManager conditionManager;
readonly WeaponInfo weapon; readonly WeaponInfo weapon;
readonly RadarPings radarPings; readonly RadarPings radarPings;
readonly AttackSwallow swallow; readonly AttackSwallow swallow;
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.D2k.Activities
sandworm = self.Trait<Sandworm>(); sandworm = self.Trait<Sandworm>();
positionable = self.Trait<Mobile>(); positionable = self.Trait<Mobile>();
swallow = self.Trait<AttackSwallow>(); swallow = self.Trait<AttackSwallow>();
manager = self.TraitOrDefault<ConditionManager>(); conditionManager = self.TraitOrDefault<ConditionManager>();
radarPings = self.World.WorldActor.TraitOrDefault<RadarPings>(); radarPings = self.World.WorldActor.TraitOrDefault<RadarPings>();
} }
@@ -109,9 +109,9 @@ namespace OpenRA.Mods.D2k.Activities
stance = AttackState.Burrowed; stance = AttackState.Burrowed;
countdown = swallow.Info.AttackDelay; countdown = swallow.Info.AttackDelay;
burrowLocation = self.Location; burrowLocation = self.Location;
if (manager != null && attackingToken == ConditionManager.InvalidConditionToken && if (conditionManager != null && attackingToken == ConditionManager.InvalidConditionToken &&
!string.IsNullOrEmpty(swallow.Info.AttackingCondition)) !string.IsNullOrEmpty(swallow.Info.AttackingCondition))
attackingToken = manager.GrantCondition(self, swallow.Info.AttackingCondition); attackingToken = conditionManager.GrantCondition(self, swallow.Info.AttackingCondition);
break; break;
case AttackState.Burrowed: case AttackState.Burrowed:
if (--countdown > 0) if (--countdown > 0)
@@ -171,7 +171,7 @@ namespace OpenRA.Mods.D2k.Activities
void RevokeCondition(Actor self) void RevokeCondition(Actor self)
{ {
if (attackingToken != ConditionManager.InvalidConditionToken) if (attackingToken != ConditionManager.InvalidConditionToken)
attackingToken = manager.RevokeCondition(self, attackingToken); attackingToken = conditionManager.RevokeCondition(self, attackingToken);
} }
} }
} }

View File

@@ -83,7 +83,7 @@ namespace OpenRA.Mods.RA.Traits
readonly Actor self; readonly Actor self;
readonly DisguiseInfo info; readonly DisguiseInfo info;
ConditionManager um; ConditionManager conditionManager;
int disguisedToken = ConditionManager.InvalidConditionToken; int disguisedToken = ConditionManager.InvalidConditionToken;
public Disguise(Actor self, DisguiseInfo info) public Disguise(Actor self, DisguiseInfo info)
@@ -94,7 +94,7 @@ namespace OpenRA.Mods.RA.Traits
void INotifyCreated.Created(Actor self) void INotifyCreated.Created(Actor self)
{ {
um = self.TraitOrDefault<ConditionManager>(); conditionManager = self.TraitOrDefault<ConditionManager>();
} }
public IEnumerable<IOrderTargeter> Orders public IEnumerable<IOrderTargeter> Orders
@@ -187,12 +187,12 @@ namespace OpenRA.Mods.RA.Traits
foreach (var t in self.TraitsImplementing<INotifyEffectiveOwnerChanged>()) foreach (var t in self.TraitsImplementing<INotifyEffectiveOwnerChanged>())
t.OnEffectiveOwnerChanged(self, oldEffectiveOwner, AsPlayer); t.OnEffectiveOwnerChanged(self, oldEffectiveOwner, AsPlayer);
if (Disguised != oldDisguiseSetting && um != null) if (Disguised != oldDisguiseSetting && conditionManager != null)
{ {
if (Disguised && disguisedToken == ConditionManager.InvalidConditionToken && !string.IsNullOrEmpty(info.DisguisedCondition)) if (Disguised && disguisedToken == ConditionManager.InvalidConditionToken && !string.IsNullOrEmpty(info.DisguisedCondition))
disguisedToken = um.GrantCondition(self, info.DisguisedCondition); disguisedToken = conditionManager.GrantCondition(self, info.DisguisedCondition);
else if (!Disguised && disguisedToken != ConditionManager.InvalidConditionToken) else if (!Disguised && disguisedToken != ConditionManager.InvalidConditionToken)
disguisedToken = um.RevokeCondition(self, disguisedToken); disguisedToken = conditionManager.RevokeCondition(self, disguisedToken);
} }
} }