Class AbilityManager
Manages running, querying, stopping and interaction with abilities. Takes in an AbilityData as input that defines the set of abilities this actor have access to.
Inherited Members
Namespace: LobsterFramework.AbilitySystem
Assembly: LobsterFramework.dll
Syntax
[AddComponentMenu("AbilityManager")]
public class AbilityManager : ReferenceProvider
Remarks
All inqueries and ability manipulations should be done before the LateUpdate event. Doing it during the LateUpdate event could result in race conditions and other undefined behaviors. At runtime, the input AbilityData is duplicated so any modifications done to the original asset will not be reflected. However, the data used at runtime can be edited via the custom inspector of this component and saved as asset. When a new asset derived from the runtime data is saved to the disk, the input data reference will be redirected to that instead. The custom inspector does not allow adding or removing ability configurations to avoid breaking the running abilities.
Fields
| Improve this Doc View SourceActionBlocked
If this evaluates to true, all abilities are halted and no abilities can be enqueued.
Declaration
public readonly OrValue ActionBlocked
Field Value
Type | Description |
---|---|
OrValue |
Properties
| Improve this Doc View SourceIsAnimating
True if a animation of an ability is currently being played, false otherwise
Declaration
public bool IsAnimating { get; }
Property Value
Type | Description |
---|---|
bool |
Methods
| Improve this Doc View SourceAnimationEnd(AnimationEvent)
Used by animation events to signal the end of the ability. The ability will immediately terminate after this call. Do nothing if the event does not belong to the current ability animation.
Declaration
public void AnimationEnd(AnimationEvent animationEvent)
Parameters
Type | Name | Description |
---|---|---|
AnimationEvent | animationEvent | The animation event instance to be queried |
AnimationSignal(AnimationEvent)
Used by animation events to send signals
Declaration
public void AnimationSignal(AnimationEvent animationEvent)
Parameters
Type | Name | Description |
---|---|---|
AnimationEvent | animationEvent |
EnqueueAbilitiesInJoint<T, V>(string, string)
Enqueue two abilities of different types together with the second one being guaranteed to terminate no later than the first one.
Declaration
public bool EnqueueAbilitiesInJoint<T, V>(string instance1 = "default", string instance2 = "default") where T : Ability where V : Ability
Parameters
Type | Name | Description |
---|---|---|
string | instance1 | Name of the instance for the first ability |
string | instance2 | Name of the instance for the second ability |
Returns
Type | Description |
---|---|
bool |
Type Parameters
Name | Description |
---|---|
T | The type of the first ability |
V | The type of the second ability |
EnqueueAbility(Type, string)
Add an ability instance to the executing queue, return the status of this operation.
For this operation to be successful, the following must be satisfied:
- The entity must not be action blocked.
- The specified ability instance must be present
- The precondition of the specified ability instance must be satisfied.
- The ability instance must not be currently running or enqueued.
Note that this method should only be called before LateUpdate(), otherwise the ability instance execution will be deferred to the next frame. OnAbilityEnqueue() will be immediately called if enqueued successfully.
Declaration
public bool EnqueueAbility(Type abilityType, string instance = "default")
Parameters
Type | Name | Description |
---|---|---|
Type | abilityType | Type of the ability to be enqueued |
string | instance | Name of the instance to be enqueued |
Returns
Type | Description |
---|---|
bool | true if successfully enqueued the ability instance, false otherwise |
EnqueueAbility<T>(string)
Add an ability instance to the executing queue, return the status of this operation.
For this operation to be successful, the following must be satisfied:
- The entity must not be action blocked.
- The specified ability instance must be present
- The precondition of the specified ability instance must be satisfied.
- The ability instance must not be currently running or enqueued.
Note that this method should only be called before LateUpdate(), otherwise the ability instance execution will be deferred to the next frame. OnAbilityEnqueue() will be immediately called if enqueued successfully.
Declaration
public bool EnqueueAbility<T>(string instance = "default") where T : Ability
Parameters
Type | Name | Description |
---|---|---|
string | instance | Name of the instance to be enqueued |
Returns
Type | Description |
---|---|
bool | true if successfully enqueued the ability instance, false otherwise |
Type Parameters
Name | Description |
---|---|
T | Type of the Ability to be enqueued |
GetAbilityChannel<T>(string)
Get the ability channel of specified ability and configuration
Declaration
public AbilityChannel GetAbilityChannel<T>(string instance = "default") where T : Ability
Parameters
Type | Name | Description |
---|---|---|
string | instance | The name of the ability instance |
Returns
Type | Description |
---|---|
AbilityChannel | The channel that connects to the specified ability and configuration if it exists, otherwise return null. |
Type Parameters
Name | Description |
---|---|
T | The type of Ability this channel is associated with. |
GetAbilityComponent<T>()
Get the specified ability component if it is present.
Declaration
public T GetAbilityComponent<T>() where T : AbilityComponent
Returns
Type | Description |
---|---|
T | Return the ability component if it is present, otherwise null |
Type Parameters
Name | Description |
---|---|
T | Type of the AbilityComponent being requested |
InterruptAbilityAnimation()
Interrupt the currently playing ability animation, do nothing if no abilities is currently playing animation.
Declaration
public void InterruptAbilityAnimation()
IsAbilityReady(Type, string)
Check if the specified ability instance is ready
Declaration
public bool IsAbilityReady(Type abilityType, string instance = "default")
Parameters
Type | Name | Description |
---|---|---|
Type | abilityType | Type of the Ability to be queried |
string | instance | Name of the ability instance to be queried |
Returns
Type | Description |
---|---|
bool | true if the ability instance exists and is ready, false otherwise |
IsAbilityReady<T>(string)
Check if the specified ability instance is ready
Declaration
public bool IsAbilityReady<T>(string instance = "default") where T : Ability
Parameters
Type | Name | Description |
---|---|---|
string | instance | Name of the ability instance to be queried |
Returns
Type | Description |
---|---|
bool | true if the ability instance exists and is ready, false otherwise |
Type Parameters
Name | Description |
---|---|
T | Type of the Ability to be queried |
IsAbilityRunning(Type, string)
Check if the specified ability instance is running
Declaration
public bool IsAbilityRunning(Type abilityType, string instance = "default")
Parameters
Type | Name | Description |
---|---|---|
Type | abilityType | The type of the ability being queried |
string | instance | The name of the ability instance being queried |
Returns
Type | Description |
---|---|
bool | true if the ability instance exists and is running, otherwise false |
IsAbilityRunning<T>(string)
Check if the ability with specified config is running
Declaration
public bool IsAbilityRunning<T>(string instance = "default") where T : Ability
Parameters
Type | Name | Description |
---|---|---|
string | instance | The name of the ability instance being queried |
Returns
Type | Description |
---|---|
bool | true if the ability instance exists and is running, otherwise false |
Type Parameters
Name | Description |
---|---|
T | The type of the ability being queried |
JoinAbilities(Type, Type, string, string)
Join two running abilities such that the second ability terminates no later than the primary ability.
Declaration
public bool JoinAbilities(Type primaryAbility, Type secondaryAbility, string instance1 = "default", string instance2 = "default")
Parameters
Type | Name | Description |
---|---|---|
Type | primaryAbility | The type of the primary ability |
Type | secondaryAbility | The type of the secondary ability |
string | instance1 | The name of the primary ability instance |
string | instance2 | The name of the secondary ability instance |
Returns
Type | Description |
---|---|
bool | true on success, false otherwise |
JoinAbilities<T, V>(string, string)
Join two running abilities such that the second ability terminates no later than the primary ability.
Declaration
public bool JoinAbilities<T, V>(string instance1 = "default", string instance2 = "default") where T : Ability where V : Ability
Parameters
Type | Name | Description |
---|---|---|
string | instance1 | The name of the primary ability instance |
string | instance2 | The name of the secondary ability instance |
Returns
Type | Description |
---|---|
bool | true on success, false otherwise |
Type Parameters
Name | Description |
---|---|
T | The type of the primary ability |
V | The type of the secondary ability |
Reset()
Reset the status of all abilities and their configs to their initial state
Declaration
public void Reset()
Signal<T>(string)
Send a signal to the specified ability.
Declaration
public void Signal<T>(string instance = "default") where T : Ability
Parameters
Type | Name | Description |
---|---|---|
string | instance |
Type Parameters
Name | Description |
---|---|
T |
SuspendAbilities()
Stops execution of all abilities
Declaration
public void SuspendAbilities()
SuspendAbilityInstance(Type, string)
Stops the execution of the ability and returns the status of this operation
Declaration
public bool SuspendAbilityInstance(Type abilityType, string instance = "default")
Parameters
Type | Name | Description |
---|---|---|
Type | abilityType | Type of the ability to be stopped |
string | instance | Name of the ability instance to be stopped |
Returns
Type | Description |
---|---|
bool | true if the ability instance exists and is stopped, otherwise return false |
SuspendAbilityInstance<T>(string)
Stops the execution of the ability and returns the status of this operation
Declaration
public bool SuspendAbilityInstance<T>(string instance = "default") where T : Ability
Parameters
Type | Name | Description |
---|---|---|
string | instance | Name of the ability instance to be stopped |
Returns
Type | Description |
---|---|
bool | true if the ability instance exists and is stopped, otherwise return false |
Type Parameters
Name | Description |
---|---|
T | Type of the ability to be stopped |
SuspendAbility<T>()
Stop the execution of all instances of the specified ability
Declaration
public bool SuspendAbility<T>() where T : Ability
Returns
Type | Description |
---|---|
bool | true if the ability exists, otherwise false |
Type Parameters
Name | Description |
---|---|
T | The type of the ability to be stopped |
Events
| Improve this Doc View SourceOnAbilityEnqueued
Invoked when an ability is enqueued, the type of the ability is passed in as parameter.
Declaration
public event Action<Type> OnAbilityEnqueued
Event Type
Type | Description |
---|---|
Action<Type> |
OnAbilityFinished
Invoked when an ability is terminated, the type of the ability is passed in as parameter.
Declaration
public event Action<Type> OnAbilityFinished
Event Type
Type | Description |
---|---|
Action<Type> |
OnAnimationBegin
Invoked when an animation of an ability is initiated.
Declaration
public event Action<Type> OnAnimationBegin
Event Type
Type | Description |
---|---|
Action<Type> |
OnAnimationEnd
Invoked when an animation of an ability is terminated.
Declaration
public event Action<Type> OnAnimationEnd
Event Type
Type | Description |
---|---|
Action<Type> |