Class ScyllaTransition<TContext>
Delegate-based convenience implementation of IScyllaTransition<TContext> for code-first machine construction and tests.
Implements
Inherited Members
Namespace: Scylla.Core.Structures
Assembly: ScyllaCore.dll
Syntax
public sealed class ScyllaTransition<TContext> : IScyllaTransition<TContext>
Type Parameters
| Name | Description |
|---|---|
| TContext | The shared context type of the machine the transition belongs to. |
Remarks
machine.AddGlobalTransition(new ScyllaTransition<PlayerContext>(
deadState, ctx => ctx.Health <= 0f, priority: 100));
Constructors
ScyllaTransition(IScyllaState<TContext>, Func<TContext, bool>, int)
Creates a new delegate-based transition.
Declaration
public ScyllaTransition(IScyllaState<TContext> target, Func<TContext, bool> condition, int priority = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| IScyllaState<TContext> | target | The state the machine transitions to when the condition holds. |
| Func<TContext, bool> | condition | The side-effect-free condition deciding whether the transition fires. |
| int | priority | The evaluation priority; higher priorities are evaluated first. Defaults to |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when |
Properties
Priority
Gets the evaluation priority. Higher priorities are evaluated first; transitions of equal priority keep their registration order.
Declaration
public int Priority { get; }
Property Value
| Type | Description |
|---|---|
| int |
Target
Gets the state the machine transitions to when Evaluate(TContext) holds.
Declaration
public IScyllaState<TContext> Target { get; }
Property Value
| Type | Description |
|---|---|
| IScyllaState<TContext> |
Methods
Evaluate(TContext)
Returns whether the transition should fire. Must be side-effect-free.
Declaration
public bool Evaluate(TContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| TContext | context | The machine's shared context. |
Returns
| Type | Description |
|---|---|
| bool |
|