guns/GunRocketLauncher.cs

A game weapon class for a rocket launcher item. It defines the item id, ammo and reload penalties, a description string, and applies modifications to the player when the weapon run starts and cleans up on destroy.

public class GunRocketLauncher : Gun
{
	public const string ItemId = "gun_rocket_launcher";

	private static int GetAmmoReduction() => 4;
	private static int GetReloadSpeedReduction() => 20;

	public static string Description() => $"Shoot explosive bullet-icon\n-{GetAmmoReduction()} ammo\n-{GetReloadSpeedReduction()}% reload speed";

	public override void OnRunStart()
	{
		Player.IncludePerkCategory( PerkCategory.Explosion );
		Player.Modify( this, PlayerStat.ShootExplosiveBullets, 1f, ModifierType.Add );
		Player.Modify( this, PlayerStat.MaxAmmoCount, -GetAmmoReduction(), ModifierType.Add );
		Player.Modify( this, PlayerStat.ReloadSpeed, 1f - (GetReloadSpeedReduction() * 0.01f), ModifierType.Mult );
	}

	protected override void OnDestroy()
	{
		Player?.ExcludePerkCategory( PerkCategory.Explosion );
		base.OnDestroy();
	}
}