-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmod.rs
More file actions
29 lines (26 loc) · 923 Bytes
/
mod.rs
File metadata and controls
29 lines (26 loc) · 923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/// Author: John Klucinec (@johnklucinec)
pub mod commands;
pub mod components;
pub mod systems;
use bevy::prelude::*;
use commands::queue_commands;
use components::{CommandEvent, CommandQueue, PythonComms};
use systems::{handle_responses, process_command_queue};
pub struct PythonPlugin;
impl Plugin for PythonPlugin {
fn build(&self, app: &mut App) {
app
// Declare but don't initialize PythonComms here
.add_event::<CommandEvent>()
.init_resource::<CommandQueue>()
// Add systems that only run when PythonComms exists
.add_systems(
Update,
(
queue_commands, // Queue commands from any source
process_command_queue.run_if(resource_exists::<PythonComms>),
handle_responses.run_if(resource_exists::<PythonComms>),
),
);
}
}