Skip to content
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

Static class usage #175

Closed

Conversation

GenerelSchwerz
Copy link

This PR is breaking.

To alleviate some of the boilerplate (making new variables for every transition), I have abstracted the class creation process into the state-machine itself. Behaviors and nested machines alike are provided to the state machine in static form. Access to the individual classes are provided only while the class is active, usually through shouldTransition.

The examples are not yet complete, so consider this branch W.I.P.

@sefirosweb
Copy link
Contributor

@GenerelSchwerz I see are you modifing the core of package, maybe you are developing your own package and this pr must be close?

@GenerelSchwerz
Copy link
Author

@GenerelSchwerz I see are you modifing the core of package, maybe you are developing your own package and this pr must be close?

Probably, I decided to open a PR in case the Prismarine devs wanted to switch. Probably not though.

@GenerelSchwerz
Copy link
Author

GenerelSchwerz commented Mar 9, 2023

Typings within this version are vebose (to say the least) but are completely functional.

Added functionality:

Backend/functionality
======================
1. immediate chained state switching.
-  re-iterate over transitions after change in case other transitions are now true.

2. multiple parent states for transitions.
-  provides strongly typed union for shouldTransition.

3. Wildcard implementation.
-  provided wildcard transitions will be checked regardless of currently active state.

# Frontend/utility
======================
1. Positions for states can be set per state machine instead of globally.
-  Positions are not provided on the behaviors themselves, instead they are provided to a handler.

2. Exit states will be colored.
-  Wildcard states may also become colored in the future.

@extremeheat
Copy link
Member

As Frej mentioned on the Discord you can apply these changes on sefiros' change_nested_layout_bar branch to avoid a conflict later on after #172 gets merged

@GenerelSchwerz
Copy link
Author

As Frej mentioned on the Discord you can apply these changes on sefiros' change_nested_layout_bar branch to avoid a conflict later on after #172 gets merged

Sure, I can do that. 👍

@rom1504
Copy link
Member

rom1504 commented May 20, 2023

@GenerelSchwerz this seems to be changing everything

could be considered to merge but only if you then want to maintain it. Is it the case?

@GenerelSchwerz
Copy link
Author

GenerelSchwerz commented Jan 10, 2024

I moved this PR to a new repository: https://github.com/GenerelSchwerz/mineflayer-static-statemachine

There are a lot of additions/improvements I have added to that project that I will try to move here in time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

4 participants