A charm component that grants extra perk choice(s) for each consecutive reroll during a run. It tracks consecutive rerolls, increments the player's NumPerkChoices stat before a reroll, and resets the counter when a perk is chosen or when 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;
}
}