charms/CharmRerollConsecutive.cs

A charm component that grants +1 perk choice for each consecutive reroll. It tracks consecutive rerolls, increments the player's NumPerkChoices stat before each reroll, and resets/cleans up when a perk is chosen or a run starts.

public class CharmRerollConsecutive : Charm
{
	public const string ItemId = "charm_reroll_consecutive";

	public static string Description() => $"See +1 perk choice for\neach consecutive reroll";

	private int _consecutiveRerolls = 0;

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

		_consecutiveRerolls++;
		Player.Modify( this, PlayerStat.NumPerkChoices, _consecutiveRerolls, ModifierType.Add );
	}

	public override void OnChoosePerk( TypeDescription type )
	{
		base.OnChoosePerk( type );

		_consecutiveRerolls = 0;
		Player.StopModifying( this, PlayerStat.NumPerkChoices );
	}

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

		_consecutiveRerolls = 0;
	}
}