The Generic ability is very versatile. But if you have more than one, then you need to depend on the index order to retrieve the correct ability. Using order for retrieval can easily lead to configuration bugs.
The AbilityIndexParameter would typically be unique for multiple instances of the Generic ability. Having a method in UltimateCharacterLocomotion to retrieve abilities by type and the AbilityIndexParameter would make retrieval more targeted when several abilities of the same type exist.
For example:
The AbilityIndexParameter would typically be unique for multiple instances of the Generic ability. Having a method in UltimateCharacterLocomotion to retrieve abilities by type and the AbilityIndexParameter would make retrieval more targeted when several abilities of the same type exist.
For example:
C#:
/// <summary>
/// Returns the ability of type T with the specified Ability Index.
/// </summary>
/// <typeparam name="T">The type of ability to return.</typeparam>
/// <param name="abilityIndex">The Ability Index</param>
/// <returns>The ability of type T with the specified index. Can be null.</returns>
public T GetAbilityByAbilityIndex<T>(int abilityIndex) where T : Ability
{
return GetAbility(typeof(T), abilityIndex) as T;
}
/// <summary>
/// Returns the ability of the specified type with the Ability index.
/// </summary>
/// <param name="type">The type of ability to return.</param>
/// <param name="abilityIndex">The Ability Index</param>
/// <returns>The ability of the specified type with the specified ability index. Can be null.</returns>
public Ability GetAbilityByAbilityIndex(System.Type type, int abilityIndex)
{
var allAbilities = (typeof(ItemAbility).IsAssignableFrom(type) ? m_ItemAbilities : m_Abilities);
if (allAbilities != null)
{
for (int i = 0; i < allAbilities.Length; ++i)
{
if (type.IsInstanceOfType(allAbilities[i]) && (allAbilities[i].AbilityIndexParameter == abilityIndex))
{
return allAbilities[i];
}
}
}
return null;
}
Last edited: