guns/GunRecoil.cs

A small gun item subclass that grants the player a recoil-related perk at run start. It defines an item id and a perk level, shows a description string, announces via chat when run starts, and adds the PerkRecoil perk to the player PerkLevel times.

public class GunRecoil : Gun
{
	public const string ItemId = "gun_recoil";

	private const int PerkLevel = 2;

	public static string Description() => $"Start with {Perk.GetRichTextNameToken( typeof( PerkRecoil ) )} {Perk.GetRichTextToken( nameof( PerkRecoil ), level: PerkLevel )} Lvl {PerkLevel}";

	public override void OnRunStart()
	{
		base.OnRunStart();

		Manager.Instance.Chat.AddLocalChatMessage( $"Got {Perk.GetRichTextNameToken( typeof( PerkRecoil ) )} {Perk.GetRichTextToken( nameof( PerkRecoil ), level: PerkLevel )} Lvl {PerkLevel}", from: "" );

		for( int i = 0; i < PerkLevel; i++ )
			Player.AddPerk( TypeLibrary.GetType( typeof( PerkRecoil ) ) );
	}
}