From 94f6dd5e562ac8d1f80cd907235da5d8d833dc11 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Mon, 3 Aug 2015 15:39:22 +0200 Subject: [PATCH] Allow WithBuildingExplosion to randomly select from multiple sequences Necessary for TS/RA2-style building explosions. --- OpenRA.Mods.Common/Traits/Render/WithBuildingExplosion.cs | 8 ++++---- OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs | 7 +++++++ mods/ts/rules/defaults.yaml | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Render/WithBuildingExplosion.cs b/OpenRA.Mods.Common/Traits/Render/WithBuildingExplosion.cs index bd9e55d052..6c08be2cc3 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithBuildingExplosion.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithBuildingExplosion.cs @@ -18,11 +18,11 @@ namespace OpenRA.Mods.Common.Traits [Desc("Display explosions over the building footprint when it is destroyed.")] class WithBuildingExplosionInfo : ITraitInfo, Requires { - [Desc("Group where Sequence is looked up.")] + [Desc("Group where Sequences are looked up.")] public readonly string SequenceCollection = "explosion"; - [Desc("Explosion sequence name to use")] - [SequenceReference("SequenceCollection")] public readonly string Sequence = "building"; + [Desc("Explosion sequence names to use")] + [SequenceReference("SequenceCollection")] public readonly string[] Sequences = { "building" }; [Desc("Delay the explosions by this many ticks.")] public readonly int Delay = 0; @@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Traits void SpawnExplosions(World world, IEnumerable cells) { foreach (var c in cells) - world.AddFrameEndTask(w => w.Add(new Explosion(w, w.Map.CenterOfCell(c), info.Sequence, info.Palette))); + world.AddFrameEndTask(w => w.Add(new Explosion(w, w.Map.CenterOfCell(c), info.Sequences.Random(w.SharedRandom), info.Palette))); } } } diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index c7cb371426..7a410b164a 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -1680,6 +1680,13 @@ namespace OpenRA.Mods.Common.UtilityCommands } } + // WithBuildingExplosion received support for sequence randomization + if (engineVersion < 20150803) + { + if (depth == 2 && parentKey == "WithBuildingExplosion" && node.Key == "Sequence") + node.Key = "Sequences"; + } + UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1); } } diff --git a/mods/ts/rules/defaults.yaml b/mods/ts/rules/defaults.yaml index b09582270a..9eb4fd0f0d 100644 --- a/mods/ts/rules/defaults.yaml +++ b/mods/ts/rules/defaults.yaml @@ -64,6 +64,7 @@ DestroyedSounds: crmble2.aud RenderBuilding: WithBuildingExplosion: + Sequences: building, large_bang, large_brnl, verylarge_clsn, large_tumu EngineerRepairable: ShakeOnDeath: AcceptsSupplies: