A game Perk class 'PerkMineBullet' that, when active, modifies player bullet speed and bullet lifetime stats. It applies multiplicative modifiers in Refresh and defines static values via GetValue; registration metadata is commented out and the perk is marked disabled.
using System;
using Sandbox;
[Perk( Rarity.Unique, disabled: true, alwaysOfferDebug: false )]
public class PerkMineBullet : Perk
{
private enum Mod { BulletSpeed, BulletLifetime, };
static PerkMineBullet()
{
//Register<PerkMineBullet>(
// name: "Mine Bullets",
// imagePath: "textures/icons/vector/mine_bullet.png",
// description: level => $"-{GetValue( level, Mod.BulletSpeed, true )}% bullet speed and +{GetValue( level, Mod.BulletLifetime, true )}% bullet lifetime",
// upgradeDescription: level => $"-{GetValue( level - 1, Mod.BulletSpeed, true )}%→{GetValue( level, Mod.BulletSpeed, true )}% bullet speed and +{GetValue( level - 1, Mod.BulletLifetime, true )}%→{GetValue( level, Mod.BulletLifetime, true )}% bullet lifetime"
//);
}
public override void Start()
{
base.Start();
}
public override void Refresh()
{
base.Refresh();
Player.Modify( this, PlayerStat.BulletSpeed, GetValue( Level, Mod.BulletSpeed ), ModifierType.Mult );
Player.Modify( this, PlayerStat.BulletLifetime, GetValue( Level, Mod.BulletLifetime ), ModifierType.Mult );
}
private static float GetValue( int level, Mod mod, bool isPercent = false )
{
switch ( mod )
{
case Mod.BulletSpeed:
default:
return isPercent
? 95f
: 1f - 0.95f;
case Mod.BulletLifetime:
return isPercent
? 300f
: 3.0f;
}
}
}