Implement new mod/map updater framework.
This commit is contained in:
78
OpenRA.Mods.Common/UpdateRules/Rules/DefineSoundDefaults.cs
Normal file
78
OpenRA.Mods.Common/UpdateRules/Rules/DefineSoundDefaults.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
#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 DefineSoundDefaults : UpdateRule
|
||||
{
|
||||
public override string Name { get { return "Move mod-specific sound defaults to yaml"; } }
|
||||
public override string Description
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Mod-specific default sound values have been removed from several traits.\n" +
|
||||
"The original values are added back via yaml.";
|
||||
}
|
||||
}
|
||||
|
||||
Tuple<string, string, string, List<MiniYamlNode>>[] fields =
|
||||
{
|
||||
Tuple.Create("ParaDrop", "ChuteSound", "chute1.aud", new List<MiniYamlNode>()),
|
||||
Tuple.Create("EjectOnDeath", "ChuteSound", "chute1.aud", new List<MiniYamlNode>()),
|
||||
Tuple.Create("ProductionParadrop", "ChuteSound", "chute1.aud", new List<MiniYamlNode>()),
|
||||
Tuple.Create("Building", "BuildSounds", "placbldg.aud, build5.aud", new List<MiniYamlNode>()),
|
||||
Tuple.Create("Building", "UndeploySounds", "cashturn.aud", new List<MiniYamlNode>())
|
||||
};
|
||||
|
||||
public override IEnumerable<string> BeforeUpdate(ModData modData)
|
||||
{
|
||||
// Reset state for each mod/map
|
||||
foreach (var field in fields)
|
||||
field.Item4.Clear();
|
||||
|
||||
yield break;
|
||||
}
|
||||
|
||||
string BuildMessage(Tuple<string, string, string, List<MiniYamlNode>> field)
|
||||
{
|
||||
return "The default value for {0}.{1} has been removed.\n".F(field.Item1, field.Item2)
|
||||
+ "You may wish to explicitly define `{0}: {1}` at the following\n".F(field.Item2, field.Item3)
|
||||
+ "locations if the sound has not already been inherited from a parent definition.\n"
|
||||
+ UpdateUtils.FormatMessageList(field.Item4.Select(n => n.Location.ToString()));
|
||||
}
|
||||
|
||||
public override IEnumerable<string> AfterUpdate(ModData modData)
|
||||
{
|
||||
foreach (var field in fields)
|
||||
if (field.Item4.Any())
|
||||
yield return BuildMessage(field);
|
||||
}
|
||||
|
||||
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
|
||||
{
|
||||
foreach (var field in fields)
|
||||
{
|
||||
foreach (var traitNode in actorNode.ChildrenMatching(field.Item1))
|
||||
{
|
||||
var node = traitNode.LastChildMatching(field.Item2);
|
||||
if (node == null)
|
||||
field.Item4.Add(traitNode);
|
||||
}
|
||||
}
|
||||
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#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;
|
||||
|
||||
namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||
{
|
||||
public class RemoveTerrainTypeIsWaterFlag : UpdateRule
|
||||
{
|
||||
public override string Name { get { return "Remove TerrainType IsWater flag"; } }
|
||||
public override string Description
|
||||
{
|
||||
get
|
||||
{
|
||||
return "The IsWater flag on terrain type definitions has been unused for some time.\n" +
|
||||
"This flag has now been removed from the tileset yaml.";
|
||||
}
|
||||
}
|
||||
|
||||
public override IEnumerable<string> UpdateTilesetNode(ModData modData, MiniYamlNode tilesetNode)
|
||||
{
|
||||
if (tilesetNode.Key == "Terrain")
|
||||
foreach (var type in tilesetNode.Value.Nodes)
|
||||
type.Value.Nodes.RemoveAll(n => n.Key == "IsWater");
|
||||
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
#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;
|
||||
|
||||
namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||
{
|
||||
public class RemoveWeaponScanRadius : UpdateRule
|
||||
{
|
||||
public override string Name { get { return "Remove Weapon ScanRadius parameters"; } }
|
||||
public override string Description
|
||||
{
|
||||
get
|
||||
{
|
||||
return "The *ScanRadius parameters have been removed from weapon projectiles and warheads.\n" +
|
||||
"These values are now automatically determined by the engine.\n" +
|
||||
"CreateEffect.ImpactActors: False has been added to replace VictimScanRadius: 0";
|
||||
}
|
||||
}
|
||||
|
||||
public override IEnumerable<string> UpdateWeaponNode(ModData modData, MiniYamlNode weaponNode)
|
||||
{
|
||||
foreach (var node in weaponNode.ChildrenMatching("Warhead"))
|
||||
{
|
||||
if (node.Value.Value == "CreateEffect")
|
||||
{
|
||||
var victimScanRadius = node.LastChildMatching("VictimScanRadius");
|
||||
if (victimScanRadius != null && victimScanRadius.NodeValue<int>() == 0)
|
||||
node.AddNode("ImpactActors", "false");
|
||||
node.RemoveNodes("VictimScanRadius");
|
||||
}
|
||||
}
|
||||
|
||||
var projectile = weaponNode.LastChildMatching("Projectile");
|
||||
if (projectile != null)
|
||||
{
|
||||
projectile.RemoveNodes("BounceBlockerScanRadius");
|
||||
projectile.RemoveNodes("BlockerScanRadius");
|
||||
projectile.RemoveNodes("AreaVictimScanRadius");
|
||||
}
|
||||
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#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;
|
||||
|
||||
namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||
{
|
||||
public class RemoveWithReloadingSpriteTurret : UpdateRule
|
||||
{
|
||||
public override string Name { get { return "Remove WithReloadingSpriteTurret trait"; } }
|
||||
public override string Description
|
||||
{
|
||||
get
|
||||
{
|
||||
return "WithReloadingSpriteTurret has been superseded by conditions.\n" +
|
||||
"The trait is switched for with WithSpriteTurret.\n";
|
||||
}
|
||||
}
|
||||
|
||||
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
|
||||
{
|
||||
foreach (var turret in actorNode.ChildrenMatching("WithReloadingSpriteTurret"))
|
||||
{
|
||||
turret.RenameKeyPreservingSuffix("WithSpriteTurret");
|
||||
yield return turret.Location.ToString() + ": WithReloadingSpriteTurret has been replaced by WithSpriteTurret.\n" +
|
||||
"You should use AmmoPool.AmmoConditions to switch turret type when reloading to restore the previous behaviour.";
|
||||
}
|
||||
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
44
OpenRA.Mods.Common/UpdateRules/Rules/RenameWormSpawner.cs
Normal file
44
OpenRA.Mods.Common/UpdateRules/Rules/RenameWormSpawner.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
#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;
|
||||
|
||||
namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||
{
|
||||
public class RenameWormSpawner : UpdateRule
|
||||
{
|
||||
public override string Name { get { return "WormSpawner renamed and generalized to ActorSpawner"; } }
|
||||
public override string Description
|
||||
{
|
||||
get
|
||||
{
|
||||
return "The D2k-specific WormSpawner trait was renamed to ActorSpawner,\n" +
|
||||
"generalized, and moved into the common mod code.";
|
||||
}
|
||||
}
|
||||
|
||||
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
|
||||
{
|
||||
foreach (var spawner in actorNode.ChildrenMatching("WormSpawner"))
|
||||
spawner.RenameKeyPreservingSuffix("ActorSpawner");
|
||||
|
||||
foreach (var manager in actorNode.ChildrenMatching("WormManager"))
|
||||
{
|
||||
manager.RenameKeyPreservingSuffix("ActorSpawnManager");
|
||||
var signature = manager.LastChildMatching("WormSignature");
|
||||
if (signature != null)
|
||||
signature.RenameKeyPreservingSuffix("Actors");
|
||||
}
|
||||
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
#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.Value.Nodes.Add(aimSequence);
|
||||
turretAttack.Value.Nodes.Remove(aimSequence);
|
||||
|
||||
var reloadPrefix = turretAttack.LastChildMatching("ReloadPrefix");
|
||||
var turret = turretAttack.LastChildMatching("Turret");
|
||||
var armament = turretAttack.LastChildMatching("Armament");
|
||||
if (reloadPrefix != null)
|
||||
{
|
||||
turretAim.Value.Nodes.Add(reloadPrefix);
|
||||
turretAttack.Value.Nodes.Remove(reloadPrefix);
|
||||
}
|
||||
|
||||
if (turret != null)
|
||||
turretAim.Value.Nodes.Add(turret);
|
||||
if (armament != null)
|
||||
turretAim.Value.Nodes.Add(armament);
|
||||
|
||||
attackSequence.RenameKeyPreservingSuffix("Sequence");
|
||||
actorNode.Value.Nodes.Add(turretAim);
|
||||
}
|
||||
}
|
||||
|
||||
var spriteTurret = actorNode.LastChildMatching("WithSpriteTurret");
|
||||
if (spriteTurret != null)
|
||||
{
|
||||
var aimSequence = spriteTurret.Value.Nodes.FirstOrDefault(n => n.Key == "AimSequence");
|
||||
if (aimSequence != null)
|
||||
{
|
||||
var aimAnim = new MiniYamlNode("WithTurretAimAnimation", "");
|
||||
aimSequence.RenameKeyPreservingSuffix("Sequence");
|
||||
aimAnim.Value.Nodes.Add(aimSequence);
|
||||
spriteTurret.Value.Nodes.Remove(aimSequence);
|
||||
actorNode.Value.Nodes.Add(aimAnim);
|
||||
}
|
||||
}
|
||||
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user