A unique Fear-category perk called "Terror Dash". It configures visual highlight properties and, while the player is dashing, causes collided enemy Unit instances that are alive and animate to become fearful for a duration taken from the player's FearLifetime stat.
using System;
using Sandbox;
[Perk( Rarity.Unique, alwaysOfferDebug: false, IncludedCategories = new[] { PerkCategory.Fear })]
public class PerkFearDash : Perk
{
static PerkFearDash()
{
Register<PerkFearDash>(
name: "Terror Dash",
imagePath: "textures/icons/vector/fear_dash.png",
description: level => $"Scare enemies you\ntouch while dashing"
);
}
public override void Start()
{
base.Start();
HighlightColor = new Color( 0.1f, 0f, 0.25f );
HighlightDuration = 0.2f;
HighlightOpacity = 2f;
}
public override void Refresh()
{
base.Refresh();
}
public override void Colliding( Thing other, float percent, float dt )
{
base.Colliding( other, percent, dt );
if ( Player.IsDashing && other is Unit unit && !unit.IsDying && !unit.IsInanimate && !unit.IsFearful )
{
unit.Fear( Player, enemySource: null, lifetime: Player.Stats[PlayerStat.FearLifetime] );
Highlight();
}
}
}