Fix animations

Former-commit-id: 20285b42be6f1858105cc4287e357ea254a8ce35
This commit is contained in:
timokoesters
2019-05-19 16:53:07 +02:00
parent 4c0e4b52b1
commit e751dbe03b
2 changed files with 9 additions and 8 deletions

View File

@ -4,7 +4,7 @@ use vek::*;
// Crate // Crate
use crate::{ use crate::{
comp::{phys::Pos, ActionState, ActionEvent, Control, Stats}, comp::{phys::Pos, Animation, AnimationInfo, Control, Stats},
state::DeltaTime, state::DeltaTime,
}; };
@ -12,14 +12,12 @@ use crate::{
pub struct Sys; pub struct Sys;
impl<'a> System<'a> for Sys { impl<'a> System<'a> for Sys {
type SystemData = ( type SystemData = (Read<'a, DeltaTime>, WriteStorage<'a, AnimationInfo>);
Read<'a, DeltaTime>,
WriteStorage<'a, ActionState>,
);
fn run(&mut self, (dt, mut action_states): Self::SystemData) { fn run(&mut self, (dt, mut animation_infos): Self::SystemData) {
for (dt, mut animation) in (dt, &mut animation).join() { for (mut animation_info) in (&mut animation_infos).join() {
animation.time += dt.0 as f64; animation_info.time += dt.0 as f64;
&animation_info.time;
} }
} }
} }

View File

@ -1,5 +1,6 @@
pub mod action; pub mod action;
pub mod agent; pub mod agent;
pub mod animation;
pub mod control; pub mod control;
pub mod phys; pub mod phys;
mod stats; mod stats;
@ -14,6 +15,7 @@ const PHYS_SYS: &str = "phys_sys";
const ANIM_SYS: &str = "anim_sys"; const ANIM_SYS: &str = "anim_sys";
const MOVEMENT_SYS: &str = "movement_sys"; const MOVEMENT_SYS: &str = "movement_sys";
const ACTION_SYS: &str = "action_sys"; const ACTION_SYS: &str = "action_sys";
const ANIMATION_SYS: &str = "animation_sys";
const STATS_SYS: &str = "stats_sys"; const STATS_SYS: &str = "stats_sys";
pub fn add_local_systems(dispatch_builder: &mut DispatcherBuilder) { pub fn add_local_systems(dispatch_builder: &mut DispatcherBuilder) {
@ -23,5 +25,6 @@ pub fn add_local_systems(dispatch_builder: &mut DispatcherBuilder) {
dispatch_builder.add(anim::Sys, ANIM_SYS, &[]); dispatch_builder.add(anim::Sys, ANIM_SYS, &[]);
dispatch_builder.add(agent::Sys, AGENT_SYS, &[]); dispatch_builder.add(agent::Sys, AGENT_SYS, &[]);
dispatch_builder.add(action::Sys, ACTION_SYS, &[]); dispatch_builder.add(action::Sys, ACTION_SYS, &[]);
dispatch_builder.add(animation::Sys, ANIMATION_SYS, &[]);
dispatch_builder.add(stats::Sys, STATS_SYS, &[ACTION_SYS]); dispatch_builder.add(stats::Sys, STATS_SYS, &[ACTION_SYS]);
} }