A player perk class that continuously rotates the player's aim, implemented as a curse. It sets an update flag on Start, subtracts a small angle from Player.BodyAimOffset each Update, and resets the offset on Remove.
using Sandbox;
[Perk( Rarity.Unique, curse: true, disabled: true, alwaysOfferDebug: false )]
public class CurseRotateAim : Perk
{
private const float RotateDegreesPerSecond = 10f;
//static CurseRotateAim()
//{
// Register<CurseRotateAim>(
// name: "Dizzy",
// imagePath: "textures/icons/vector/blank_icon.png",
// description: level => $"Your facing direction continuously rotates"
// );
//}
public override void Start()
{
base.Start();
ShouldUpdate = true;
}
public override void Update( float dt )
{
base.Update( dt );
Player.BodyAimOffset -= RotateDegreesPerSecond * Player.TimeScale * dt;
}
public override void Remove( bool restart = false )
{
base.Remove( restart );
Player.BodyAimOffset = 0f;
}
}