Add CarryableConditions to Carryall.

This commit is contained in:
Mustafa Alperen Seki
2021-12-11 20:48:39 +03:00
committed by Matthias Mailänder
parent b67954451a
commit 3c60a515f7

View File

@@ -66,12 +66,20 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Condition to grant to the Carryall while it is carrying something.")] [Desc("Condition to grant to the Carryall while it is carrying something.")]
public readonly string CarryCondition = null; public readonly string CarryCondition = null;
[ActorReference(dictionaryReference: LintDictionaryReference.Keys)]
[Desc("Conditions to grant when a specified actor is being carried.",
"A dictionary of [actor id]: [condition].")]
public readonly Dictionary<string, string> CarryableConditions = new Dictionary<string, string>();
[VoiceReference] [VoiceReference]
public readonly string Voice = "Action"; public readonly string Voice = "Action";
[Desc("Color to use for the target line.")] [Desc("Color to use for the target line.")]
public readonly Color TargetLineColor = Color.Yellow; public readonly Color TargetLineColor = Color.Yellow;
[GrantedConditionReference]
public IEnumerable<string> LinterCarryableConditions => CarryableConditions.Values;
public override object Create(ActorInitializer init) { return new Carryall(init.Self, this); } public override object Create(ActorInitializer init) { return new Carryall(init.Self, this); }
} }
@@ -102,6 +110,7 @@ namespace OpenRA.Mods.Common.Traits
IActorPreview[] carryablePreview; IActorPreview[] carryablePreview;
HashSet<string> landableTerrainTypes; HashSet<string> landableTerrainTypes;
int carryConditionToken = Actor.InvalidConditionToken; int carryConditionToken = Actor.InvalidConditionToken;
int carryableConditionToken = Actor.InvalidConditionToken;
/// <summary>Offset between the carryall's and the carried actor's CenterPositions</summary> /// <summary>Offset between the carryall's and the carried actor's CenterPositions</summary>
public WVec CarryableOffset { get; private set; } public WVec CarryableOffset { get; private set; }
@@ -209,6 +218,9 @@ namespace OpenRA.Mods.Common.Traits
if (carryConditionToken == Actor.InvalidConditionToken) if (carryConditionToken == Actor.InvalidConditionToken)
carryConditionToken = self.GrantCondition(Info.CarryCondition); carryConditionToken = self.GrantCondition(Info.CarryCondition);
if (Info.CarryableConditions.TryGetValue(carryable.Info.Name, out var carryableCondition))
carryableConditionToken = self.GrantCondition(carryableCondition);
CarryableOffset = OffsetForCarryable(self, carryable); CarryableOffset = OffsetForCarryable(self, carryable);
landableTerrainTypes = Carryable.Trait<Mobile>().Info.LocomotorInfo.TerrainSpeeds.Keys.ToHashSet(); landableTerrainTypes = Carryable.Trait<Mobile>().Info.LocomotorInfo.TerrainSpeeds.Keys.ToHashSet();
@@ -222,6 +234,9 @@ namespace OpenRA.Mods.Common.Traits
if (carryConditionToken != Actor.InvalidConditionToken) if (carryConditionToken != Actor.InvalidConditionToken)
carryConditionToken = self.RevokeCondition(carryConditionToken); carryConditionToken = self.RevokeCondition(carryConditionToken);
if (carryableConditionToken != Actor.InvalidConditionToken)
carryableConditionToken = self.RevokeCondition(carryableConditionToken);
carryablePreview = null; carryablePreview = null;
landableTerrainTypes = null; landableTerrainTypes = null;
CarryableOffset = WVec.Zero; CarryableOffset = WVec.Zero;