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
30
31
32
33
34
35
36
37
38
39
use crate::{
ecs::components::{ Component, GlobalComponentStorage, GlobalComponent },
};
use pill_core::PillTypeMapKey;
use anyhow::{Result, Error, Context};
#[readonly::make]
pub struct TimeComponent {
#[readonly]
pub time: f32,
#[readonly]
pub delta_time: f32,
}
impl TimeComponent {
pub fn new() -> Self {
Self {
time: 0.0,
delta_time: 0.0,
}
}
pub(crate) fn update(&mut self, delta_time: f32) -> Result<()> {
self.time += delta_time / 1000.0;
self.delta_time = delta_time / 1000.0;
Ok(())
}
}
impl PillTypeMapKey for TimeComponent {
type Storage = GlobalComponentStorage<TimeComponent>;
}
impl GlobalComponent for TimeComponent {
}