Class ConditionalGameAction<TContext>
- Namespace
- ElectricDrill.AstraRpgFramework.GameActions.Actions
- Assembly
- com.electricdrill.astra-rpg-framework.Runtime.dll
Wraps another GameAction<TContext> with an optional Condition guard. If the condition evaluates to false, the inner action is skipped. A null condition is treated as always-true.
public abstract class ConditionalGameAction<TContext> : GameAction<TContext>, IExecutable<TContext>, ITaggable
Type Parameters
TContext
- Inheritance
-
objectGameAction<TContext>ConditionalGameAction<TContext>
- Implements
-
IExecutable<TContext>
- Derived
- Inherited Members
Methods
BuildEvaluationContext(TContext, MonoBehaviour)
Builds the EvaluationContext passed to the condition from the action context.
protected abstract EvaluationContext BuildEvaluationContext(TContext context, MonoBehaviour runtimeOwner)
Parameters
contextTContextThe action context (event payload).
runtimeOwnerMonoBehaviourThe MonoBehaviour that owns this action invocation at runtime. Used to populate Holder. May be
nullin legacy ownerless execution paths.
Returns
ExecuteAsync(TContext, CancellationToken)
Executes the action asynchronously with the provided context. Override this method to implement your action logic.
public override Awaitable ExecuteAsync(TContext context, CancellationToken cancellationToken = default)
Parameters
contextTContextThe context object containing information needed for execution.
cancellationTokenCancellationTokenToken to cancel the operation. MonoBehaviour owners can use their "destroyCancellationToken" to automatically cancel when destroyed.
Returns
- Awaitable
An Awaitable that completes when the action finishes.
ExecuteWithOwnerAsync(TContext, MonoBehaviour, CancellationToken)
Owner-aware execution path. The runtimeOwner identifies the
MonoBehaviour (typically a listener or runner) whose entity is the logical owner of this
action invocation. Wrapper actions must override this to forward the owner to children.
The default implementation ignores the owner and delegates to ExecuteAsync(TContext, CancellationToken), so leaf actions that do not need owner information require no changes.
public override Awaitable ExecuteWithOwnerAsync(TContext context, MonoBehaviour runtimeOwner, CancellationToken cancellationToken = default)
Parameters
contextTContextThe context object containing information needed for execution.
runtimeOwnerMonoBehaviourThe MonoBehaviour that owns this action invocation at runtime. Used by conditional actions to populate
EvaluationContext.Holder.cancellationTokenCancellationTokenToken to cancel the operation.
Returns
- Awaitable
An Awaitable that completes when the action finishes.