Perk class that grants turn speed and reload speed modifiers. It registers the perk metadata (name, icon, description) and applies stat multipliers to the Player when refreshed.
using System;
using Sandbox;
[Perk( Rarity.Unique, alwaysOfferDebug: false )]
public class PerkTurnSpeed : Perk
{
private enum Mod { TurnSpeed, ReloadSpeed };
static PerkTurnSpeed()
{
Register<PerkTurnSpeed>(
name: "Quick Reflexes",
imagePath: "textures/icons/vector/turn_speed.png",
description: level => $"+{GetValue( level, Mod.TurnSpeed, true )}% turn speed\n+{(int)GetValue( level, Mod.ReloadSpeed, true )}% reload speed"
);
}
public override void Start()
{
base.Start();
}
public override void Refresh()
{
base.Refresh();
Player.Modify( this, PlayerStat.TurnSpeed, GetValue( Level, Mod.TurnSpeed ), ModifierType.Mult );
Player.Modify( this, PlayerStat.ReloadSpeed, GetValue( Level, Mod.ReloadSpeed ), ModifierType.Mult );
}
private static float GetValue( int level, Mod mod, bool isPercent = false )
{
switch ( mod )
{
case Mod.TurnSpeed:
default:
return isPercent
? 250f
: 1f + 2.5f;
case Mod.ReloadSpeed:
return isPercent
? 8f
: 1f + (0.08f * level);
}
}
}