From ed280e02391cb2182d31ceaa1a4c5bc6f0cc4b16 Mon Sep 17 00:00:00 2001 From: Peter Hayman Date: Wed, 3 Jul 2024 13:56:20 +1000 Subject: [PATCH] feat: hello_net --- .../beet_examples/examples/basics/scenes/hello_net.rs | 4 ++-- .../beet_examples/src/net/example_replicate_plugin.rs | 11 +---------- crates/beet_net/src/replication/common_events.rs | 8 +++++--- examples/fetch.rs | 2 +- index.html | 10 +++++++++- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/crates/beet_examples/examples/basics/scenes/hello_net.rs b/crates/beet_examples/examples/basics/scenes/hello_net.rs index bf452a52..4de9e970 100644 --- a/crates/beet_examples/examples/basics/scenes/hello_net.rs +++ b/crates/beet_examples/examples/basics/scenes/hello_net.rs @@ -7,8 +7,8 @@ pub fn hello_net(mut commands: Commands) { .spawn((SequenceSelector::default(), Running)) .with_children(|parent| { parent.spawn(( - LogOnRun::new("Send: AppLoaded"), - TriggerOnRun(AppLoaded), + LogOnRun::new("Send: AppReady"), + TriggerOnRun(AppReady), )); }); commands.spawn(( diff --git a/crates/beet_examples/src/net/example_replicate_plugin.rs b/crates/beet_examples/src/net/example_replicate_plugin.rs index 4bdfd648..05bd5df2 100644 --- a/crates/beet_examples/src/net/example_replicate_plugin.rs +++ b/crates/beet_examples/src/net/example_replicate_plugin.rs @@ -10,21 +10,12 @@ impl Plugin for ExampleReplicatePlugin { app.add_plugins((ReplicatePlugin, CommonEventsPlugin)) .add_event::() .replicate_event_incoming::() - .add_plugins(ActionPlugin::>::default()) - - .add_event::() - .replicate_event_outgoing::() - .add_plugins(ActionPlugin::>::default()); + .add_plugins(ActionPlugin::>::default()); } } - /// User messages received either internally or externally #[derive( Debug, Clone, Deref, DerefMut, Serialize, Deserialize, Event, Reflect, )] pub struct OnUserMessage(pub String); - -/// Sent from this bevy app to web ui etc to notify that assets etc have loaded. -#[derive(Debug, Clone, Serialize, Deserialize, Event, Reflect)] -pub struct AppLoaded; diff --git a/crates/beet_net/src/replication/common_events.rs b/crates/beet_net/src/replication/common_events.rs index 9d7b21ba..7365da2a 100644 --- a/crates/beet_net/src/replication/common_events.rs +++ b/crates/beet_net/src/replication/common_events.rs @@ -1,11 +1,12 @@ use super::AppExtReplicate; +use beet_ecs::prelude::*; use bevy::prelude::*; use serde::Deserialize; use serde::Serialize; -/// Signal that this app is fully loaded, usually once assets are ready. -#[derive(Debug, Clone, Serialize, Deserialize, Event)] +/// Sent from this app, usually once assets are ready. +#[derive(Debug, Clone, Serialize, Deserialize, Event, Reflect)] pub struct AppReady; pub struct CommonEventsPlugin; @@ -13,7 +14,8 @@ pub struct CommonEventsPlugin; impl Plugin for CommonEventsPlugin { fn build(&self, app: &mut App) { app.add_event::() - .replicate_event_outgoing::(); + .replicate_event_outgoing::() + .add_plugins(ActionPlugin::>::default()); // .add_systems(Startup, ready); } } diff --git a/examples/fetch.rs b/examples/fetch.rs index 5f944f5d..a168ef95 100644 --- a/examples/fetch.rs +++ b/examples/fetch.rs @@ -110,7 +110,7 @@ fn setup_fox( parent .spawn(( Name::new("Idle Or Fetch"), - TriggerOnRun(AppLoaded), + TriggerOnRun(AppReady), TargetAgent(agent), ScoreSelector::default(), // ScoreSelector::consuming(), diff --git a/index.html b/index.html index 145e3bd5..b4b96cb3 100644 --- a/index.html +++ b/index.html @@ -20,10 +20,18 @@