Actors/Mechanics/AttackStunMechanic.cs
using Opium.AI;

namespace Opium;

public partial class AttackStunMechanic : ActorMechanic
{
	[Property] public float StunTime { get; set; } = 1f;
	[Property] public float StunTraversalSpeed { get; set; } = 100f;

	TimeSince TimeSinceActive = 1f;

	public override bool ShouldBecomeActive()
	{
		if ( Actor is not Opium.PlayerController && Actor.TimeSinceLastDamage <= 0.1f && !IsActive )
		{
			return true;
		}

		return TimeSinceActive < StunTime;
	}

	protected override void OnActiveChanged( bool before, bool after )
	{
		if ( after )
		{
			TimeSinceActive = 0;
		}
	}

	public override void BuildWishInput( ref Vector3 wish )
	{
		wish = new( -1, 0, 0 );
	}

	public override float? GetSpeed()
	{
		return StunTraversalSpeed;
	}
}