steel_registry/stat/
custom.rs1use rustc_hash::FxHashMap;
2use steel_utils::{DowncastType, DowncastTypeKey, Identifier};
3
4#[derive(Debug)]
12pub struct CustomStat {
13 pub key: Identifier,
14}
15
16pub type CustomStatRef = &'static CustomStat;
17
18pub struct CustomStatRegistry {
25 custom_stats_by_id: Vec<CustomStatRef>,
26 custom_stats_by_key: FxHashMap<Identifier, usize>,
27 allows_registering: bool,
28}
29
30unsafe impl DowncastType for CustomStatRegistry {
32 const TYPE_KEY: DowncastTypeKey = DowncastTypeKey::new("steel:registry/custom_stat");
33}
34
35impl CustomStatRegistry {
36 #[must_use]
37 pub fn new() -> Self {
38 Self {
39 custom_stats_by_id: Vec::new(),
40 custom_stats_by_key: FxHashMap::default(),
41 allows_registering: true,
42 }
43 }
44}
45
46crate::impl_standard_methods!(
47 CustomStatRegistry,
48 CustomStatRef,
49 custom_stats_by_id,
50 custom_stats_by_key,
51 allows_registering
52);
53
54crate::impl_registry!(
55 CustomStatRegistry,
56 CustomStat,
57 custom_stats_by_id,
58 custom_stats_by_key,
59 custom_stats
60);