Skip to content

Commit

Permalink
More docs
Browse files Browse the repository at this point in the history
  • Loading branch information
victorb committed Aug 11, 2024
1 parent c8ce2f5 commit 70cb6a5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 23 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ check:
test:
cargo test --no-default-features

.PHONY: test-watch
test-watch:
cargo watch -s "make test"

.PHONY: clippy
clippy:
cargo clippy
Expand All @@ -19,7 +23,7 @@ doc:

.PHONY: doc-watch
doc-watch:
cargo watch -s "cargo doc --workspace --no-deps"
cargo watch -s "make doc"

.PHONY: build
build: check test clippy doc
Expand Down
4 changes: 1 addition & 3 deletions crates/bevy_dogoap/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#![doc = include_str!("../README.md")]

// Public API
pub use dogoap::prelude::*;

mod macros;
mod planner;
mod plugin;
mod traits;

// Public API
pub mod prelude;
7 changes: 7 additions & 0 deletions crates/bevy_dogoap/src/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,18 @@ type ActionsMap = HashMap<String, (Action, Box<dyn InserterComponent>)>;

type DatumComponents = Vec<Box<dyn DatumComponent>>;

/// Our main struct for handling the planning within Bevy, keeping track of added
/// [`Action`]s, [`DatumComponent`]s, and some options for controlling the execution
#[derive(Component, Reflect)]
pub struct Planner {
/// Our current state used for planning, updated by [`update_planner_local_state`] which reads
/// the current state from our Bevy world and updates it accordingly
pub state: LocalState,
/// A Vector of all possible [`Goal`]s
pub goals: Vec<Goal>,
/// What [`Goal`] we're currently planning towards
pub current_goal: Option<Goal>,
/// What [`Action`] we're currrently trying to execute
pub current_action: Option<Action>,

// queue of action keys, first is current
Expand Down
22 changes: 3 additions & 19 deletions crates/bevy_dogoap/src/plugin.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::planner;
use bevy::prelude::*;
// use bevy::time::common_conditions::on_timer;
// use std::time::Duration;

/// Setups the [`Planner`](planner::Planner) systems to run at
/// [`PreUpdate`](bevy::prelude::PreUpdate)
pub struct DogoapPlugin;

impl Plugin for DogoapPlugin {
Expand All @@ -11,31 +11,15 @@ impl Plugin for DogoapPlugin {
// TODO not entirely sure about using PreUpdate here
// On one hand, we get to react to actions added in the same frame
// On the other hand, feels a bit too much magical when actions can disappear really quickly
// .add_systems(PreUpdate, (planner::update_planner_local_state, planner::update_planner).chain())
// .add_systems(PreUpdate, (planner::update_planner_local_state, planner::update_planner))
// .add_systems(Update, (planner::update_planner_local_state, planner::update_planner))
// .add_systems(PreUpdate, planner::update_planner_local_state)
.add_systems(
PreUpdate,
(
planner::update_planner_local_state,
planner::create_planner_tasks,
planner::handle_planner_tasks,
)
.chain(), // .run_if(on_timer(Duration::from_millis(100))),
.chain(),
)
// .add_systems(PlanningSchedule,
// (planner::update_planner_local_state,
// planner::update_planner))
// .add_systems(Update, .in_set(MyGoapSet))
.register_type::<planner::Planner>();

// TODO how to be able to call this with generate types passed in to the creation of DogoapPlugin?
// app.register_component_as::<dyn DatumComponent, IsTired>();
// Right now users have to manually call `register_components!(app, vec![IsHungry, IsTired]);`
// somewhere

// app.world_mut().resource_mut::<MainScheduleOrder>()
// .insert_after(PreUpdate, DogoapSchedule);
}
}

0 comments on commit 70cb6a5

Please sign in to comment.