Seldom-SE / seldom_state

Component-based state machine plugin for Bevy. Useful for AI, player state, and other entities that occupy different states.
Apache License 2.0
172 stars 18 forks source link

Rewrite the plugin to run in an exclusive system #1

Closed deifactor closed 1 year ago

deifactor commented 1 year ago

The motivation for this was that it lets us get rid of all the Bevy reflection machinery and the requirement to register every trigger (which makes 'trigger combinators' much harder to use). The downside is that the triggers and transitions now run in an exclusive system, which could be worse for performance. We can ameliorate this using the ComputeTaskPool to spread running the machine across threads.

I also added some functionality tests.

I kept the Reflect bound on MachineState, even though it's probably not necessary, in case it winds up being useful for better debugging information or something later.

(Suggestion: don't review the PR one commit at a time, it's a bit messy; just look at the final diff.)

Breaking changes

Seldom-SE commented 1 year ago

Thanks!