giusdp / bevy_talks

A Bevy plugin to write dialogues for your characters, together with player choices.
https://giusdp.github.io/bevy_talks/
Apache License 2.0
54 stars 6 forks source link

Refactor Dialogue Graph #40

Closed giusdp closed 8 months ago

giusdp commented 9 months ago

Currently the graph that models a conversation is implemented with petgraph and stored into a component Talk. This also keeps track of the start_node and current_node (these are NodeIndex).

There are also some helper components (CurrentText, CurrentActor, CurrentNodeKind...) that can be queried, but they are kinda useless since you just need to query for Talk and you can access all the info you need.

It would be interesting to try to model the graph as a bunch of entities:

We could have a root Entity that represents the entire dialogue graph (with some marker component). Then each children entity has the bundle of components to make it a "TalkNode". They each have the "Next" component so we know where it points to.

Perhaps we could use aery to add relationships between entities. Instead of using "Next" component to have a pointer to the next dialogue, we can put the 2 TalkNode entities in a relationship? We should investigate this.

The relationship can also be useful to tie together a TalkNode with the Actors. We ca have all the actors of a dialogue graph as their own entities (with the appropiate components) connected to each TalkNode in a relationship.