Convert Disguise to conditions.
This commit is contained in:
@@ -596,6 +596,13 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
|
|
||||||
if (node.Key.StartsWith("Cloak", StringComparison.Ordinal))
|
if (node.Key.StartsWith("Cloak", StringComparison.Ordinal))
|
||||||
ConvertUpgradesToCondition(parent, node, "WhileCloakedUpgrades", "CloakedCondition");
|
ConvertUpgradesToCondition(parent, node, "WhileCloakedUpgrades", "CloakedCondition");
|
||||||
|
|
||||||
|
if (node.Key == "Disguise")
|
||||||
|
{
|
||||||
|
ConvertUpgradesToCondition(parent, node, "Upgrades", "DisguisedCondition");
|
||||||
|
if (!node.Value.Nodes.Any(n => n.Key == "DisguisedCondition"))
|
||||||
|
node.Value.Nodes.Add(new MiniYamlNode("DisguisedCondition", "disguise"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UpgradeActorRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1);
|
UpgradeActorRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||||
|
|||||||
@@ -65,13 +65,13 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
[VoiceReference] public readonly string Voice = "Action";
|
[VoiceReference] public readonly string Voice = "Action";
|
||||||
|
|
||||||
[UpgradeGrantedReference]
|
[UpgradeGrantedReference]
|
||||||
[Desc("Upgrades to grant when disguised.")]
|
[Desc("The condition to grant to self while disguised.")]
|
||||||
public readonly string[] Upgrades = { "disguise" };
|
public readonly string DisguisedCondition = null;
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new Disguise(init.Self, this); }
|
public object Create(ActorInitializer init) { return new Disguise(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class Disguise : IEffectiveOwner, IIssueOrder, IResolveOrder, IOrderVoice, IRadarColorModifier, INotifyAttack
|
class Disguise : INotifyCreated, IEffectiveOwner, IIssueOrder, IResolveOrder, IOrderVoice, IRadarColorModifier, INotifyAttack
|
||||||
{
|
{
|
||||||
public Player AsPlayer { get; private set; }
|
public Player AsPlayer { get; private set; }
|
||||||
public string AsSprite { get; private set; }
|
public string AsSprite { get; private set; }
|
||||||
@@ -82,14 +82,19 @@ namespace OpenRA.Mods.RA.Traits
|
|||||||
|
|
||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
readonly DisguiseInfo info;
|
readonly DisguiseInfo info;
|
||||||
readonly Lazy<UpgradeManager> um;
|
|
||||||
|
UpgradeManager um;
|
||||||
|
int disguisedToken = UpgradeManager.InvalidConditionToken;
|
||||||
|
|
||||||
public Disguise(Actor self, DisguiseInfo info)
|
public Disguise(Actor self, DisguiseInfo info)
|
||||||
{
|
{
|
||||||
this.self = self;
|
this.self = self;
|
||||||
this.info = info;
|
this.info = info;
|
||||||
|
}
|
||||||
|
|
||||||
um = Exts.Lazy(() => self.TraitOrDefault<UpgradeManager>());
|
void INotifyCreated.Created(Actor self)
|
||||||
|
{
|
||||||
|
um = self.TraitOrDefault<UpgradeManager>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<IOrderTargeter> Orders
|
public IEnumerable<IOrderTargeter> Orders
|
||||||
@@ -182,18 +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.Value != null)
|
if (Disguised != oldDisguiseSetting && um != null)
|
||||||
{
|
{
|
||||||
foreach (var u in info.Upgrades)
|
if (Disguised && disguisedToken == UpgradeManager.InvalidConditionToken && !string.IsNullOrEmpty(info.DisguisedCondition))
|
||||||
{
|
disguisedToken = um.GrantCondition(self, info.DisguisedCondition);
|
||||||
if (!um.Value.AcknowledgesUpgrade(self, u))
|
else if (!Disguised && disguisedToken != UpgradeManager.InvalidConditionToken)
|
||||||
continue;
|
disguisedToken = um.RevokeCondition(self, disguisedToken);
|
||||||
|
|
||||||
if (Disguised)
|
|
||||||
um.Value.GrantUpgrade(self, u, this);
|
|
||||||
else
|
|
||||||
um.Value.RevokeUpgrade(self, u, this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -211,6 +211,7 @@ SPY:
|
|||||||
Voice: Move
|
Voice: Move
|
||||||
Disguise:
|
Disguise:
|
||||||
Voice: Move
|
Voice: Move
|
||||||
|
DisguisedCondition: disguise
|
||||||
Infiltrates:
|
Infiltrates:
|
||||||
Types: SpyInfiltrate
|
Types: SpyInfiltrate
|
||||||
PlayerExperience: 50
|
PlayerExperience: 50
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ CHAMSPY:
|
|||||||
Range: 9c0
|
Range: 9c0
|
||||||
Passenger:
|
Passenger:
|
||||||
Disguise:
|
Disguise:
|
||||||
|
DisguisedCondition: disguise
|
||||||
WithDecoration@disguise:
|
WithDecoration@disguise:
|
||||||
Image: pips
|
Image: pips
|
||||||
Sequence: pip-disguise
|
Sequence: pip-disguise
|
||||||
|
|||||||
Reference in New Issue
Block a user