ThePat02 / BehaviourToolkit

A collection of tools for AI Behaviour in the Godot 4 Game Engine!
MIT License
303 stars 12 forks source link

add: Dynamic changes to Behaviour Patterns at runtime Nr.2 #73

Open SirPigeonz opened 6 months ago

SirPigeonz commented 6 months ago

This PR makes both FSM and BTree systems work properly when their nodes are moved, removed, added at runtime.

On top of that many nodes are now fine when they don't have important for them nodes as a child or property references. This allows for preparing "empty" slots for intended behaviours or branches and modeling main behaviours with them, that is "slots", in mind. Upcomming warning system can be used instead for important configuration warnings when behaviours are created by hand in the Editor.

Changes:

Changes after review 1

Changes after review 2

If you wish to add, remove, move FSMState nodes at run-time first add new FSMStates stop the FSM with method FiniteStateMachine.exit_active_state_and_stop and re-start it with method method FiniteStateMachine.start providing one of the new states either as start method property or change member FiniteStateMachine.initial_state before running start(). After this procedure you can delete unused states.

SirPigeonz commented 6 months ago

Resubmit of #47

SirPigeonz commented 5 months ago

@ThePat02 Rebased the branch ready for final review! :)

ThePat02 commented 5 months ago

Can you give me a quick overview of the changes? I'll look into it later this week!

SirPigeonz commented 5 months ago

Can you give me a quick overview of the changes? I'll look into it later this week!

Not much from last time you checked. I just had to fix PR because its previous target branch was deleted.

In rebase, I just had to merge few minor stuff mostly, conflicts in documentation. There is now more info how nodes work internally and how to work with them dynamically at runtime if somebody wishes to use that.

I also slightly modified some warning so they will be less, "you can't" -> "you shouldn't, but it's fine if you want to do it".

If you ask about most of the patch, summarizing it's mostly making base nodes smarter when handling non-typical setups, so they will not do weird stuff while being modified at runtime. Plus, it allows for some nice tricks using Godot node/scene system.

On top of that, some API to make modifying BT setup at runtime easier and cleaner. Although using standard API for nodes should still work, user just needs to be more aware how the BT nodes work internally.

ThePat02 commented 5 months ago

On top of that, some API to make modifying BT setup at runtime easier and cleaner. Although using standard API for nodes should still work, user just needs to be more aware how the BT nodes work internally.

Great, I will take a closer look on that too! Thanks for your effort!