-
Notifications
You must be signed in to change notification settings - Fork 26
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
Add multiple concurrent conditions support #30
Comments
Cool! I always wanted to support complex condition. However, there's something that concerns me:
My point of view is that such system should be as simple as possible and readability is the key. For me myself, I still haven't figured out the perfect way to tackle this feature. The best I can think of is an ExpressionCondition |
Talking of ExpressionCondition, I just implemented one in my branch. It uses params, but the expression itself is in the condition. The code for it is dead simple. I'm just inputting the params and their values as Expression input variables. Expression is one heck of a class. |
It was essential to me to have these condition groups, because now, I can further dissociate behavior from the code. Imagine a button that triggers "skip" to the state machine. And you have a state Cutscene that can transition in the state Game if "skip" is triggered or if "cutscene_end" is triggered. The skip button does not have to implement "cutscene_end" or trigger a function that, depending on the context, will trigger cutscene_end if your're in the state Cutscene. We can now more easily use triggers like "timeout" made by Timers, as an example. Then, using the FSM, behavior will follow if implemented. Less need to implement logic that will trigger specific triggers if conditions are reunited. |
Just did a quick test on the PR and it is impressive!
|
Mmm. I'll think about it! It could simplify stuff, sure. Like, you're right, everything done with condition groups are done with expression conditions. But at the cost of readability. As every condition are "AND" binded, I kinda suspect that expressions will be bloated when the complexity of a transition is anything more than simple. Imagine something like With condition groups, expressions have more chances to be kept small. And expressions are less needed. Like in the last example, no need for expressions. |
From perspective of UI, both expression and condition group has their own strength & weakness. Expression looks minimal in inspector while condition group looks more organized in graph. By comparison, yes, condition group is definitely easier to read in the graph, but the long expression is still very self explaining, while it can still be beautified by wrapping text or even syntax highlighting or break expression into boxes like condition group. But what really makes me leans toward expression is that it is more flexible, users are free to write expression from any levels of complexity. For example, expression like So, the workflow with ExpressionCondition would somehow look like this:
|
Transitions should support concurrent conditions. Being able to transit on condition groups instead of simple conditions.
Each condition in the condition group must be true for the condition group to be true. But if a condition group of many is true, the transition is done.
I built a working prototype, but this will need some polish to clean up things.
https://github.com/adamscott/gd-YAFSM/tree/condition-groups
The text was updated successfully, but these errors were encountered: