NodeCanvas Forums › General Discussion › Enum as Flag actions
Is there any chance you can add these flag enum actions to NodeCanvas by default?
I was surprised that the built-in enum actions doesn’t handle flag enums so I implemented them in couple of hours but I think they really need to be part of NodeCanvas.
Hey,
The SetEnum and CheckEnum included also work for setting and checking a flags enum.
Have you tried them out?
Let me know. Thanks 🙂
Join us on Discord: https://discord.gg/97q2Rjh
I tried them and looked at their implementations. They don’t look like designed for flag enums. For example, they don’t have the actual flag selection parameter. Without a flag selection and set/clear option, how can they work with flag enums?
I am confused.
Did you look at my implementations?
Hello again,
I did check your implementations but in practice works the same way as the included ones in the end unless I am missing something.
Can you please clarify what was the problem you faced (or differences) with the ones included?
Here is an enum flags I’ve tested.
1 2 3 4 5 6 7 8 9 10 |
[System.Flags] public enum MyEnumFlag { None = 0, Red = 1, Green = 2, Blue = 4, } |
Thank you.
Join us on Discord: https://discord.gg/97q2Rjh
Hi again.
The purpose of flag enum is to be able to set, clear and check each bit (sometimes multiple bits) of the enum on demand via bitwise operations and to be able to do that, the action needs a bit selection parameter.
Your built-in enum action doesn’t have such parameter but my version has.
Have you added my action onto a BT and see how it looks and is used?
I’ll send you a screenshot.
Here is the screenshot. This is how we use flag enums. It’s just same as C# but instead, it’s in a BT canvas.
Hello again and sorry for the late reply!
Oooh. I see now 🙂 Thanks a lot for the details.
I was confused by the naming of the tasks for some reason, expecting to check if the enum is exactly the same (flags) as the check value, or in case of set, set the target enum to be the same as the source. But I see now this is not the case at all and your tasks are actually very useful.
I will certainly add them in for the next version.
Thank you and sorry for my misunderstanding!
Join us on Discord: https://discord.gg/97q2Rjh
Amazing! I’m glad to help improve the Node Canvas.
Btw, in my screenshot, do you see what I did in “Skip after load” group?
I think it would be very nice to have a new composite node for “skip” logic instead of being have to add a “no task” action to the true leg of binary selector. By doing that, I prevent the binary selector to return fail status when the condition is true and I don’t wanna perform an action.
So basically, the new composite would be a selector with only one leg. If the condition is good (or bad), it runs (or skips) the leg.
I repeat this skip logic many times in my BTs. It would be amazing to have a single composite instead of two nodes and a group around them to explain.
Hello again and sorry for the super late reply!
I see it now 🙂
There is a similar node to what you are looking for (I think), which is the Conditional Decorator. It has only one child and takes a condition (which can be inverted of course like all conditions can). So it can be used like “If NOT [condition]” then it returns. The main difference here is that it will return Failure (instead of Success like in your case), but I could add an option in the Conditional Decorator inspector for what to return in case the condition is false (instead of always returning Failure as it is now).
Let me know.
Thanks!
Join us on Discord: https://discord.gg/97q2Rjh
Hello again.
I am aware of the Conditional decorator but as you mentioned, it returns a failure. It would be AMAZING if you could add an option to prevent failure.
Thank you very much.
When can I expect to see a new version on asset store which includes the new flag actions and non-failure conditional decorator?
Do you send unreleased packages for users with invoice?
Hello again and sorry for the super late reply!
I have just modified Conditional Decorator to have the option to return Success or Failure (default is of course Failure like before). I have attached the modified file for you here as well.
A new version will appear online as soon as I complete working on a new planned feature to warrant a new version, unless some important bug is found in which case an immediate hotfix will take place (thankfully none right now) :).
Also yes, I do send local versions to users with invoice over email no problem. Let me know if you want to 🙂 (support_AT_paradoxnotion.com).
Thanks!
Join us on Discord: https://discord.gg/97q2Rjh
This is awesome news and you are an amazing asset store publisher!