mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
e852e0cfab
big combined updates. - Add a timer to the stats persistence system and change the frequency that it runs to 10s - Seperate the loading of character data for the character list during selection, and the full data we will grab during state creation. Ideally additional persisted bits can get returned at the same point and added to the ecs within the same block.
32 lines
783 B
Rust
32 lines
783 B
Rust
use crate::{
|
|
persistence::stats,
|
|
sys::{SysScheduler, SysTimer},
|
|
};
|
|
use common::comp::{Player, Stats};
|
|
use specs::{Join, ReadStorage, System, Write};
|
|
|
|
pub struct Sys;
|
|
|
|
impl<'a> System<'a> for Sys {
|
|
type SystemData = (
|
|
ReadStorage<'a, Player>,
|
|
ReadStorage<'a, Stats>,
|
|
Write<'a, SysScheduler<Self>>,
|
|
Write<'a, SysTimer<Self>>,
|
|
);
|
|
|
|
fn run(&mut self, (players, player_stats, mut scheduler, mut timer): Self::SystemData) {
|
|
if scheduler.should_run() {
|
|
timer.start();
|
|
|
|
stats::update(
|
|
(&players, &player_stats)
|
|
.join()
|
|
.filter_map(|(player, stats)| player.character_id.map(|id| (id, stats))),
|
|
);
|
|
|
|
timer.end();
|
|
}
|
|
}
|
|
}
|