Hello, while working with input control for Abilities, I've noticed that it's possible to extend the logic for starting abilities by inheriting from the AbilityStarter type. However, there is no equivalent for stopping abilities, an AbilityStopper. It could have the same structure as AbilityStarter.
Here is an example:
Here is an example:
Code:
namespace Opsive.UltimateCharacterController.Character.Abilities.Stoppers
{
/// <summary>
/// The AbilityStopper allows a custom object to decide when the ability should stop.
/// </summary>
[System.Serializable]
[UnityEngine.Scripting.Preserve]
public abstract class AbilityStopper
{
protected Ability m_Ability;
/// <summary>
/// Initializes the stopper to the specified ability.
/// </summary>
/// <param name="ability">The ability that owns the stopper.</param>
public virtual void Initialize(Ability ability) { m_Ability = ability; }
/// <summary>
/// Can the stopper stop the ability?
/// </summary>
/// <param name="playerInput">A reference to the input component.</param>
/// <returns>True if the stopper can stop the ability.</returns>
public abstract bool CanInputStopAbility(IPlayerInput playerInput);
/// <summary>
/// The ability has started.
/// </summary>
public virtual void AbilityStarted() { }
/// <summary>
/// The ability has stopped running.
/// </summary>
public virtual void AbilityStopped() { }
/// <summary>
/// The object has been destroyed.
/// </summary>
public virtual void OnDestroy() { }
}
}