A unique perk class that slightly alters player movement and dash behavior. When active it nudges the player side-to-side while moving on the ground, and has a chance to instantly recharge the dash when a dash starts.
using System;
using Sandbox;
[Perk( Rarity.Unique, disabled: true, alwaysOfferDebug: false )]
public class PerkShuffleSideToSide : Perk
{
private enum Mod { Chance, };
static PerkShuffleSideToSide()
{
//Register<PerkShuffleSideToSide>(
// name: "Antsy",
// imagePath: "textures/icons/vector/shuffle_side_to_side.png",
// description: level => $"{GetValue( level, Mod.Chance, true )}% chance to dash for free, but shuffle from side to side while moving",
// upgradeDescription: level => $"{GetValue( level - 1, Mod.Chance, true )}%→{GetValue( level, Mod.Chance, true )}% chance to dash for free, but shuffle from side to side while moving"
//);
}
public override void Start()
{
base.Start();
ShouldUpdate = true;
}
public override void Refresh()
{
base.Refresh();
}
public override void Update( float dt )
{
base.Update( dt );
if ( Player.IsInTheAir || !Player.IsMoving )
return;
// todo: find a different downside?
// todo: make this a curse instead
Player.Position2D += Utils.GetPerpendicularVector( Player.FacingDir ) * Utils.FastSin( Time.Now * 5f ) * 60f * Player.GetMoveSpeedMultiplier() * dt;
}
public override void OnDashStarted( Vector2 dir )
{
base.OnDashStarted( dir );
if ( Game.Random.Float( 0f, 1f ) < GetValue( Level, Mod.Chance ) )
{
Player.RechargeDashInstantly();
}
}
private static float GetValue( int level, Mod mod, bool isPercent = false )
{
switch ( mod )
{
case Mod.Chance:
default:
return isPercent
? 30f
: 0.30f;
}
}
}