-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add reloadable state Signed-off-by: lee-orr <[email protected]> * readme and docs Signed-off-by: lee-orr <[email protected]> * fix intro Signed-off-by: lee-orr <[email protected]> * start adding events Signed-off-by: lee-orr <[email protected]> * events Signed-off-by: lee-orr <[email protected]> --------- Signed-off-by: lee-orr <[email protected]>
- Loading branch information
Showing
11 changed files
with
216 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
testing/dexterous_developer_tests/src/insert_replacable_event.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use bevy::prelude::*; | ||
use dexterous_developer::*; | ||
use serde::{Deserialize, Serialize}; | ||
use crate::shared::{StdInput}; | ||
|
||
fn update(input: Res<StdInput>, mut event: EventWriter<AppEvent>) { | ||
let text = input.0.as_str(); | ||
println!("Got: {text}"); | ||
event.send(AppEvent::Text(text.to_string())) | ||
} | ||
|
||
fn read(input: Res<StdInput>, mut event: EventReader<AppEvent>) { | ||
for event in event.iter() { | ||
let text = match event { | ||
AppEvent::Text(s) => format!("Text - {s}"), | ||
}; | ||
println!("Event: {text}"); | ||
} | ||
} | ||
|
||
|
||
|
||
fn startup() { | ||
println!("Press Enter to Progress, or type 'exit' to exit"); | ||
} | ||
|
||
#[derive(Event, Clone, Debug, Serialize, Deserialize)] | ||
pub enum AppEvent { | ||
Text(String), | ||
} | ||
|
||
|
||
impl ReplacableEvent for AppEvent { | ||
fn get_type_name() -> &'static str { | ||
"app-event" | ||
} | ||
} | ||
|
||
#[dexterous_developer_setup] | ||
pub fn reloadable(app: &mut ReloadableAppContents) { | ||
app | ||
.add_event::<AppEvent>() | ||
.add_systems(Startup, startup) | ||
.add_systems(Update, (update, read).chain()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
testing/dexterous_developer_tests/src/update_replacable_event.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
use crate::shared::StdInput; | ||
use bevy::prelude::*; | ||
use dexterous_developer::*; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
fn update(input: Res<StdInput>, mut event: EventWriter<AppEvent>) { | ||
let text = input.0.as_str(); | ||
println!("Got: {text}"); | ||
let e = if text.starts_with("shout:") { | ||
let text_a = text.replace("shout:", ""); | ||
let text = text_a.trim(); | ||
AppEvent::Shout(text.to_string()) | ||
} else { | ||
AppEvent::Text(text.to_string()) | ||
}; | ||
event.send(e) | ||
} | ||
|
||
fn read(input: Res<StdInput>, mut event: EventReader<AppEvent>) { | ||
for event in event.iter() { | ||
let text = match event { | ||
AppEvent::Text(s) => format!("Text - {s}"), | ||
AppEvent::Shout(s) => format!("Shout - {s}"), | ||
}; | ||
println!("Event: {text}"); | ||
} | ||
} | ||
|
||
fn startup() { | ||
println!("Press Enter to Progress, or type 'exit' to exit"); | ||
} | ||
|
||
#[derive(Event, PartialEq, Eq, Clone, Debug, Hash, Serialize, Deserialize)] | ||
pub enum AppEvent { | ||
Text(String), | ||
Shout(String), | ||
} | ||
|
||
impl ReplacableEvent for AppEvent { | ||
fn get_type_name() -> &'static str { | ||
"app-event" | ||
} | ||
} | ||
|
||
#[dexterous_developer_setup] | ||
pub fn reloadable(app: &mut ReloadableAppContents) { | ||
app.add_event::<AppEvent>() | ||
.add_systems(Startup, startup) | ||
.add_systems(Update, (update, read).chain()); | ||
} |