Skip to content

Commit

Permalink
Refactor StateMachine.ProcessTransitionInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
bazyleu committed Sep 2, 2024
1 parent 9c2bf10 commit 0da88d3
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions Assets/UniState/Runtime/Core/StateMachine/StateMachine.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Threading;
using Cysharp.Threading.Tasks;
using UniState;

namespace UniState
{
Expand Down Expand Up @@ -96,26 +95,23 @@ private void ProcessTransitionInfo(StateTransitionInfo nextTransition,
{
stateWithMetadata.Clear();

if (nextTransition.Transition != TransitionType.Exit)
if (nextTransition.Transition == TransitionType.Exit)
{
var item = nextTransition;
return;
}

if (nextTransition.Transition == TransitionType.State)
{
if (previousTransition != null)
{
_history.Push(previousTransition);
}
}
else
{
item = GetInfoFromHistory();
}
var transitionToState = nextTransition.Transition == TransitionType.State;

if (item != null)
{
stateWithMetadata.BuildState(item, item.StateBehaviourData);
}
var item = transitionToState ? nextTransition : GetInfoFromHistory();

if (transitionToState && previousTransition != null)
{
_history.Push(previousTransition);
}

if (item != null)
{
stateWithMetadata.BuildState(item, item.StateBehaviourData);
}
}

Expand Down

0 comments on commit 0da88d3

Please sign in to comment.