diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index c98d6dd53f..973b7f9efc 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -902,6 +902,7 @@ + diff --git a/OpenRA.Mods.Common/Traits/Parachutable.cs b/OpenRA.Mods.Common/Traits/Parachutable.cs index 41cec329ea..beb51caba7 100644 --- a/OpenRA.Mods.Common/Traits/Parachutable.cs +++ b/OpenRA.Mods.Common/Traits/Parachutable.cs @@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Image where Ground/WaterCorpseSequence is looked up.")] public readonly string Image = "explosion"; - [SequenceReference("Image")] public readonly string GroundCorpseSequence = "corpse"; + [SequenceReference("Image")] public readonly string GroundCorpseSequence = null; [PaletteReference] public readonly string GroundCorpsePalette = "effect"; diff --git a/OpenRA.Mods.Common/UpdateRules/Rules/DefineGroundCorpseDefault.cs b/OpenRA.Mods.Common/UpdateRules/Rules/DefineGroundCorpseDefault.cs new file mode 100644 index 0000000000..916abebe27 --- /dev/null +++ b/OpenRA.Mods.Common/UpdateRules/Rules/DefineGroundCorpseDefault.cs @@ -0,0 +1,68 @@ +#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 DefineGroundCorpseDefault : UpdateRule + { + public override string Name { get { return "Move Parachutable GroundCorspeSequence default to yaml"; } } + public override string Description + { + get + { + return "Parachutable's GroundCorspeSequence 'corpse' default has been moved to yaml."; + } + } + + Tuple>[] fields = + { + Tuple.Create("Parachutable", "GroundCorpseSequence", "corpse", new List()), + }; + + string BuildMessage(Tuple> 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}` on the `{2}` trait \n".F(field.Item2, field.Item3, field.Item1) + + "definitions on the following actors (if they have not already been inherited from a parent).\n" + + UpdateUtils.FormatMessageList(field.Item4); + } + + public override IEnumerable AfterUpdate(ModData modData) + { + foreach (var field in fields) + { + if (field.Item4.Any()) + yield return BuildMessage(field); + + field.Item4.Clear(); + } + } + + public override IEnumerable 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("{0} ({1})".F(actorNode.Key, traitNode.Location.Filename)); + } + } + + yield break; + } + } +} diff --git a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs index 4a8c6c110e..69d7f7132b 100644 --- a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs +++ b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs @@ -81,6 +81,7 @@ namespace OpenRA.Mods.Common.UpdateRules new RenameEmitInfantryOnSell(), new SplitRepairDecoration(), new MoveHackyAISupportPowerDecisions(), + new DefineGroundCorpseDefault(), }) }; diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index a39e37fb7e..a5080924bc 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -277,10 +277,6 @@ Parachutable: FallRate: 26 KilledOnImpassableTerrain: true - GroundCorpseSequence: - GroundCorpsePalette: - WaterCorpseSequence: - WaterCorpsePalette: ParachutingCondition: parachute Explodes: Weapon: UnitExplodeSmall @@ -391,6 +387,7 @@ Parachutable: FallRate: 26 KilledOnImpassableTerrain: true + GroundCorpseSequence: corpse GroundImpactSound: squishy2.aud WaterImpactSound: splash9.aud WaterCorpseSequence: small_splash