modular stuffs
[carveJwlIkooP6JGAAIwe30JlM.git] / entity.h
1 #ifndef ENTITY_H
2 #define ENTITY_H
3
4 #include "model.h"
5
6 typedef struct ent_spawn ent_spawn;
7 typedef struct ent_light ent_light;
8 typedef struct ent_gate ent_gate;
9 typedef struct ent_route_node ent_route_node;
10 typedef struct ent_path_index ent_path_index;
11 typedef struct ent_checkpoint ent_checkpoint;
12 typedef struct ent_route ent_route;
13 typedef struct ent_water ent_water;
14 typedef struct ent_audio_clip ent_audio_clip;
15 typedef struct volume_particles volume_particles;
16 typedef struct volume_trigger volume_trigger;
17 typedef struct ent_volume ent_volume;
18 typedef struct ent_audio ent_audio;
19 typedef struct ent_index ent_index;
20 typedef struct ent_marker ent_marker;
21 typedef struct ent_font ent_font;
22 typedef struct ent_font_variant ent_font_variant;
23 typedef struct ent_glyph ent_glyph;
24
25 enum entity_alias{
26 k_ent_none = 0,
27 k_ent_gate = 1,
28 k_ent_spawn = 2,
29 k_ent_route_node = 3,
30 k_ent_route = 4,
31 k_ent_water = 5,
32 k_ent_volume = 6,
33 k_ent_audio = 7,
34 k_ent_marker = 8,
35 k_ent_font = 9,
36 k_ent_font_variant= 10,
37 k_ent_traffic = 11
38 };
39
40 static u32 mdl_entity_id_type( u32 entity_id )
41 {
42 return (entity_id & 0xffff0000) >> 16;
43 }
44
45 static u32 mdl_entity_id_id( u32 entity_id )
46 {
47 return entity_id & 0x0000ffff;
48 }
49
50 struct ent_index{
51 u32 type,
52 index;
53 };
54
55 enum entity_function{
56 k_ent_function_trigger,
57 k_ent_function_particle_spawn
58 };
59
60 struct ent_spawn{
61 mdl_transform transform;
62 u32 pstr_name;
63 };
64
65 enum light_type{
66 k_light_type_point = 0,
67 k_light_type_spot = 1
68 };
69
70 struct ent_light{
71 mdl_transform transform;
72 u32 daytime,
73 type;
74
75 v4f colour;
76 float angle,
77 range;
78
79 m4x3f inverse_world;
80 v2f angle_sin_cos;
81 };
82
83 enum gate_type{
84 k_gate_type_unlinked = 0,
85 k_gate_type_teleport = 1,
86 k_gate_type_nonlocal_unlinked = 2,
87 k_gate_type_nonlocel = 3
88 };
89
90 struct ent_gate{
91 u32 type,
92 target;
93
94 v3f dimensions,
95 co[2];
96
97 v4f q[2];
98
99 /* runtime */
100 m4x3f to_world, transport;
101
102 union{
103 u32 timing_version;
104
105 struct{
106 u8 ref_count;
107 };
108 };
109
110 double timing_time;
111 u16 routes[4]; /* routes that pass through this gate */
112 u8 route_count;
113 };
114
115 struct ent_route_node{
116 v3f co;
117 u8 ref_count, ref_total;
118 };
119
120 struct ent_path_index{
121 u16 index;
122 };
123
124 struct ent_checkpoint{
125 u16 gate_index,
126 path_start,
127 path_count;
128 };
129
130 struct ent_route{
131
132 union{
133 mdl_transform transform;
134 u32 official_track_id;
135 };
136
137 u32 pstr_name;
138 u16 checkpoints_start,
139 checkpoints_count;
140
141 v4f colour;
142
143 /* runtime */
144 u16 active_checkpoint,
145 valid_checkpoints;
146
147 float factive;
148 m4x3f board_transform;
149 mdl_submesh sm;
150 double timing_base;
151 };
152
153 struct ent_water{
154 mdl_transform transform;
155 float max_dist;
156 u32 reserved0, reserved1;
157 };
158
159 struct ent_audio_clip{
160 union{
161 mdl_file file;
162 audio_clip clip;
163 };
164
165 float probability;
166 };
167
168 struct volume_particles{
169 u32 blank, blank2;
170 };
171
172 struct volume_trigger{
173 u32 event, blank;
174 };
175
176 enum volume_subtype{
177 k_volume_subtype_trigger,
178 k_volume_subtype_particle
179 };
180
181 struct ent_volume{
182 mdl_transform transform;
183 m4x3f to_world, to_local;
184 u32 type;
185
186 ent_index target;
187
188 union{
189 volume_trigger trigger;
190 volume_particles particles;
191 };
192 };
193
194 struct ent_audio{
195 mdl_transform transform;
196 u32 flags,
197 clip_start,
198 clip_count;
199 float volume, crossfade;
200 u32 behaviour,
201 group,
202 probability_curve,
203 max_channels;
204 };
205
206 struct ent_marker{
207 mdl_transform transform;
208 u32 pstr_alias;
209 };
210
211 VG_STATIC ent_marker *ent_find_marker( mdl_context *mdl,
212 mdl_array_ptr *arr, const char *alias )
213 {
214 for( u32 i=0; i<mdl_arrcount(arr); i++ ){
215 ent_marker *marker = mdl_arritm( arr, i );
216
217 if( !strcmp( mdl_pstr( mdl, marker->pstr_alias ), alias ) ){
218 return marker;
219 }
220 }
221
222 return NULL;
223 }
224
225 enum channel_behaviour{
226 k_channel_behaviour_unlimited = 0,
227 k_channel_behaviour_discard_if_full = 1,
228 k_channel_behaviour_crossfade_if_full = 2
229 };
230
231 enum probability_curve{
232 k_probability_curve_constant = 0,
233 k_probability_curve_wildlife_day = 1,
234 k_probability_curve_wildlife_night = 2
235 };
236
237 struct ent_font{
238 u32 alias,
239 variant_start,
240 variant_count,
241 glyph_start,
242 glyph_count,
243 glyph_utf32_base;
244 };
245
246 struct ent_font_variant{
247 u32 name,
248 material_id;
249 };
250
251 struct ent_glyph{
252 v2f size;
253 u32 indice_start,
254 indice_count;
255 };
256
257 #endif /* ENTITY_H */