mirror of
https://github.com/lightsoutgames/bevy_tts.git
synced 2024-11-10 02:15:56 +00:00
Bump to Bevy main.
This commit is contained in:
parent
380f2afb3d
commit
c63e43f0fd
|
@ -11,5 +11,6 @@ default = ["tolk"]
|
|||
tolk = ["tts/tolk"]
|
||||
|
||||
[dependencies]
|
||||
bevy = "0.4"
|
||||
bevy = { git = "https://github.com/bevyengine/bevy" }
|
||||
crossbeam-channel = "0.5"
|
||||
tts = { version = "0.14" }
|
|
@ -63,11 +63,8 @@ fn setup(mut tts: ResMut<TTS>) {
|
|||
}
|
||||
|
||||
// Reports events from TTS subsystem.
|
||||
fn event_poll(
|
||||
mut tts_event_reader: Local<EventReader<TtsEvent>>,
|
||||
tts_events: Res<Events<TtsEvent>>,
|
||||
) {
|
||||
for event in tts_event_reader.iter(&tts_events) {
|
||||
fn event_poll(mut events: EventReader<TtsEvent>) {
|
||||
for event in events.iter() {
|
||||
println!("{:?}", event);
|
||||
}
|
||||
}
|
||||
|
|
13
src/lib.rs
13
src/lib.rs
|
@ -1,6 +1,5 @@
|
|||
use std::sync::mpsc::{channel, Receiver};
|
||||
|
||||
use bevy::prelude::*;
|
||||
use crossbeam_channel::{unbounded, Receiver};
|
||||
pub use tts::{Error, Features, UtteranceId, TTS};
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
|
@ -12,10 +11,8 @@ pub enum TtsEvent {
|
|||
|
||||
struct TtsChannel(Receiver<TtsEvent>);
|
||||
|
||||
fn poll_callbacks(_: &mut World, resources: &mut Resources) {
|
||||
let channel = resources.get_thread_local::<TtsChannel>().unwrap();
|
||||
fn poll_callbacks(channel: Res<TtsChannel>, mut events: ResMut<Events<TtsEvent>>) {
|
||||
if let Ok(msg) = channel.0.try_recv() {
|
||||
let mut events = resources.get_mut::<Events<TtsEvent>>().unwrap();
|
||||
events.send(msg);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +22,7 @@ pub struct TtsPlugin;
|
|||
impl Plugin for TtsPlugin {
|
||||
fn build(&self, app: &mut AppBuilder) {
|
||||
let tts = TTS::default().unwrap();
|
||||
let (tx, rx) = channel();
|
||||
let (tx, rx) = unbounded();
|
||||
let tx_begin = tx.clone();
|
||||
let tx_end = tx.clone();
|
||||
let tx_stop = tx;
|
||||
|
@ -48,8 +45,8 @@ impl Plugin for TtsPlugin {
|
|||
.unwrap();
|
||||
}
|
||||
app.add_event::<TtsEvent>()
|
||||
.add_thread_local_resource(TtsChannel(rx))
|
||||
.add_resource(tts)
|
||||
.insert_resource(TtsChannel(rx))
|
||||
.insert_resource(tts)
|
||||
.add_system(poll_callbacks.system());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user