/// <summary> /// Attaches the given custom weapon to this stub. /// </summary> /// <param name="weapon">The weapon to be attached.</param> internal void AttachWeapon(CustomWeapon weapon) { if (weapon == null) { throw new ArgumentNullException("weapon"); } if (this.attachedWeapon.Read() != null) { throw new InvalidOperationException("Another custom weapon has already been attached to this stub!"); } weapon.OnAttachingToStub(this); this.attachedWeapon.Write(weapon); }
/// <summary> /// Attaches the given custom weapon to this armour. /// </summary> /// <param name="name">The name of the custom weapon to be attached.</param> /// <param name="customWeapon">The curtom weapon to be attached.</param> public void AttachCustomWeapon(string name, CustomWeapon customWeapon) { if (name == null) { throw new ArgumentNullException("name"); } if (customWeapon == null) { throw new ArgumentNullException("customWeapon"); } if (!this.customWeapons.ContainsKey(name)) { throw new InvalidOperationException(string.Format("Custom weapon with name '{0}' is not defined for scenario element type '{1}'!", name, this.owner.Read().ElementType.Name)); } this.customWeapons[name].AttachWeapon(customWeapon); }