Bläddra i källkod

Renamed 'StateUpdate' to 'InputStateUpdate'

master
Bergmann89 4 år sedan
förälder
incheckning
d5022fdaaf
3 ändrade filer med 10 tillägg och 11 borttagningar
  1. +2
    -3
      space-crush-app/src/lib.rs
  2. +6
    -6
      space-crush-app/src/systems/input_state_update.rs
  3. +2
    -2
      space-crush-app/src/systems/mod.rs

+ 2
- 3
space-crush-app/src/lib.rs Visa fil

@@ -15,7 +15,7 @@ use debug::{Fleets as DebugFleets, Ships as DebugShips, Summary as DebugSummary}
use misc::{Events, TextManager, Window};
use render::{Asteroids, FleetSelect, Init, Planets, Ships};
use resources::{Camera, Config, GameState, Geometry, InputState, Uniform};
use systems::{FleetControl, StateUpdate};
use systems::InputStateUpdate;

pub struct App<'a, 'b> {
is_running: bool,
@@ -48,8 +48,7 @@ impl<'a, 'b> App<'a, 'b> {
let text_manager = TextManager::new(world)?;

let mut dispatcher = DispatcherBuilder::new()
.with(StateUpdate::new(world)?, "state_update", &[])
.with(FleetControl::new(world)?, "fleet_control", &[])
.with(InputStateUpdate::new(world)?, "input_state_update", &[])
.with_thread_local(Init::new(world)?)
.with_thread_local(Planets::new(world)?)
.with_thread_local(Asteroids::new(world)?)


space-crush-app/src/systems/state_update.rs → space-crush-app/src/systems/input_state_update.rs Visa fil

@@ -8,13 +8,13 @@ use crate::{
Error,
};

pub struct StateUpdate {
pub struct InputStateUpdate {
mouse_event_id: ReaderId<MouseEvent>,
window_events_id: ReaderId<WindowEvent>,
keyboard_events_id: ReaderId<KeyboardEvent>,
}

impl StateUpdate {
impl InputStateUpdate {
pub fn new(world: &mut World) -> Result<Self, Error> {
let mouse_event_id = world.register_event_reader::<MouseEvent>()?;
let window_events_id = world.register_event_reader::<WindowEvent>()?;
@@ -29,18 +29,18 @@ impl StateUpdate {
}

#[derive(SystemData)]
pub struct StateUpdateData<'a> {
pub struct InputStateUpdateData<'a> {
input_state: Write<'a, InputState>,
mouse_events: ReadExpect<'a, EventChannel<MouseEvent>>,
window_events: ReadExpect<'a, EventChannel<WindowEvent>>,
keyboard_events: ReadExpect<'a, EventChannel<KeyboardEvent>>,
}

impl<'a> System<'a> for StateUpdate {
type SystemData = StateUpdateData<'a>;
impl<'a> System<'a> for InputStateUpdate {
type SystemData = InputStateUpdateData<'a>;

fn run(&mut self, data: Self::SystemData) {
let StateUpdateData {
let InputStateUpdateData {
mut input_state,
mouse_events,
window_events,

+ 2
- 2
space-crush-app/src/systems/mod.rs Visa fil

@@ -1,5 +1,5 @@
mod fleet_control;
mod state_update;
mod input_state_update;

pub use fleet_control::FleetControl;
pub use state_update::StateUpdate;
pub use input_state_update::InputStateUpdate;

Laddar…
Avbryt
Spara