]> git.lizzy.rs Git - mt_net.git/blob - src/to_clt/obj.rs
Use cgmath and support BS constant
[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: Aabb3<f32>,
20     pub selection_box: Aabb3<f32>,
21     pub pointable: bool,
22     pub visual: ObjVisual,
23     pub visual_size: Vector3<f32>,
24     pub textures: Vec<String>,
25     pub sprite_sheet_size: Vector2<i16>, // in sprites
26     pub sprite_pos: Point2<i16>,         // in sprite sheet
27     pub visible: bool,
28     pub make_footstep_sounds: bool,
29     pub rotate_speed: Rad<f32>, // 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: Deg<f32>,
36     pub backface_cull: bool,
37     pub nametag: String,
38     pub nametag_color: Color,
39     pub face_rotate_speed: Deg<f32>, // 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: Deg<f32>, // 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     #[mt(multiplier = "BS")]
56     pub pos: Point3<f32>,
57     #[mt(multiplier = "BS")]
58     pub vel: Vector3<f32>,
59     #[mt(multiplier = "BS")]
60     pub acc: Vector3<f32>,
61     pub rot: Euler<Deg<f32>>,
62     pub interpolate: bool,
63     pub end: bool,
64     pub update_interval: f32,
65 }
66
67 #[mt_derive(to = "clt")]
68 pub struct ObjSprite {
69     pub frame_0: Point2<i16>,
70     pub frames: u16,
71     pub frame_duration: f32,
72     pub view_angle_frames: bool,
73 }
74
75 #[mt_derive(to = "clt")]
76 pub struct ObjAnim {
77     pub frames: Vector2<i32>,
78     pub speed: f32,
79     pub blend: f32,
80     pub no_loop: bool,
81 }
82
83 #[mt_derive(to = "clt")]
84 pub struct ObjBonePos {
85     pub pos: Point3<f32>,
86     pub rot: Euler<Deg<f32>>,
87 }
88
89 #[mt_derive(to = "clt")]
90 pub struct ObjAttach {
91     pub parent_id: u16,
92     pub bone: String,
93     pub pos: Point3<f32>,
94     pub rot: Euler<Deg<f32>>,
95     pub force_visible: bool,
96 }
97
98 #[mt_derive(to = "clt")]
99 pub struct ObjPhysicsOverride {
100     pub walk: f32,
101     pub jump: f32,
102     pub gravity: f32,
103     // the following are player only
104     pub no_sneak: bool,
105     pub no_sneak_glitch: bool,
106     pub old_sneak: bool,
107 }
108
109 pub const GENERIC_CAO: u8 = 101;
110
111 #[mt_derive(to = "clt", repr = "u8", tag = "type", content = "data")]
112 pub enum ObjMsg {
113     Props(Box<ObjProps>) = 0,
114     Pos(ObjPos),
115     TextureMod {
116         #[serde(rename = "mod")]
117         texture_mod: String,
118     },
119     Sprite(ObjSprite),
120     Hp {
121         hp: u16,
122     },
123     ArmorGroups {
124         armor: HashMap<String, u16>,
125     },
126     Anim(ObjAnim),
127     BonePos {
128         bone: String,
129         pos: ObjBonePos,
130     },
131     Attach(ObjAttach),
132     PhysicsOverride(ObjPhysicsOverride),
133     SpawnInfant {
134         #[mt(const_after = "GENERIC_CAO")]
135         id: u16,
136     } = 11,
137     AnimSpeed {
138         speed: f32,
139     },
140 }
141
142 #[mt_derive(to = "clt")]
143 pub struct ObjIdMsg {
144     pub id: u16,
145     #[mt(size = "u16")]
146     pub msg: ObjMsg,
147 }
148
149 #[mt_derive(to = "clt")]
150 pub struct ObjInitMsg(#[mt(size = "u32")] pub ObjMsg);
151
152 #[mt_derive(to = "clt")]
153 pub struct ObjInitData {
154     #[mt(const_before = "1u8")] // version
155     pub name: String,
156     pub is_player: bool,
157     pub id: u16,
158     #[mt(multiplier = "BS")]
159     pub pos: Point3<f32>,
160     pub rot: Euler<Deg<f32>>,
161     pub hp: u16,
162     #[mt(len = "u8")]
163     pub msgs: Vec<ObjInitMsg>,
164 }
165
166 #[mt_derive(to = "clt")]
167 pub struct ObjAdd {
168     pub id: u16,
169     #[mt(const_before = "GENERIC_CAO")]
170     #[mt(size = "u32")]
171     pub init_data: ObjInitData,
172 }