Improve the exception message when a Bridge's DemolishWeapon cannot be found
This commit is contained in:
@@ -47,7 +47,18 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public object Create(ActorInitializer init) { return new Bridge(init.Self, this); }
|
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
|
public IEnumerable<Pair<ushort, int>> Templates
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user