charms/CharmRandomPerk.cs

A charm component that grants the player one random perk when they reach level 3. It checks player level on level-up, picks a random perk type, gives the perk item with a random spawn direction, and posts a local chat message announcing the granted perk.

Networking
public class CharmRandomPerk : Charm
{
	public const string ItemId = "charm_random_perk";

	public static string Description() => $"+1 random perk when\nyou reach Lvl 3";

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

		if ( Player.Level == 3 )
		{
			var type = Player.GetRandomPerkType( isReward: false );
			Player.GivePerkItem( type, dir: Utils.GetRandomVectorInCone( -Player.FacingDir ) );

			Manager.Instance.Chat.AddLocalChatMessage( $"{ProgressManager.GetItemRichTextToken( ItemId )} Got {Perk.GetRichTextNameToken( type.TargetType )} {Perk.GetRichTextToken( type )}", from: "" );
		}
	}
}