Skip to content

Commit

Permalink
patch: all tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
mrchantey committed Jul 9, 2024
1 parent 5c9212c commit 696ecf6
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 73 deletions.
18 changes: 9 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ tokio.workspace = true
### WORKSPACE ################################################################################################z###########################

[workspace.package]
version = "0.0.3"
version = "0.0.2"
edition = "2021"
description = "A very flexible AI behavior library for games and robotics."
documentation = "https://beetmash.com/docs/beet"
Expand Down Expand Up @@ -96,14 +96,14 @@ exclude = ["crates/beet_esp"]

[workspace.dependencies]
## internal
beet = { path = "./", version = "0.0.3" }
beet_core = { path = "crates/beet_core", version = "0.0.3", default-features = false }
beet_ecs = { path = "crates/beet_ecs", version = "0.0.3" }
beet_ecs_macros = { path = "crates/beet_ecs/macros", version = "0.0.3" }
beet_ml = { path = "crates/beet_ml", version = "0.0.3" }
beet_net = { path = "crates/beet_net", version = "0.0.3" }
beet_server = { path = "crates/beet_server", version = "0.0.3" }
beet_examples = { path = "crates/beet_examples", version = "0.0.3" }
beet = { path = "./", version = "0.0.2" }
beet_core = { path = "crates/beet_core", version = "0.0.2", default-features = false }
beet_ecs = { path = "crates/beet_ecs", version = "0.0.2" }
beet_ecs_macros = { path = "crates/beet_ecs/macros", version = "0.0.2" }
beet_ml = { path = "crates/beet_ml", version = "0.0.2" }
beet_net = { path = "crates/beet_net", version = "0.0.2" }
beet_server = { path = "crates/beet_server", version = "0.0.2" }
beet_examples = { path = "crates/beet_examples", version = "0.0.2" }

## local
# forky_core = { path = "../forky/crates/forky/forky_core" }
Expand Down
4 changes: 2 additions & 2 deletions crates/beet_ecs/src/lifecycle/actions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ pub use self::set_on_run::*;
pub mod set_on_spawn;
#[allow(unused_imports)]
pub use self::set_on_spawn::*;
pub mod trigger_on_run;
pub mod send_on_run;
#[allow(unused_imports)]
pub use self::trigger_on_run::*;
pub use self::send_on_run::*;
25 changes: 25 additions & 0 deletions crates/beet_ecs/src/lifecycle/actions/send_on_run.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use crate::prelude::*;
use bevy::prelude::*;

/// Sends the given event when this behavior starts running.
#[derive(Debug, Clone, PartialEq, Deref, DerefMut, Action, Reflect)]
#[reflect(Component, ActionMeta)]
#[systems(send_on_run::<T>.in_set(TickSet))]
pub struct SendOnRun<T: GenericActionEvent>(pub T);

impl<T: Default + GenericActionEvent> Default for SendOnRun<T> {
fn default() -> Self { Self(T::default()) }
}

impl<T: GenericActionEvent> SendOnRun<T> {
pub fn new(value: impl Into<T>) -> Self { Self(value.into()) }
}

fn send_on_run<T: GenericActionEvent>(
mut writer: EventWriter<T>,
query: Query<&SendOnRun<T>, Added<Running>>,
) {
for trigger in query.iter() {
writer.send(trigger.0.clone());
}
}
25 changes: 0 additions & 25 deletions crates/beet_ecs/src/lifecycle/actions/trigger_on_run.rs

This file was deleted.

1 change: 0 additions & 1 deletion crates/beet_ecs/src/lifecycle/beet_debug_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ fn log_on_start_observer(
.get(trigger.entity())
.map(|n| format!("Started: {n}"))
.unwrap_or_else(|_| format!("Started: {}", trigger.entity()));
log::info!("called: {}", name);
commands.trigger(OnLogMessage::new(name));
}
fn log_on_stop_observer(
Expand Down
3 changes: 1 addition & 2 deletions crates/beet_examples/src/scenes/hello_net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ pub fn hello_net(mut commands: Commands) {
commands
.spawn((SequenceSelector::default(), Running))
.with_children(|parent| {
parent
.spawn((Name::new("Send - AppReady"), TriggerOnRun(AppReady)));
parent.spawn((Name::new("Send - AppReady"), SendOnRun(AppReady)));
});
commands.spawn((
Name::new("Recv - Player Message"),
Expand Down
7 changes: 3 additions & 4 deletions crates/beet_ml/src/rl_realtime/rl_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,11 @@ mod test {
params.learn_params.n_training_episodes = 1;
app.world_mut().spawn(RlSession::new(params));

expect(app.world().entities().len()).to_be(1)?;

app.update();
expect(app.world().entities().len()).to_be(2)?;
app.update();
expect(app.world().entities().len()).to_be(1)?;
expect(app.world().entities().len()).to_be(3)?;
app.update();
expect(app.world().entities().len()).to_be(2)?;

Ok(())
}
Expand Down
40 changes: 19 additions & 21 deletions crates/beet_net/src/events/common_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,25 @@ pub struct CommonEventsPlugin;
impl Plugin for CommonEventsPlugin {
fn build(&self, app: &mut App) {
app
// AppStartup
.add_event::<AppStartup>()
.replicate_event_outgoing::<AppStartup>()
.add_systems(Startup, |mut events: EventWriter<AppStartup>| {
events.send(AppStartup);
})
// AppReady
.add_event::<AppReady>()
.replicate_event_outgoing::<AppReady>()
.add_plugins(ActionPlugin::<(
TriggerOnRun<AppReady>,
InsertOnTrigger<AppReady, Running>,
)>::default())
.register_type::<TriggerOnRun<AppReady>>()
.register_type::<InsertOnTrigger<AppReady, Running>>()
// SpawnSceneFile
.add_event::<SpawnSceneFile>()
.replicate_event_incoming::<SpawnSceneFile>()
.add_event::<SpawnSceneFileResponse>()
.replicate_event_outgoing::<SpawnSceneFileResponse>()
.add_systems(Update, handle_spawn_scene);
// AppStartup
.add_event::<AppStartup>()
.replicate_event_outgoing::<AppStartup>()
.add_systems(Startup, |mut events: EventWriter<AppStartup>| {
events.send(AppStartup);
})
// AppReady
.add_event::<AppReady>()
.replicate_event_outgoing::<AppReady>()
.add_plugins(ActionPlugin::<(
SendOnRun<AppReady>,
InsertOnTrigger<AppReady, Running>,
)>::default())
// SpawnSceneFile
.add_event::<SpawnSceneFile>()
.replicate_event_incoming::<SpawnSceneFile>()
.add_event::<SpawnSceneFileResponse>()
.replicate_event_outgoing::<SpawnSceneFileResponse>()
.add_systems(Update, handle_spawn_scene);
// Screenshot

#[cfg(not(test))]
Expand Down
25 changes: 25 additions & 0 deletions examples/hello_net.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use beet_examples::prelude::*;
use bevy::prelude::*;

pub fn main() {
App::new()
.add_plugins(ExamplePluginFull)
.add_systems(
Startup,
(
scenes::beet_debug,
scenes::camera_2d,
scenes::ui_terminal,
scenes::hello_net,
),
)
.run();
}

/*
STDOUT:
Started: Sentence Selector
Started: Attack Behavior
*/

0 comments on commit 696ecf6

Please sign in to comment.