Add Cargo.LoadedCondition.
This commit is contained in:
@@ -59,6 +59,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("The condition to grant to self while waiting for cargo to load.")]
|
[Desc("The condition to grant to self while waiting for cargo to load.")]
|
||||||
public readonly string LoadingCondition = null;
|
public readonly string LoadingCondition = null;
|
||||||
|
|
||||||
|
[UpgradeGrantedReference]
|
||||||
|
[Desc("The condition to grant to self while passengers are loaded.",
|
||||||
|
"Condition can stack with multiple passengers.")]
|
||||||
|
public readonly string LoadedCondition = null;
|
||||||
|
|
||||||
[UpgradeGrantedReference]
|
[UpgradeGrantedReference]
|
||||||
[Desc("Conditions to grant when specified actors are loaded inside the transport.",
|
[Desc("Conditions to grant when specified actors are loaded inside the transport.",
|
||||||
"A dictionary of [actor id]: [condition].")]
|
"A dictionary of [actor id]: [condition].")]
|
||||||
@@ -83,6 +88,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
Aircraft aircraft;
|
Aircraft aircraft;
|
||||||
UpgradeManager upgradeManager;
|
UpgradeManager upgradeManager;
|
||||||
int loadingToken = UpgradeManager.InvalidConditionToken;
|
int loadingToken = UpgradeManager.InvalidConditionToken;
|
||||||
|
Stack<int> loadedTokens = new Stack<int>();
|
||||||
|
|
||||||
CPos currentCell;
|
CPos currentCell;
|
||||||
public IEnumerable<CPos> CurrentAdjacentCells { get; private set; }
|
public IEnumerable<CPos> CurrentAdjacentCells { get; private set; }
|
||||||
@@ -260,6 +266,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
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());
|
upgradeManager.RevokeCondition(self, passengerToken.Pop());
|
||||||
|
|
||||||
|
if (loadedTokens.Any())
|
||||||
|
upgradeManager.RevokeCondition(self, loadedTokens.Pop());
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,6 +334,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
string passengerCondition;
|
string passengerCondition;
|
||||||
if (upgradeManager != null && Info.PassengerConditions.TryGetValue(a.Info.Name, out passengerCondition))
|
if (upgradeManager != 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(upgradeManager.GrantCondition(self, passengerCondition));
|
||||||
|
|
||||||
|
if (upgradeManager != null && !string.IsNullOrEmpty(Info.LoadedCondition))
|
||||||
|
loadedTokens.Push(upgradeManager.GrantCondition(self, Info.LoadedCondition));
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyKilled.Killed(Actor self, AttackInfo e)
|
void INotifyKilled.Killed(Actor self, AttackInfo e)
|
||||||
|
|||||||
Reference in New Issue
Block a user