YamlException is now thrown if WeaponInfo can not be found in Ruleset.Weapons
Removed invalid spacing at the end of the line 36 in ThrowsShrapnel Prevented NullReferenceException in cases where weapons aren't optional
This commit is contained in:
@@ -30,7 +30,15 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public WeaponInfo DemolishWeaponInfo { get; private set; }
|
||||
|
||||
public void RulesetLoaded(Ruleset rules, ActorInfo ai) { DemolishWeaponInfo = rules.Weapons[DemolishWeapon.ToLowerInvariant()]; }
|
||||
public void RulesetLoaded(Ruleset rules, ActorInfo ai)
|
||||
{
|
||||
WeaponInfo weapon;
|
||||
var weaponToLower = (DemolishWeapon ?? string.Empty).ToLowerInvariant();
|
||||
if (!rules.Weapons.TryGetValue(weaponToLower, out weapon))
|
||||
throw new YamlException("Weapons Ruleset does not contain an entry '{0}'".F(weaponToLower));
|
||||
|
||||
DemolishWeaponInfo = weapon;
|
||||
}
|
||||
|
||||
public object Create(ActorInitializer init) { return new GroundLevelBridge(init.Self, this); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user