Perk class for a rarer-perk chance upgrade. It defines a perk that, when refreshed, adds a modifier to the player's RarerPerkChance stat based on perk level and contains a commented-out static registration block and a helper to compute values.
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;
}
}
}