Skip to content

Commit

Permalink
Update StackOverflowModule locking, version 0.1.13
Browse files Browse the repository at this point in the history
  • Loading branch information
Anatoly Brizhan committed May 21, 2024
1 parent 1b5b0df commit c212a89
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
21 changes: 12 additions & 9 deletions Assets/BetterStateMachine/Runtime/Modules/StackOverflowModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,17 @@ public void Unlock()

protected internal override bool AllowChangeState(IStateMachine<TState> stateMachine, TState state)
{
return base.AllowChangeState(stateMachine, state) && !IsLocked;
if (!base.AllowChangeState(stateMachine, state))
{
return false;
}

if (Depth >= OverflowDepth)
{
Lock();
}

return !IsLocked;
}

protected internal override void OnStatePreChanged(IStateMachine<TState> stateMachine, TState state)
Expand All @@ -47,11 +57,6 @@ protected internal override void OnStatePreChanged(IStateMachine<TState> stateMa

Depth++;
MaxDepth = Mathf.Max(MaxDepth, Depth);

if (Depth >= OverflowDepth)
{
Lock();
}
}

protected internal override void OnStateChanged(IStateMachine<TState> stateMachine, TState state)
Expand All @@ -65,9 +70,7 @@ protected internal override void OnMachineStopped(IStateMachine<TState> stateMac
{
base.OnMachineStopped(stateMachine);

Depth = 0;
MaxDepth = 0;
IsLocked = false;
Unlock();
}
}
}
2 changes: 1 addition & 1 deletion Assets/BetterStateMachine/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.tdw.better.statemachine",
"displayName": "Better State Machine",
"version": "0.1.12",
"version": "0.1.13",
"unity": "2021.3",
"description": " ",
"dependencies": {
Expand Down

0 comments on commit c212a89

Please sign in to comment.