Update rule for AimAnimation splits and ReloadPrefix removal
This commit is contained in:
@@ -872,7 +872,7 @@
|
|||||||
<Compile Include="UpdateRules\Rules\RemoveWeaponScanRadius.cs" />
|
<Compile Include="UpdateRules\Rules\RemoveWeaponScanRadius.cs" />
|
||||||
<Compile Include="UpdateRules\Rules\DefineSoundDefaults.cs" />
|
<Compile Include="UpdateRules\Rules\DefineSoundDefaults.cs" />
|
||||||
<Compile Include="UpdateRules\Rules\DefineSquadExcludeHarvester.cs" />
|
<Compile Include="UpdateRules\Rules\DefineSquadExcludeHarvester.cs" />
|
||||||
<Compile Include="UpdateRules\Rules\SplitTurretAimAnimation.cs" />
|
<Compile Include="UpdateRules\Rules\SplitAimAnimations.cs" />
|
||||||
<Compile Include="UpdateRules\Rules\RenameWormSpawner.cs" />
|
<Compile Include="UpdateRules\Rules\RenameWormSpawner.cs" />
|
||||||
<Compile Include="UpdateRules\Rules\RemoveWithReloadingSpriteTurret.cs" />
|
<Compile Include="UpdateRules\Rules\RemoveWithReloadingSpriteTurret.cs" />
|
||||||
<Compile Include="UpdateRules\Rules\AddEditorPlayer.cs" />
|
<Compile Include="UpdateRules\Rules\AddEditorPlayer.cs" />
|
||||||
|
|||||||
185
OpenRA.Mods.Common/UpdateRules/Rules/SplitAimAnimations.cs
Normal file
185
OpenRA.Mods.Common/UpdateRules/Rules/SplitAimAnimations.cs
Normal file
@@ -0,0 +1,185 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2018 The OpenRA Developers (see AUTHORS)
|
||||||
|
* This file is part of OpenRA, which is free software. It is made
|
||||||
|
* available to you under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation, either version 3 of
|
||||||
|
* the License, or (at your option) any later version. For more
|
||||||
|
* information, see COPYING.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||||
|
{
|
||||||
|
public class SplitAimAnimations : UpdateRule
|
||||||
|
{
|
||||||
|
public override string Name { get { return "Introduce WithAimAnimation and WithTurretAimAnimation traits"; } }
|
||||||
|
public override string Description
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "WithAttackAnimation.AimSequence, WithTurretAttackAnimation.AimSequence\n" +
|
||||||
|
"as well as WithSpriteTurret.AimSequence have been split to new With*AimAnimation traits.\n" +
|
||||||
|
"Furthermore, ReloadPrefixes have been removed in favor of condition-based solutions.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
readonly List<Tuple<string, string>> aimAnimLocations = new List<Tuple<string, string>>();
|
||||||
|
readonly List<Tuple<string, string>> reloadPrefixLocations = new List<Tuple<string, string>>();
|
||||||
|
|
||||||
|
public override IEnumerable<string> AfterUpdate(ModData modData)
|
||||||
|
{
|
||||||
|
var message1 = "AimSequences have been split to With*AimAnimation.\n"
|
||||||
|
+ "The following actors have been updated and might need manual adjustments:\n"
|
||||||
|
+ UpdateUtils.FormatMessageList(aimAnimLocations.Select(n => n.Item1 + " (" + n.Item2 + ")"));
|
||||||
|
|
||||||
|
if (aimAnimLocations.Any())
|
||||||
|
yield return message1;
|
||||||
|
|
||||||
|
aimAnimLocations.Clear();
|
||||||
|
|
||||||
|
var message2 = "ReloadPrefixes have been removed.\n"
|
||||||
|
+ "Instead, grant a condition on reloading via Armament.ReloadingCondition to enable\n"
|
||||||
|
+ "an alternate sprite body (with reloading sequences) on the following actors:\n"
|
||||||
|
+ UpdateUtils.FormatMessageList(reloadPrefixLocations.Select(n => n.Item1 + " (" + n.Item2 + ")"));
|
||||||
|
|
||||||
|
if (reloadPrefixLocations.Any())
|
||||||
|
yield return message2;
|
||||||
|
|
||||||
|
reloadPrefixLocations.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
|
||||||
|
{
|
||||||
|
var turretAttack = actorNode.LastChildMatching("WithTurretAttackAnimation");
|
||||||
|
if (turretAttack != null)
|
||||||
|
{
|
||||||
|
var attackSequence = turretAttack.LastChildMatching("AttackSequence");
|
||||||
|
var aimSequence = turretAttack.LastChildMatching("AimSequence");
|
||||||
|
var reloadPrefix = turretAttack.LastChildMatching("ReloadPrefix");
|
||||||
|
|
||||||
|
if (aimSequence != null)
|
||||||
|
aimAnimLocations.Add(Tuple.Create(actorNode.Key, actorNode.Location.Filename));
|
||||||
|
|
||||||
|
if (reloadPrefix != null)
|
||||||
|
reloadPrefixLocations.Add(Tuple.Create(actorNode.Key, actorNode.Location.Filename));
|
||||||
|
|
||||||
|
// If only AttackSequence is not null, just rename AttackSequence to Sequence.
|
||||||
|
// If only the prefix isn't null (extremely unlikely, but you never know), just rename the trait.
|
||||||
|
// If AttackSequence is null but AimSequence isn't, rename the trait and property.
|
||||||
|
// If both aren't null, split/copy everything relevant to the new WithTurretAimAnimation.
|
||||||
|
// If both are null (extremely unlikely), do nothing.
|
||||||
|
if (attackSequence != null && aimSequence == null)
|
||||||
|
attackSequence.RenameKeyPreservingSuffix("Sequence");
|
||||||
|
else if (attackSequence == null && aimSequence == null && reloadPrefix != null)
|
||||||
|
{
|
||||||
|
turretAttack.RemoveNode(reloadPrefix);
|
||||||
|
turretAttack.RenameKeyPreservingSuffix("WithTurretAimAnimation");
|
||||||
|
}
|
||||||
|
else if (attackSequence == null && aimSequence != null)
|
||||||
|
{
|
||||||
|
turretAttack.RenameKeyPreservingSuffix("WithTurretAimAnimation");
|
||||||
|
aimSequence.RenameKeyPreservingSuffix("Sequence");
|
||||||
|
if (reloadPrefix != null)
|
||||||
|
turretAttack.RemoveNode(reloadPrefix);
|
||||||
|
}
|
||||||
|
else if (attackSequence != null && aimSequence != null)
|
||||||
|
{
|
||||||
|
var turretAim = new MiniYamlNode("WithTurretAimAnimation", "");
|
||||||
|
aimSequence.RenameKeyPreservingSuffix("Sequence");
|
||||||
|
turretAim.AddNode(aimSequence);
|
||||||
|
turretAttack.RemoveNode(aimSequence);
|
||||||
|
|
||||||
|
var turret = turretAttack.LastChildMatching("Turret");
|
||||||
|
var armament = turretAttack.LastChildMatching("Armament");
|
||||||
|
if (reloadPrefix != null)
|
||||||
|
turretAttack.RemoveNode(reloadPrefix);
|
||||||
|
|
||||||
|
if (turret != null)
|
||||||
|
turretAim.AddNode(turret);
|
||||||
|
if (armament != null)
|
||||||
|
turretAim.AddNode(armament);
|
||||||
|
|
||||||
|
attackSequence.RenameKeyPreservingSuffix("Sequence");
|
||||||
|
actorNode.AddNode(turretAim);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var spriteTurret = actorNode.LastChildMatching("WithSpriteTurret");
|
||||||
|
if (spriteTurret != null)
|
||||||
|
{
|
||||||
|
var aimSequence = spriteTurret.LastChildMatching("AimSequence");
|
||||||
|
if (aimSequence != null)
|
||||||
|
{
|
||||||
|
aimAnimLocations.Add(Tuple.Create(actorNode.Key, actorNode.Location.Filename));
|
||||||
|
|
||||||
|
var aimAnim = new MiniYamlNode("WithTurretAimAnimation", "");
|
||||||
|
aimSequence.RenameKeyPreservingSuffix("Sequence");
|
||||||
|
aimAnim.AddNode(aimSequence);
|
||||||
|
spriteTurret.RemoveNode(aimSequence);
|
||||||
|
actorNode.AddNode(aimAnim);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var attackAnim = actorNode.LastChildMatching("WithAttackAnimation");
|
||||||
|
if (attackAnim != null)
|
||||||
|
{
|
||||||
|
var attackSequence = attackAnim.LastChildMatching("AttackSequence");
|
||||||
|
var aimSequence = attackAnim.LastChildMatching("AimSequence");
|
||||||
|
var reloadPrefix = attackAnim.LastChildMatching("ReloadPrefix");
|
||||||
|
|
||||||
|
if (aimSequence != null)
|
||||||
|
aimAnimLocations.Add(Tuple.Create(actorNode.Key, actorNode.Location.Filename));
|
||||||
|
|
||||||
|
if (reloadPrefix != null)
|
||||||
|
reloadPrefixLocations.Add(Tuple.Create(actorNode.Key, actorNode.Location.Filename));
|
||||||
|
|
||||||
|
// If only AttackSequence is not null, just rename AttackSequence to Sequence.
|
||||||
|
// If only the prefix isn't null (extremely unlikely, but you never know), just rename the trait.
|
||||||
|
// If AttackSequence is null but AimSequence isn't, rename the trait and property.
|
||||||
|
// If both sequences aren't null, split/copy everything relevant to the new WithAimAnimation.
|
||||||
|
// If both sequences and the prefix are null (extremely unlikely), do nothing.
|
||||||
|
if (attackSequence != null && aimSequence == null && reloadPrefix == null)
|
||||||
|
attackSequence.RenameKeyPreservingSuffix("Sequence");
|
||||||
|
else if (attackSequence == null && aimSequence == null && reloadPrefix != null)
|
||||||
|
{
|
||||||
|
attackAnim.RemoveNode(reloadPrefix);
|
||||||
|
attackAnim.RenameKeyPreservingSuffix("WithAimAnimation");
|
||||||
|
}
|
||||||
|
else if (attackSequence == null && aimSequence != null)
|
||||||
|
{
|
||||||
|
attackAnim.RenameKeyPreservingSuffix("WithAimAnimation");
|
||||||
|
aimSequence.RenameKeyPreservingSuffix("Sequence");
|
||||||
|
if (reloadPrefix != null)
|
||||||
|
attackAnim.RemoveNode(reloadPrefix);
|
||||||
|
}
|
||||||
|
else if (attackSequence != null && aimSequence != null)
|
||||||
|
{
|
||||||
|
var aimAnim = new MiniYamlNode("WithAimAnimation", "");
|
||||||
|
aimSequence.RenameKeyPreservingSuffix("Sequence");
|
||||||
|
aimAnim.AddNode(aimSequence);
|
||||||
|
attackAnim.RemoveNode(aimSequence);
|
||||||
|
|
||||||
|
var body = attackAnim.LastChildMatching("Body");
|
||||||
|
var armament = attackAnim.LastChildMatching("Armament");
|
||||||
|
if (reloadPrefix != null)
|
||||||
|
attackAnim.RemoveNode(reloadPrefix);
|
||||||
|
|
||||||
|
if (body != null)
|
||||||
|
aimAnim.AddNode(body);
|
||||||
|
if (armament != null)
|
||||||
|
aimAnim.AddNode(armament);
|
||||||
|
|
||||||
|
attackSequence.RenameKeyPreservingSuffix("Sequence");
|
||||||
|
actorNode.AddNode(aimAnim);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
#region Copyright & License Information
|
|
||||||
/*
|
|
||||||
* Copyright 2007-2018 The OpenRA Developers (see AUTHORS)
|
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
|
||||||
* available to you under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation, either version 3 of
|
|
||||||
* the License, or (at your option) any later version. For more
|
|
||||||
* information, see COPYING.
|
|
||||||
*/
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.UpdateRules.Rules
|
|
||||||
{
|
|
||||||
public class SplitTurretAimAnimation : UpdateRule
|
|
||||||
{
|
|
||||||
public override string Name { get { return "Introduce WithTurretAimAnimation trait"; } }
|
|
||||||
public override string Description
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return "WithSpriteTurret.AimSequence and WithTurretAttackAnimation.AimSequence\n" +
|
|
||||||
"have been split into a new WithTurretAimAnimation trait.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
|
|
||||||
{
|
|
||||||
var turretAttack = actorNode.LastChildMatching("WithTurretAttackAnimation");
|
|
||||||
if (turretAttack != null)
|
|
||||||
{
|
|
||||||
var attackSequence = turretAttack.LastChildMatching("AttackSequence");
|
|
||||||
var aimSequence = turretAttack.LastChildMatching("AimSequence");
|
|
||||||
|
|
||||||
// If only AimSequence is null, just rename AttackSequence to Sequence (ReloadPrefix is very unlikely to be defined in that case).
|
|
||||||
// If only AttackSequence is null, just rename the trait and property (the delay properties will likely be undefined).
|
|
||||||
// If both aren't null, split/copy everything relevant to the new WithTurretAimAnimation.
|
|
||||||
// If both are null (extremely unlikely), do nothing.
|
|
||||||
if (attackSequence == null && aimSequence != null)
|
|
||||||
{
|
|
||||||
turretAttack.RenameKeyPreservingSuffix("WithTurretAimAnimation");
|
|
||||||
aimSequence.RenameKeyPreservingSuffix("Sequence");
|
|
||||||
}
|
|
||||||
else if (attackSequence != null && aimSequence == null)
|
|
||||||
attackSequence.RenameKeyPreservingSuffix("Sequence");
|
|
||||||
else if (attackSequence != null && aimSequence != null)
|
|
||||||
{
|
|
||||||
var turretAim = new MiniYamlNode("WithTurretAimAnimation", "");
|
|
||||||
aimSequence.RenameKeyPreservingSuffix("Sequence");
|
|
||||||
turretAim.AddNode(aimSequence);
|
|
||||||
turretAttack.RemoveNode(aimSequence);
|
|
||||||
|
|
||||||
var reloadPrefix = turretAttack.LastChildMatching("ReloadPrefix");
|
|
||||||
var turret = turretAttack.LastChildMatching("Turret");
|
|
||||||
var armament = turretAttack.LastChildMatching("Armament");
|
|
||||||
if (reloadPrefix != null)
|
|
||||||
{
|
|
||||||
turretAim.AddNode(reloadPrefix);
|
|
||||||
turretAttack.RemoveNode(reloadPrefix);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (turret != null)
|
|
||||||
turretAim.AddNode(turret);
|
|
||||||
if (armament != null)
|
|
||||||
turretAim.AddNode(armament);
|
|
||||||
|
|
||||||
attackSequence.RenameKeyPreservingSuffix("Sequence");
|
|
||||||
actorNode.AddNode(turretAim);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var spriteTurret = actorNode.LastChildMatching("WithSpriteTurret");
|
|
||||||
if (spriteTurret != null)
|
|
||||||
{
|
|
||||||
var aimSequence = spriteTurret.LastChildMatching("AimSequence");
|
|
||||||
if (aimSequence != null)
|
|
||||||
{
|
|
||||||
var aimAnim = new MiniYamlNode("WithTurretAimAnimation", "");
|
|
||||||
aimSequence.RenameKeyPreservingSuffix("Sequence");
|
|
||||||
aimAnim.AddNode(aimSequence);
|
|
||||||
spriteTurret.RemoveNode(aimSequence);
|
|
||||||
actorNode.AddNode(aimAnim);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
yield break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.UpdateRules
|
|||||||
new RemoveTerrainTypeIsWaterFlag(),
|
new RemoveTerrainTypeIsWaterFlag(),
|
||||||
new DefineSquadExcludeHarvester(),
|
new DefineSquadExcludeHarvester(),
|
||||||
new RemoveWeaponScanRadius(),
|
new RemoveWeaponScanRadius(),
|
||||||
new SplitTurretAimAnimation(),
|
new SplitAimAnimations(),
|
||||||
new DefineSoundDefaults(),
|
new DefineSoundDefaults(),
|
||||||
new RenameWormSpawner(),
|
new RenameWormSpawner(),
|
||||||
new RemoveWithReloadingSpriteTurret(),
|
new RemoveWithReloadingSpriteTurret(),
|
||||||
|
|||||||
Reference in New Issue
Block a user