diff --git a/src/builder/mod.rs b/src/builder/mod.rs index 9bd6158..45a8281 100644 --- a/src/builder/mod.rs +++ b/src/builder/mod.rs @@ -41,7 +41,7 @@ pub(crate) struct BuildNode { /// To build an entity dialogue graph you will define it with the `TalkBuilder` methods /// and finally call `build` to generate the `BuildTalkCommand`. /// -/// This [`Command`] is what will actually spawn all the entities, you will have to `add` it to the commands queue. +/// This `Command` is what will actually spawn all the entities, you will have to `add` it to the commands queue. /// /// ```rust,no_run /// use bevy::app::App; @@ -72,10 +72,6 @@ impl TalkBuilder { /// This function also validates the `Talk` asset (checks that the `next` and `choice.next` fields point to existing actions) /// and then fills the [`TalkBuilder`] with all the actions. /// - /// # Errors - /// - /// If the `TalkData` asset is not valid, this function will return a [`BuildTalkError`]. - /// /// # Example /// /// ```rust,no_run diff --git a/src/events.rs b/src/events.rs index ea733e3..c38a511 100644 --- a/src/events.rs +++ b/src/events.rs @@ -2,20 +2,20 @@ use bevy::prelude::{Entity, Event}; -/// Event to request the next action in a [`Talk`]. It requires an entity with the [`Talk`] component you want to update. +/// Event to request the next action in a `Talk`. It requires an entity with the `Talk` component you want to update. /// /// This event is typically used wired to an input from the player, e.g. a mouse click to advance the current dialogue. /// It can fail (and logs an error) in case there is no next action or in case the current action is a choice action. #[derive(Event)] pub struct NextActionRequest(pub Entity); -/// An event to jump to some specific node in a graph. It requires an entity with the [`Talk`] component you want to update. +/// An event to jump to some specific node in a graph. It requires an entity with the `Talk` component you want to update. /// /// It is typically used when you want to go to a target node from a choice node. /// The `ActionId` to jump to is the one defined in the next field for the Choice choosen by the player. #[derive(Event)] pub struct ChooseActionRequest { - /// The entity with the [`Talk`] component you want to update. + /// The entity with the `Talk` component you want to update. pub talk: Entity, /// The next entity to go to. pub next: Entity, @@ -30,3 +30,39 @@ impl ChooseActionRequest { // TODO: more events to talk to the library... (reset talk?) // TODO: events in the other direction: from the library to the game (e.g. text event when reaching a text action node...) + +// region: EXPERIMENTS + +// trait DialogueNode: Component { +// fn emit_event(&self, writer: EventWriter); +// } + +// // #[derive(DialogueNode)] +// #[derive(Component)] +// pub struct MyNode { +// pub my_field: bool, +// } + +// impl DialogueNode for MyNode { +// fn emit_event(&self, mut writer: EventWriter) { +// writer.send(MyEvent); +// } +// } +// #[derive(Event)] +// pub struct MyEvent; + +// /// An event to request the next action in a [`Talk`]. It requires an entity with the [`Talk`] component you want to update. +// #[derive(Event)] +// pub struct TextEvent { +// text: String, +// } + +// fn test(mut q: Query<&DialogueNode<>, mut writer: EventWriter) { +// for c in &q { +// c.emit_event(writer); +// } +// } + +// endregion + +// NOTE: An invariant of the dialogue graph is that there is always only one current node diff --git a/src/lib.rs b/src/lib.rs index 65df09e..0aa99a5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,7 +7,7 @@ // Unhelpful for systems #![allow(clippy::too_many_arguments)] -//! [`bevy_talks`] is a Bevy plugin that provides the basics to build and handle dialogues in games. +//! `bevy_talks` is a Bevy plugin that provides the basics to build and handle dialogues in games. use aery::{prelude::*, tuple_traits::RelationEntries}; use bevy::prelude::*; diff --git a/src/ron_loader/loader.rs b/src/ron_loader/loader.rs index 7c25b6d..8aa6c76 100644 --- a/src/ron_loader/loader.rs +++ b/src/ron_loader/loader.rs @@ -23,7 +23,7 @@ pub enum RonLoaderError { /// An [IO Error](std::io::Error) #[error("Could not read the file: {0}")] Io(#[from] std::io::Error), - /// A [RON Error](ron::error::SpannedError) + /// A [RON Error](serde_ron::error::SpannedError) #[error("Could not parse RON: {0}")] RonError(#[from] serde_ron::error::SpannedError), /// Multiple actions have same id error