Display an error when TrailSequences is empty and TrailImage is not

This commit is contained in:
abcdefg30
2019-05-16 22:46:39 +02:00
committed by reaperrr
parent b8fbc63542
commit bc3cabdea0

View File

@@ -9,7 +9,7 @@
*/ */
#endregion #endregion
using OpenRA.Effects; using System.Linq;
using OpenRA.GameRules; using OpenRA.GameRules;
using OpenRA.Mods.Common.Effects; using OpenRA.Mods.Common.Effects;
using OpenRA.Traits; using OpenRA.Traits;
@@ -101,6 +101,9 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new NukePower(init.Self, this); } public override object Create(ActorInitializer init) { return new NukePower(init.Self, this); }
public override void RulesetLoaded(Ruleset rules, ActorInfo ai) public override void RulesetLoaded(Ruleset rules, ActorInfo ai)
{ {
if (!string.IsNullOrEmpty(TrailImage) && !TrailSequences.Any())
throw new YamlException("At least one entry in TrailSequences must be defined when TrailImage is defined.");
WeaponInfo weapon; WeaponInfo weapon;
var weaponToLower = (MissileWeapon ?? string.Empty).ToLowerInvariant(); var weaponToLower = (MissileWeapon ?? string.Empty).ToLowerInvariant();
if (!rules.Weapons.TryGetValue(weaponToLower, out weapon)) if (!rules.Weapons.TryGetValue(weaponToLower, out weapon))