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