-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Release 0.9.3 #18
Release 0.9.3 #18
Conversation
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughThe changes include the addition of a new method Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Statechart
participant TaskWaitState
participant UniTask
User->>Statechart: Trigger Event
Statechart->>TaskWaitState: Call WaitingFor(Func<UniTask>)
TaskWaitState->>UniTask: Execute Async Operation
UniTask-->>TaskWaitState: Return Result
TaskWaitState-->>Statechart: Notify Completion
Statechart-->>User: Event Handling Complete
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
WalkthroughThe changes include the addition of a new method Changes
Uplevel your code reviews with CodeRabbit ProCodeRabbit ProIf you like this project, please support us by purchasing the Pro version. The Pro version has advanced context, superior noise reduction and several proprietary improvements compared to the open source version. Moreover, CodeRabbit Pro is free for open source projects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Files selected (6)
- CHANGELOG.md (8)
- Runtime/GameLovers.Statechart.asmdef (1)
- Runtime/IState.cs (2)
- Runtime/Internal/TaskWaitState.cs (4)
- Tests/Editor/GameLovers.Statechart.Editor.Tests.asmdef (1)
- Tests/Editor/StatechartTaskWaitTest.cs (5)
Files ignored due to filter (1)
- package.json
Files skipped from review due to trivial changes (1)
- Tests/Editor/GameLovers.Statechart.Editor.Tests.asmdef
Review comments generated (6)
- Review: 5
- LGTM: 1
Tips
Chat with
CodeRabbit Bot (@coderabbitai
)
- Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
- Invite the bot into a review comment chain by tagging
@coderabbitai
in a reply.
Code suggestions
- The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
- You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.
Pausing incremental reviews
- Add
@coderabbitai: ignore
anywhere in the PR description to pause further reviews from the bot.
using Cysharp.Threading.Tasks; | ||
using GameLovers.StatechartMachine; | ||
using NSubstitute; | ||
using NUnit.Framework; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Test] | ||
public async Task UniTaskWait_EventTrigger_DoesNothing() | ||
{ | ||
var statechart = new Statechart(SetupUniTaskWaitState); | ||
|
||
statechart.Run(); | ||
|
||
_caller.Received().OnTransitionCall(0); | ||
_caller.DidNotReceive().OnTransitionCall(1); | ||
_caller.DidNotReceive().OnTransitionCall(2); | ||
_caller.Received().InitialOnExitCall(0); | ||
_caller.Received().StateOnEnterCall(0); | ||
_caller.DidNotReceive().StateOnExitCall(0); | ||
_caller.DidNotReceive().FinalOnEnterCall(0); | ||
|
||
statechart.Trigger(_event); | ||
|
||
_blocker = false; | ||
|
||
await YieldWaitUniTask(); | ||
|
||
_caller.Received().OnTransitionCall(1); | ||
_caller.DidNotReceive().OnTransitionCall(2); | ||
_caller.Received().StateOnExitCall(0); | ||
_caller.Received().FinalOnEnterCall(0); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A new test method UniTaskWait_EventTrigger_DoesNothing()
has been added to test UniTask waiting functionality.
[Test]
public async Task UniTaskWait_EventTrigger_DoesNothing()
{
var statechart = new Statechart(SetupUniTaskWaitState);
statechart.Run();
_caller.Received().OnTransitionCall(0);
_caller.DidNotReceive().OnTransitionCall(1);
_caller.DidNotReceive().OnTransitionCall(2);
_caller.Received().InitialOnExitCall(0);
_caller.Received().StateOnEnterCall(0);
_caller.DidNotReceive().StateOnExitCall(0);
_caller.DidNotReceive().FinalOnEnterCall(0);
statechart.Trigger(_event);
_blocker = false;
await YieldWaitUniTask();
_caller.Received().OnTransitionCall(1);
_caller.DidNotReceive().OnTransitionCall(2);
_caller.Received().StateOnExitCall(0);
_caller.Received().FinalOnEnterCall(0);
}
|
||
private async UniTask UniTaskWaitAction() | ||
{ | ||
while (_blocker) | ||
{ | ||
await UniTask.Yield(); | ||
} | ||
|
||
_done = true; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private async UniTask YieldWaitUniTask() | ||
{ | ||
while (!_done) | ||
{ | ||
await UniTask.Yield(); | ||
} | ||
|
||
await UniTask.Yield(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private void SetupUniTaskWaitState(IStateFactory factory) | ||
{ | ||
var waiting = factory.TaskWait("Task Wait"); | ||
var final = SetupSimpleFlow(factory, waiting); | ||
|
||
waiting.OnEnter(() => _caller.StateOnEnterCall(0)); | ||
waiting.WaitingFor(UniTaskWaitAction).OnTransition(() => _caller.OnTransitionCall(1)).Target(final); | ||
waiting.OnExit(() => _caller.StateOnExitCall(0)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SetupUniTaskWaitState()
method has been added to set up the statechart for UniTask waiting.
private void SetupUniTaskWaitState(IStateFactory factory)
{
var waiting = factory.TaskWait("Task Wait");
var final = SetupSimpleFlow(factory, waiting);
waiting.OnEnter(() => _caller.StateOnEnterCall(0));
waiting.WaitingFor(UniTaskWaitAction).OnTransition(() => _caller.OnTransitionCall(1)).Target(final);
waiting.OnExit(() => _caller.StateOnExitCall(0));
}
Overall, the changes seem fine. However, there are a few suggestions to improve the code:
- Consistency: Ensure consistent ordering of
using
statements. It's recommended to group them by namespace and separate them with a blank line. - Naming: Consider using more descriptive names for variables and methods to improve code readability.
- Error Handling: Add appropriate error handling mechanisms, such as try-catch blocks, to handle exceptions that may occur during asynchronous operations.
Let me know if you have any questions or need further assistance!
New
Fixed
Summary by CodeRabbit
UniTask
in the game's statechart system, allowing for asynchronous operations and improved performance.TaskWaitState
class when usingUniTask
, ensuring smooth transitions between states.UniTask
waiting in the statechart system.CHANGELOG.md
file to reflect the changes made, including the addition of theWaitingFor
method andUniTask
support for WebGL.UniTask
usage in the project and testing environment.Summary by CodeRabbit
Release Notes for Version 0.9.3
New Features
UniTask
in theITaskWaitState
interface, allowing for enhanced asynchronous operations.WaitingFor(Func<UniTask>)
for improved flexibility in handling tasks.Improvements
UniTask
.Bug Fixes
Documentation