chickensoft-games / LogicBlocks

Human-friendly, hierarchical state machines for games and apps in C#.
https://www.nuget.org/packages/Chickensoft.LogicBlocks
MIT License
152 stars 6 forks source link

bug: `Logic.Stop()` does not detach and clear state #31

Closed lavstudia closed 4 months ago

lavstudia commented 4 months ago

Logic.Stop() does not Detach from the current state. You need to add Value.Detach() to Stop(). This leads to bugs that are difficult to track down.

definitelyokay commented 4 months ago

Okay, I'll get that fixed.

Desired behavior: once a logic block is stopped, it should fully detach the state after exiting and set its internal state to null, releasing the ending state to be collected by the GC and ensuring it can't cause postmortem side-effects. Note that this fix will also require you to Start() a stopped logic block to start it back up from its initial state, but that seems correct to me.

lavstudia commented 4 months ago

Great! It sounds logical and will be convenient to use. Thank you

definitelyokay commented 4 months ago

Just released version 4.2.2 with the fix for this in #32. Once it gets indexed on nuget in a few minutes, please update the reference in your project. Thanks for reporting this bug!