Skip to content

Commit

Permalink
docs: fix links in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
giusdp committed Jan 6, 2024
1 parent 5fb71bb commit 23a04ce
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 10 deletions.
6 changes: 1 addition & 5 deletions src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
42 changes: 39 additions & 3 deletions src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<E: Event>: Component<Storage = TableStorage> {
// fn emit_event(&self, writer: EventWriter<E>);
// }

// // #[derive(DialogueNode)]
// #[derive(Component)]
// pub struct MyNode {
// pub my_field: bool,
// }

// impl DialogueNode<MyEvent> for MyNode {
// fn emit_event(&self, mut writer: EventWriter<MyEvent>) {
// 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<TextEvent>) {
// 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
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
2 changes: 1 addition & 1 deletion src/ron_loader/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 23a04ce

Please sign in to comment.