-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from bazyleu/feature/state-machine-updates
Updates state machine error handling, improve tests, update README.md
- Loading branch information
Showing
19 changed files
with
249 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
Assets/UniState/Runtime/Core/StateMachine/StateMachineErrorData.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
|
||
namespace UniState | ||
{ | ||
public class StateMachineErrorData | ||
{ | ||
public Exception Exception { get; } | ||
public StateMachineErrorType ErrorType { get; } | ||
public IExecutableState State { get; } | ||
|
||
public StateMachineErrorData(Exception exception, StateMachineErrorType errorType, IExecutableState state = null) | ||
{ | ||
Exception = exception; | ||
ErrorType = errorType; | ||
State = state; | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
Assets/UniState/Runtime/Core/StateMachine/StateMachineErrorData.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
Assets/UniStateTests/PlayMode/GoToStateTests/Infrastructure/CompositeStateGoTo7.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using System.Threading; | ||
using Cysharp.Threading.Tasks; | ||
using UniState; | ||
using UniStateTests.Common; | ||
|
||
namespace UniStateTests.PlayMode.GoToStateTests.Infrastructure | ||
{ | ||
internal class CompositeStateGoTo7: DefaultCompositeState<CompositeStatePayload> | ||
{ | ||
|
||
} | ||
|
||
internal class SubStateGoToX7A : SubStateBase<CompositeStateGoTo7, CompositeStatePayload> | ||
{ | ||
private readonly ExecutionLogger _logger; | ||
|
||
public SubStateGoToX7A(ExecutionLogger logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
public override async UniTask<StateTransitionInfo> Execute(CancellationToken token) | ||
{ | ||
_logger.LogStep("SubStateGoToX7A", $"Execute:{Payload.DelayFirstSubState}"); | ||
|
||
if (Payload.DelayFirstSubState) | ||
{ | ||
await UniTask.Yield(token); | ||
await UniTask.Yield(token); | ||
await UniTask.Yield(token); | ||
await UniTask.Yield(token); | ||
await UniTask.Yield(token); | ||
} | ||
|
||
await UniTask.Yield(token); | ||
await UniTask.Yield(token); | ||
|
||
return Transition.GoTo<IStateGoTo8, bool>(true); | ||
} | ||
} | ||
|
||
internal class SubStateGoToX7B : SubStateBase<CompositeStateGoTo7, CompositeStatePayload> | ||
{ | ||
private readonly ExecutionLogger _logger; | ||
|
||
public SubStateGoToX7B(ExecutionLogger logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
public override async UniTask<StateTransitionInfo> Execute(CancellationToken token) | ||
{ | ||
await UniTask.Yield(token); | ||
|
||
_logger.LogStep("SubStateGoToX7B", $"Execute:{Payload.DelayFirstSubState}"); | ||
|
||
await UniTask.Yield(token); | ||
await UniTask.Yield(token); | ||
|
||
return Transition.GoTo<StateGoTo8, bool>(false); | ||
} | ||
} | ||
|
||
internal class CompositeStatePayload | ||
{ | ||
public bool DelayFirstSubState { get; } | ||
|
||
public CompositeStatePayload(bool delayFirstSubState) | ||
{ | ||
DelayFirstSubState = delayFirstSubState; | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
Assets/UniStateTests/PlayMode/GoToStateTests/Infrastructure/CompositeStateGoTo7.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
Assets/UniStateTests/PlayMode/GoToStateTests/Infrastructure/StateGoTo8.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System.Threading; | ||
using Cysharp.Threading.Tasks; | ||
using UniState; | ||
using UniStateTests.Common; | ||
|
||
namespace UniStateTests.PlayMode.GoToStateTests.Infrastructure | ||
{ | ||
internal interface IStateGoTo8 : IState<bool> | ||
{ | ||
} | ||
|
||
internal class StateGoTo8 : StateBase<bool>, IStateGoTo8 | ||
{ | ||
private readonly ExecutionLogger _logger; | ||
|
||
public StateGoTo8(ExecutionLogger logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
public override UniTask<StateTransitionInfo> Execute(CancellationToken token) | ||
{ | ||
_logger.LogStep("StateGoTo8", $"Execute:{Payload}"); | ||
|
||
if (Payload) | ||
{ | ||
return UniTask.FromResult(Transition.GoToExit()); | ||
} | ||
|
||
return UniTask.FromResult(Transition.GoTo<CompositeStateGoTo7, CompositeStatePayload>(new CompositeStatePayload(false))); | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
Assets/UniStateTests/PlayMode/GoToStateTests/Infrastructure/StateGoTo8.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.