1use super::RealTimeData;
2use num_enum::{IntoPrimitive, TryFromPrimitive};
3
4#[derive(Debug, Clone)]
5#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6pub struct GameData {
7 pub game_build: u32,
9
10 pub game_state: Result<GameState, u32>,
12
13 pub language: Result<GameLanguage, u32>,
15}
16
17impl GameData {
18 pub unsafe fn read(data: *const RealTimeData) -> Self {
23 unsafe {
24 Self {
25 game_build: (*data).game_build,
26 game_state: (*data).game_state.try_into(),
27 language: (*data).language.try_into(),
28 }
29 }
30 }
31}
32
33#[derive(
34 Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, TryFromPrimitive, IntoPrimitive,
35)]
36#[num_enum(error_type(name = u32, constructor = From::from))]
37#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
38#[cfg_attr(
39 feature = "strum",
40 derive(
41 strum::AsRefStr,
42 strum::Display,
43 strum::EnumCount,
44 strum::EnumIter,
45 strum::IntoStaticStr,
46 strum::VariantArray,
47 strum::VariantNames
48 )
49)]
50#[repr(u32)]
51pub enum GameState {
52 CharacterSelection,
53 CharacterCreation,
54 Cinematic,
55 LoadingScreen,
56 Gameplay,
57}
58
59#[derive(
60 Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, TryFromPrimitive, IntoPrimitive,
61)]
62#[num_enum(error_type(name = u32, constructor = From::from))]
63#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
64#[cfg_attr(
65 feature = "strum",
66 derive(
67 strum::AsRefStr,
68 strum::Display,
69 strum::EnumCount,
70 strum::EnumIter,
71 strum::IntoStaticStr,
72 strum::VariantArray,
73 strum::VariantNames
74 )
75)]
76#[repr(u32)]
77pub enum GameLanguage {
78 English,
79 Korean,
80 French,
81 German,
82 Spanish,
83 Chinese,
84}