perks/PerkNumChoicesCantMove.cs

A Perk class called PerkNumChoicesCantMove (Decision Paralysis). It increases the number of perk choices and applies a modifier preventing the player from moving while choosing; clears the modifiers when a perk is chosen and shows a highlight when leveling up if still active.

using System;
using Sandbox;

[Perk( Rarity.Epic, onlyUnpausedChoosing: true, locked: true, minUnlocksReq: 3, alwaysOfferDebug: false )]
public class PerkNumChoicesCantMove : Perk
{
	private enum Mod { NumPerkChoices };

	static PerkNumChoicesCantMove()
	{
		Register<PerkNumChoicesCantMove>(
			name: "Decision Paralysis",
			imagePath: "textures/icons/vector/override_num_choices.png",
			description: level => $"+{(int)GetValue( level, Mod.NumPerkChoices )} perk choices\nCan't move while choosing\n(until you choose)",
			upgradeDescription: level => $"+{(int)GetValue( level, Mod.NumPerkChoices )} perk choices\nCan't move while choosing\n(until you choose)"
		);
	}

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

		HighlightColor = new Color( 1f, 0.8f, 0f );
		HighlightDuration = 0.8f;
		HighlightOpacity = 4.5f;
	}

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

		Player.Modify( this, PlayerStat.NumPerkChoices, GetValue( Level, Mod.NumPerkChoices ), ModifierType.Add );
		//Player.Stats[PlayerStat.OverrideNumPerkChoices] = 6f;
		Player.Modify( this, PlayerStat.CantMoveWhileChoosing, 1f, ModifierType.Add );
		DisplayText = "🤔";

		// todo: lasts until you choose 2 perks?
	}

	// todo: in Update, keep wobbling/scaling the perk while we can't move

	public override void OnChoosePerk( TypeDescription type )
	{
		base.OnChoosePerk( type );

		Player.StopModifying( this, PlayerStat.NumPerkChoices );
		Player.StopModifying( this, PlayerStat.CantMoveWhileChoosing );
		DisplayText = " ";
	}

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

		if ( Player.Stats[PlayerStat.CantMoveWhileChoosing] > 0f )
			Highlight();
	}

	private static float GetValue( int level, Mod mod, bool isPercent = false )
	{
		switch ( mod )
		{
			case Mod.NumPerkChoices:
			default:
				return 4;
		}
	}
}