perks/PerkRarerPerkChance.cs

A perk class for giving players an increased chance to get rarer perks. It computes a modifier based on perk level and applies it to the PlayerStat.RarerPerkChance when refreshed. The registration UI code is commented out and the perk is marked disabled in the attribute.

File Access
using System;
using Sandbox;

[Perk( Rarity.Common, includedAtStart: false, disabled: true, alwaysOfferDebug: false )]
public class PerkRarerPerkChance : Perk
{
	private enum Mod { RarerPerkChance };

	static PerkRarerPerkChance()
	{
		//Register<PerkRarerPerkChance>(
		//	name: "Rare Stuff",
		//	imagePath: "textures/icons/vector/rare_upgrade_chance.png",
		//	description: level => $"[DISABLED]+{(int)GetValue( level, Mod.RarerPerkChance, true )}% chance of rarer perks",
		//	upgradeDescription: level => $"[DISABLED]+{(int)GetValue( level - 1, Mod.RarerPerkChance, true )}%→{(int)GetValue( level, Mod.RarerPerkChance, true )}% chance of rarer perks"
		//);
	}

	public override void Start()
	{
		base.Start();
	}

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

		Player.Modify( this, PlayerStat.RarerPerkChance, GetValue( Level, Mod.RarerPerkChance ), ModifierType.Add );
	}

	private static float GetValue( int level, Mod mod, bool isPercent = false )
	{
		switch ( mod )
		{
			case Mod.RarerPerkChance:
			default:
				return isPercent
					? 25 * level
					: 0.25f * level;
		}
	}
}