IAbilityController - jimdroberts/FishMMO GitHub Wiki

Description

Interface for ability controllers, managing ability activation, events, and known abilities. Provides a contract for handling ability-related logic, events, and state within the FishMMO infrastructure.


API Access

Fields

Properties

  • Dictionary<long, Ability> KnownAbilities

    Dictionary of known abilities by ID.

  • HashSet KnownBaseAbilities

    Set of known base ability IDs.

  • HashSet KnownAbilityEvents

    Set of known ability event IDs.

  • HashSet KnownAbilityOnTickEvents

    Set of known OnTick event IDs.

  • HashSet KnownAbilityOnHitEvents

    Set of known OnHit event IDs.

  • HashSet KnownAbilityOnPreSpawnEvents

    Set of known OnPreSpawn event IDs.

  • HashSet KnownAbilityOnSpawnEvents

    Set of known OnSpawn event IDs.

  • HashSet KnownAbilityOnDestroyEvents

    Set of known OnDestroy event IDs.

  • bool IsActivating

    True if an ability is currently activating.

  • bool AbilityQueued

    True if an ability is queued for activation.

Methods

  • void Interrupt(ICharacter attacker)

    Interrupts the current ability, optionally specifying the attacker. Parameters: ICharacter attacker — The character causing the interruption.

  • void Activate(long referenceID, KeyCode heldKey)

    Activates an ability by reference ID and held key. Parameters: long referenceID — The ability reference ID; KeyCode heldKey — The key held for activation.

  • void RemoveAbility(int referenceID)

    Removes an ability by reference ID. Parameters: int referenceID — The ability reference ID.

  • bool CanManipulate()

    Returns true if manipulation is allowed. Returns: bool — True if manipulation is allowed.

  • AbilityType GetCurrentAbilityType()

    Gets the current ability type. Returns: AbilityType — The current ability type.

  • bool IsCurrentAbilityTypeAerial()

    Returns true if the current ability type is aerial. Returns: bool — True if the current ability type is aerial.

  • CharacterAttributeTemplate GetActivationAttributeTemplate(Ability ability)

    Gets the activation attribute template for the given ability. Parameters: Ability ability — The ability to check. Returns: CharacterAttributeTemplate — The activation attribute template.

  • float CalculateSpeedReduction(CharacterAttributeTemplate attribute)

    Calculates the speed reduction for the given attribute. Parameters: CharacterAttributeTemplate attribute — The attribute to check. Returns: float — The calculated speed reduction.

  • bool KnowsAbility(int abilityID)

    Returns true if the controller knows the specified ability. Parameters: int abilityID — The ability ID. Returns: bool — True if the ability is known.

  • bool LearnBaseAbilities(List abilityTemplates = null)

    Learns the specified base abilities. Parameters: List abilityTemplates — The list of base ability templates (optional). Returns: bool — True if abilities were learned.

  • bool KnowsAbilityEvent(int eventID)

    Returns true if the controller knows the specified ability event. Parameters: int eventID — The event ID. Returns: bool — True if the event is known.

  • bool LearnAbilityEvents(List abilityEvents = null)

    Learns the specified ability events. Parameters: List abilityEvents — The list of ability events (optional). Returns: bool — True if events were learned.

  • bool KnowsLearnedAbility(int templateID)

    Returns true if the controller knows the specified learned ability. Parameters: int templateID — The template ID. Returns: bool — True if the learned ability is known.

  • void LearnAbility(Ability ability, float remainingCooldown = 0.0f)

    Learns the specified ability, with optional cooldown. Parameters: Ability ability — The ability to learn; float remainingCooldown — The remaining cooldown time (optional).


Basic Usage

Setup

  1. Implement the IAbilityController interface in your character or controller class.
  2. Wire up the required events and properties to your ability system logic.
  3. Ensure all dependencies (such as Ability, BaseAbilityTemplate, AbilityEvent, etc.) are available and referenced.
  4. Initialize event handlers and state as needed in your implementation.

Example

// Example 1: Implementing IAbilityController in a character class
public class PlayerAbilityController : MonoBehaviour, IAbilityController
{
    // Implement all interface members and event wiring here
}

// Example 2: Activating an ability
abilityController.Activate(abilityReferenceID, KeyCode.Space);

Best Practices

  • Always check for null before invoking events to avoid runtime exceptions.
  • Use strongly-typed collections for known abilities and events to ensure type safety.
  • Keep ability logic modular and decoupled from unrelated systems.
  • Document custom implementations of the interface for maintainability.
⚠️ **GitHub.com Fallback** ⚠️