A charm component class named CharmDice that grants the player extra rerolls at the start of a run. It defines a constant ItemId, a static NumRerolls value, a Description method returning a string, and in OnRunStart it increments the player's NumRerollAvailable by NumRerolls. Commented-out code shows previously giving items and playing a sound.
using System.Xml.Linq;
using static Sandbox.VertexLayout;
public class CharmDice : Charm
{
public const string ItemId = "charm_dice";
private static int NumRerolls = 5;
public static string Description() => $"Start with +{NumRerolls} reroll-item";
public override void OnRunStart()
{
Player.NumRerollAvailable += NumRerolls;
//for ( int i = 0; i < NumRerolls; i++ )
//{
// Player.GiveItemRpc( "reroll_item", Utils.GetRandomVector() );
//}
//Manager.Instance.PlaySfxNearbyRpc( "scuffle", Player.Position2D, pitch: Game.Random.Float( 0.8f, 0.95f ), volume: 0.85f, maxDist: 300f );
}
}