Improve the exception message when a Bridge's DemolishWeapon cannot be found

This commit is contained in:
Taryn Hill
2017-07-22 11:33:42 -05:00
committed by reaperrr
parent 8ee742d66a
commit 57fb551545

View File

@@ -47,7 +47,18 @@ namespace OpenRA.Mods.Common.Traits
public object Create(ActorInitializer init) { return new Bridge(init.Self, this); }
public void RulesetLoaded(Ruleset rules, ActorInfo ai) { DemolishWeaponInfo = rules.Weapons[DemolishWeapon.ToLowerInvariant()]; }
public void RulesetLoaded(Ruleset rules, ActorInfo ai)
{
if (string.IsNullOrEmpty(DemolishWeapon))
throw new YamlException("A value for DemolishWeapon of a Bridge trait is missing.");
WeaponInfo weapon;
var weaponToLower = DemolishWeapon.ToLowerInvariant();
if (!rules.Weapons.TryGetValue(weaponToLower, out weapon))
throw new YamlException("Weapons Ruleset does not contain an entry '{0}'".F(weaponToLower));
DemolishWeaponInfo = weapon;
}
public IEnumerable<Pair<ushort, int>> Templates
{