]> git.lizzy.rs Git - mt_net.git/blob - src/to_clt/obj.rs
Implement NodeMeta and add Inventory stub
[mt_net.git] / src / to_clt / obj.rs
1 use super::*;
2
3 #[mt_derive(to = "clt", repr = "str")]
4 pub enum ObjVisual {
5     Cube,
6     Sprite,
7     UprightSprite,
8     Mesh,
9     Wielditem,
10     Item,
11 }
12
13 #[mt_derive(to = "clt")]
14 pub struct ObjProps {
15     #[mt(const_before = "4u8")] // version
16     pub max_hp: u16, // player only
17     pub collide_with_nodes: bool,
18     pub weight: f32, // deprecated
19     pub collision_box: ([f32; 3], [f32; 3]),
20     pub selection_box: ([f32; 3], [f32; 3]),
21     pub pointable: bool,
22     pub visual: ObjVisual,
23     pub visual_size: [f32; 3],
24     pub textures: Vec<String>,
25     pub sprite_sheet_size: [i16; 2], // in sprites
26     pub sprite_pos: [i16; 2],        // in sprite sheet
27     pub visible: bool,
28     pub make_footstep_sounds: bool,
29     pub rotate_speed: f32, // in radians per second
30     pub mesh: String,
31     pub colors: Vec<Color>,
32     pub collide_with_objs: bool,
33     pub step_height: f32,
34     pub face_rotate_dir: bool,
35     pub face_rotate_dir_off: f32, // in degrees
36     pub backface_cull: bool,
37     pub nametag: String,
38     pub nametag_color: Color,
39     pub face_rotate_speed: f32, // in degrees per second
40     pub infotext: String,
41     pub itemstring: String,
42     pub glow: i8,
43     pub max_breath: u16, // player only
44     pub eye_height: f32, // player only
45     pub zoom_fov: f32,   // in degrees. player only
46     pub use_texture_alpha: bool,
47     pub dmg_texture_mod: String, // suffix
48     pub shaded: bool,
49     pub show_on_minimap: bool,
50     pub nametag_bg: Color,
51 }
52
53 #[mt_derive(to = "clt")]
54 pub struct ObjPos {
55     pub pos: [f32; 3],
56     pub vel: [f32; 3],
57     pub acc: [f32; 3],
58     pub rot: [f32; 3],
59     pub interpolate: bool,
60     pub end: bool,
61     pub update_interval: f32,
62 }
63
64 #[mt_derive(to = "clt")]
65 pub struct ObjSprite {
66     pub frame0: [i16; 2],
67     pub frames: u16,
68     pub frame_duration: f32,
69     pub view_angle_frames: bool,
70 }
71
72 #[mt_derive(to = "clt")]
73 pub struct ObjAnim {
74     pub frames: [i32; 2],
75     pub speed: f32,
76     pub blend: f32,
77     pub no_loop: bool,
78 }
79
80 #[mt_derive(to = "clt")]
81 pub struct ObjBonePos {
82     pub pos: [f32; 3],
83     pub rot: [f32; 3],
84 }
85
86 #[mt_derive(to = "clt")]
87 pub struct ObjAttach {
88     pub parent_id: u16,
89     pub bone: String,
90     pub pos: [f32; 3],
91     pub rot: [f32; 3],
92     pub force_visible: bool,
93 }
94
95 #[mt_derive(to = "clt")]
96 pub struct ObjPhysicsOverride {
97     pub walk: f32,
98     pub jump: f32,
99     pub gravity: f32,
100     // the following are player only
101     pub no_sneak: bool,
102     pub no_sneak_glitch: bool,
103     pub old_sneak: bool,
104 }
105
106 pub const GENERIC_CAO: u8 = 101;
107
108 #[mt_derive(to = "clt", repr = "u8", tag = "type", content = "data")]
109 pub enum ObjMsg {
110     Props(Box<ObjProps>) = 0,
111     Pos(ObjPos),
112     TextureMod {
113         #[serde(rename = "mod")]
114         texture_mod: String,
115     },
116     Sprite(ObjSprite),
117     Hp {
118         hp: u16,
119     },
120     ArmorGroups {
121         armor: HashMap<String, u16>,
122     },
123     Anim(ObjAnim),
124     BonePos {
125         bone: String,
126         pos: ObjBonePos,
127     },
128     Attach(ObjAttach),
129     PhysicsOverride(ObjPhysicsOverride),
130     SpawnInfant {
131         #[mt(const_after = "GENERIC_CAO")]
132         id: u16,
133     } = 11,
134     AnimSpeed {
135         speed: f32,
136     },
137 }
138
139 #[mt_derive(to = "clt")]
140 pub struct ObjIdMsg {
141     pub id: u16,
142     #[mt(size = "u16")]
143     pub msg: ObjMsg,
144 }
145
146 #[mt_derive(to = "clt")]
147 pub struct ObjInitMsg(#[mt(size = "u32")] pub ObjMsg);
148
149 #[mt_derive(to = "clt")]
150 pub struct ObjInitData {
151     #[mt(const_before = "1u8")] // version
152     pub name: String,
153     pub is_player: bool,
154     pub id: u16,
155     pub pos: [f32; 3],
156     pub rot: [f32; 3],
157     pub hp: u16,
158     #[mt(len = "u8")]
159     pub msgs: Vec<ObjInitMsg>,
160 }
161
162 #[mt_derive(to = "clt")]
163 pub struct ObjAdd {
164     pub id: u16,
165     #[mt(const_before = "GENERIC_CAO")]
166     #[mt(size = "u32")]
167     pub init_data: ObjInitData,
168 }