Skip to content

Commit 94f316f

Browse files
committed
Allow for runtime changes to needsExitTime etc.
- Removed the "readonly" modifier to fields such as needsExitTime and forceInstantly. This allows them to be changed at runtime, increasing the flexibility of UnityHFSM - Added documentation describing when these runtime changes have an effect See issue #71
1 parent 0733c63 commit 94f316f

2 files changed

Lines changed: 42 additions & 3 deletions

File tree

src/Base/StateBase.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,29 @@ namespace UnityHFSM
88
/// </summary>
99
public class StateBase<TStateId> : IVisitableState
1010
{
11-
public readonly bool needsExitTime;
12-
public readonly bool isGhostState;
11+
/// <summary>
12+
/// If true, the state machine will wait for this state to signal it is "ready to exit"
13+
/// before allowing a transition to occur.
14+
/// </summary>
15+
/// <remarks>
16+
/// Changes to this at runtime only take effect the next time a transition is evaluated on this state.
17+
/// </remarks>
18+
public bool needsExitTime;
19+
/// <summary>
20+
/// When entered, the state machine will immediately check this state's outgoing transitions
21+
/// and move to the next valid state within the same update tick if possible.
22+
/// </summary>
23+
/// <remarks>
24+
/// Changes to this at runtime only take effect the next this state is entered.
25+
/// </remarks>
26+
public bool isGhostState;
27+
28+
/// <summary>
29+
/// The unique identifier used to reference this state within the state machine.
30+
/// </summary>
31+
/// <remarks>
32+
/// This field should not be changed once this state has been added to a state machine.
33+
/// </remarks>
1334
public TStateId name;
1435

1536
public IStateTimingManager fsm;

src/Base/TransitionBase.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,25 @@ public class TransitionBase<TStateId> : ITransitionListener
99
public readonly TStateId from;
1010
public readonly TStateId to;
1111

12-
public readonly bool forceInstantly;
12+
/// <summary>
13+
/// If true, the state machine will ignore the current state's needsExitTime behaviour to immediately
14+
/// transition to the 'to' state as soon as the condition is met.
15+
/// </summary>
16+
/// <remarks>
17+
/// Changing this value at runtime will only take effect the next time the state machine
18+
/// evaluates this transition.
19+
/// </remarks>
20+
public bool forceInstantly;
21+
22+
/// <summary>
23+
/// Indicates if this transition is specifically designed to exit a nested
24+
/// state machine and return control to the parent state machine.
25+
/// </summary>
26+
/// <remarks>
27+
/// Changing this value at runtime will only take effect the next time the state machine
28+
/// evaluates this transition. <para/>
29+
/// If this field is true, the 'to' state is irrelevant (and can have any value).
30+
/// </remarks>
1331
public bool isExitTransition;
1432

1533
public IStateMachine<TStateId> fsm;

0 commit comments

Comments
 (0)