Weapons/Base/Effects/WeaponEffect.cs
namespace Opium;
public partial class WeaponEffect : CameraEffect
{
[Property] public BaseWeapon Weapon { get; set; }
[Property, Group( "States" )] public bool UseState { get; set; } = false;
[Property, Group( "States" )] public AttackState State { get; set; } = AttackState.Inactive;
[Property, Group( "Timing" )] public bool UseTiming { get; set; } = false;
[Property, Group( "Timing" )] public float DestroyTime { get; set; } = 1f;
protected TimeSince LifeTime = 0;
protected TimeUntil TimeUntilDestroy { get; set; }
protected float Delta => TimeUntilDestroy.Fraction.Clamp( 0, 1 );
protected override void OnEnabled()
{
base.OnStart();
if ( UseTiming )
{
TimeUntilDestroy = DestroyTime;
}
}
public override bool TickEffect()
{
// If we're following the state and our current state doesn't match, kill the effect
if ( UseState && Weapon is MeleeWeapon melee && melee.CurrentAttack?.State != State )
{
return true;
}
if ( UseTiming && TimeUntilDestroy )
{
return true;
}
return base.TickEffect();
}
}