add medals to miniworld display
[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_marker ent_marker;
20 typedef struct ent_traffic ent_traffic;
21 typedef struct ent_font ent_font;
22 typedef struct ent_font_variant ent_font_variant;
23 typedef struct ent_glyph ent_glyph;
24 typedef struct ent_skateshop ent_skateshop;
25 typedef struct ent_camera ent_camera;
26 typedef struct ent_swspreview ent_swspreview;
27 typedef struct ent_worldinfo ent_worldinfo;
28 typedef struct ent_ccmd ent_ccmd;
29 typedef struct ent_objective ent_objective;
30 typedef struct ent_challenge ent_challenge;
31 typedef struct ent_relay ent_relay;
32 typedef struct ent_cubemap ent_cubemap;
33 typedef struct ent_miniworld ent_miniworld;
34 typedef struct ent_prop ent_prop;
35
36 enum entity_alias{
37 k_ent_none = 0,
38 k_ent_gate = 1,
39 k_ent_spawn = 2,
40 k_ent_route_node = 3,
41 k_ent_route = 4,
42 k_ent_water = 5,
43 k_ent_volume = 6,
44 k_ent_audio = 7,
45 k_ent_marker = 8,
46 k_ent_font = 9,
47 k_ent_font_variant= 10,
48 k_ent_traffic = 11,
49 k_ent_skateshop = 12,
50 k_ent_camera = 13,
51 k_ent_swspreview = 14,
52 k_ent_menuitem = 15,
53 k_ent_worldinfo = 16,
54 k_ent_ccmd = 17,
55 k_ent_objective = 18,
56 k_ent_challenge = 19,
57 k_ent_relay = 20,
58 k_ent_cubemap = 21,
59 k_ent_miniworld = 22
60 };
61
62 static u32 mdl_entity_id_type( u32 entity_id ){
63 return (entity_id & 0x0fff0000) >> 16;
64 }
65
66 static u32 mdl_entity_id_id( u32 entity_id ){
67 return entity_id & 0x0000ffff;
68 }
69
70 static u32 mdl_entity_id( u32 type, u32 index ){
71 return (type & 0xfffff)<<16 | (index & 0xfffff);
72 }
73
74 enum entity_function{
75 k_ent_function_trigger,
76 k_ent_function_particle_spawn,
77 k_ent_function_trigger_leave
78 };
79
80 struct ent_spawn{
81 mdl_transform transform;
82 u32 pstr_name;
83 };
84
85 enum light_type{
86 k_light_type_point = 0,
87 k_light_type_spot = 1
88 };
89
90 struct ent_light{
91 mdl_transform transform;
92 u32 daytime,
93 type;
94
95 v4f colour;
96 float angle,
97 range;
98
99 m4x3f inverse_world;
100 v2f angle_sin_cos;
101 };
102
103 /* v101 */
104 #if 0
105 enum gate_type{
106 k_gate_type_unlinked = 0,
107 k_gate_type_teleport = 1,
108 k_gate_type_nonlocal_unlinked = 2,
109 k_gate_type_nonlocel = 3
110 };
111 #endif
112
113 /* v102+ */
114 enum ent_gate_flag{
115 k_ent_gate_linked = 0x1, /* this is a working portal */
116 k_ent_gate_nonlocal = 0x2, /* use the key string to link this portal.
117 NOTE: if set, it adds the flip flag. */
118 k_ent_gate_flip = 0x4, /* flip direction 180* for exiting portal */
119 k_ent_gate_custom_mesh = 0x8, /* use a custom submesh instead of default */
120 k_ent_gate_locked = 0x10,/* has to be unlocked to be useful */
121
122 k_ent_gate_clean_pass = 0x20,/* player didn't rewind while getting here */
123 };
124
125 struct ent_gate{
126 u32 flags,
127 target,
128 key;
129
130 v3f dimensions,
131 co[2];
132
133 v4f q[2];
134
135 /* runtime */
136 m4x3f to_world, transport;
137
138 union{
139 u32 timing_version;
140
141 struct{
142 u8 ref_count;
143 };
144 };
145
146 double timing_time;
147 u16 routes[4]; /* routes that pass through this gate */
148 u8 route_count;
149
150 /* v102+ */
151 u32 submesh_start, submesh_count;
152 };
153
154 struct ent_route_node{
155 v3f co;
156 u8 ref_count, ref_total;
157 };
158
159 struct ent_path_index{
160 u16 index;
161 };
162
163 struct ent_checkpoint{
164 u16 gate_index,
165 path_start,
166 path_count;
167 };
168
169 struct ent_route{
170 union{
171 mdl_transform transform;
172 u32 official_track_id;
173 }
174 anon;
175
176 u32 pstr_name;
177 u16 checkpoints_start,
178 checkpoints_count;
179
180 v4f colour;
181
182 /* runtime */
183 u16 active_checkpoint,
184 valid_checkpoints;
185
186 f32 factive;
187 m4x3f board_transform;
188 mdl_submesh sm;
189 f64 timing_base;
190
191 u32 id_camera; /* v103+ */
192
193 /* v104+, but always accessible */
194 u32 achievment_status;
195 f64 best_laptime;
196 };
197
198 struct ent_water{
199 mdl_transform transform;
200 float max_dist;
201 u32 reserved0, reserved1;
202 };
203
204 struct ent_audio_clip{
205 union{
206 mdl_file file;
207 audio_clip clip;
208 }_;
209
210 float probability;
211 };
212
213 struct volume_particles{
214 u32 blank, blank2;
215 };
216
217 struct volume_trigger{
218 u32 event, event_leave;
219 };
220
221 enum ent_volume_flag {
222 k_ent_volume_flag_particles = 0x1,
223 k_ent_volume_flag_disabled = 0x2
224 };
225
226 struct ent_volume{
227 mdl_transform transform;
228 m4x3f to_world, to_local;
229 u32 flags;
230
231 u32 target;
232 union{
233 volume_trigger trigger;
234 volume_particles particles;
235 };
236 };
237
238 struct ent_audio{
239 mdl_transform transform;
240 u32 flags,
241 clip_start,
242 clip_count;
243 float volume, crossfade;
244 u32 behaviour,
245 group,
246 probability_curve,
247 max_channels;
248 };
249
250 struct ent_marker{
251 mdl_transform transform;
252 u32 pstr_alias;
253 };
254
255 enum skateshop_type{
256 k_skateshop_type_boardshop = 0,
257 k_skateshop_type_charshop = 1,
258 k_skateshop_type_worldshop = 2,
259 k_skateshop_type_DELETED = 3,
260 k_skateshop_type_server = 4
261 };
262
263 struct ent_skateshop{
264 mdl_transform transform;
265 u32 type, id_camera;
266
267 union{
268 struct{
269 u32 id_display,
270 id_info,
271 id_rack;
272 }
273 boards;
274
275 struct{
276 u32 id_display,
277 id_info;
278 }
279 character;
280
281 struct{
282 u32 id_display,
283 id_info;
284 }
285 worlds;
286
287 struct{
288 u32 id_lever;
289 }
290 server;
291 };
292 };
293
294 struct ent_swspreview{
295 u32 id_camera, id_display, id_display1;
296 };
297
298 struct ent_traffic{
299 mdl_transform transform;
300 u32 submesh_start,
301 submesh_count,
302 start_node,
303 node_count;
304 float speed,
305 t;
306 u32 index; /* into the path */
307 };
308
309 struct ent_camera{
310 mdl_transform transform;
311 float fov;
312 };
313
314 enum ent_menuitem_type{
315 k_ent_menuitem_type_visual = 0,
316 k_ent_menuitem_type_event_button = 1,
317 k_ent_menuitem_type_page_button = 2,
318 k_ent_menuitem_type_toggle = 3,
319 k_ent_menuitem_type_slider = 4,
320 k_ent_menuitem_type_page = 5,
321 k_ent_menuitem_type_binding = 6,
322 k_ent_menuitem_type_visual_nocol = 7,
323 k_ent_menuitem_type_disabled = 90
324 };
325
326 enum ent_menuitem_stack_behaviour{
327 k_ent_menuitem_stack_append = 0,
328 k_ent_menuitem_stack_replace = 1
329 };
330
331 typedef struct ent_menuitem ent_menuitem;
332 struct ent_menuitem{
333 u32 type, groups,
334 id_links[4]; /* ent_menuitem */
335 f32 factive, fvisible;
336
337 mdl_transform transform;
338 u32 submesh_start, submesh_count;
339
340 union{ u64 _u64; /* force storage for 64bit pointers */
341 i32 *pi32;
342 f32 *pf32;
343 void *pvoid;
344 };
345
346 union{
347 struct{
348 u32 pstr_name;
349 }
350 visual;
351
352 struct{
353 u32 id_min, /* ent_marker */
354 id_max, /* . */
355 id_handle, /* ent_menuitem */
356 pstr_data;
357 }
358 slider;
359
360 struct{
361 u32 pstr,
362 stack_behaviour;
363 }
364 button;
365
366 struct{
367 u32 id_check, /* ent_menuitem */
368 pstr_data;
369 v3f offset; /* relative to parent */
370 }
371 checkmark;
372
373 struct{
374 u32 pstr_name,
375 id_entrypoint, /* ent_menuitem */
376 id_viewpoint; /* ent_camera */
377 }
378 page;
379
380 struct{
381 u32 pstr_bind,
382 font_variant;
383 }
384 binding;
385 };
386 };
387
388 struct ent_worldinfo{
389 u32 pstr_name, pstr_author, pstr_desc;
390 f32 timezone;
391 u32 pstr_skybox;
392 };
393
394 static ent_marker *ent_find_marker( mdl_context *mdl,
395 mdl_array_ptr *arr, const char *alias )
396 {
397 for( u32 i=0; i<mdl_arrcount(arr); i++ ){
398 ent_marker *marker = mdl_arritm( arr, i );
399
400 if( !strcmp( mdl_pstr( mdl, marker->pstr_alias ), alias ) ){
401 return marker;
402 }
403 }
404
405 return NULL;
406 }
407
408 enum channel_behaviour{
409 k_channel_behaviour_unlimited = 0,
410 k_channel_behaviour_discard_if_full = 1,
411 k_channel_behaviour_crossfade_if_full = 2
412 };
413
414 enum probability_curve{
415 k_probability_curve_constant = 0,
416 k_probability_curve_wildlife_day = 1,
417 k_probability_curve_wildlife_night = 2
418 };
419
420 struct ent_font{
421 u32 alias,
422 variant_start,
423 variant_count,
424 glyph_start,
425 glyph_count,
426 glyph_utf32_base;
427 };
428
429 struct ent_font_variant{
430 u32 name,
431 material_id;
432 };
433
434 struct ent_glyph{
435 v2f size;
436 u32 indice_start,
437 indice_count;
438 };
439
440 struct ent_ccmd{
441 u32 pstr_command;
442 };
443
444 enum ent_objective_filter{
445 k_ent_objective_filter_none = 0x00000000,
446 k_ent_objective_filter_trick_shuvit = 0x00000001,
447 k_ent_objective_filter_trick_kickflip = 0x00000002,
448 k_ent_objective_filter_trick_treflip = 0x00000004,
449 k_ent_objective_filter_trick_any =
450 k_ent_objective_filter_trick_shuvit|
451 k_ent_objective_filter_trick_treflip|
452 k_ent_objective_filter_trick_kickflip,
453 k_ent_objective_filter_flip_back = 0x00000008,
454 k_ent_objective_filter_flip_front = 0x00000010,
455 k_ent_objective_filter_flip_any =
456 k_ent_objective_filter_flip_back|
457 k_ent_objective_filter_flip_front,
458 k_ent_objective_filter_grind_truck_any = 0x00000020,
459 k_ent_objective_filter_grind_board_any = 0x00000040,
460 k_ent_objective_filter_grind_any =
461 k_ent_objective_filter_grind_truck_any|
462 k_ent_objective_filter_grind_board_any,
463 k_ent_objective_filter_footplant = 0x00000080,
464 k_ent_objective_filter_passthrough = 0x00000100
465 };
466
467 enum ent_objective_flag {
468 k_ent_objective_hidden = 0x1,
469 k_ent_objective_passed = 0x2
470 };
471
472 struct ent_objective{
473 mdl_transform transform;
474 u32 submesh_start,
475 submesh_count,
476 flags,
477 id_next,
478 filter,filter2,
479 id_win,
480 win_event;
481 f32 time_limit;
482 };
483
484 enum ent_challenge_flag {
485 k_ent_challenge_timelimit = 0x1
486 };
487
488 struct ent_challenge{
489 mdl_transform transform;
490 u32 pstr_alias,
491 flags,
492 target,
493 target_event,
494 reset,
495 reset_event,
496 first,
497 camera,
498 status;
499 };
500
501 struct ent_relay {
502 u32 targets[4][2];
503 };
504
505 struct ent_cubemap {
506 v3f co;
507 u32 resolution, live, texture_id,
508 framebuffer_id, renderbuffer_id, placeholder[2];
509 };
510
511 typedef struct ent_call ent_call;
512 struct ent_call{
513 u32 id, function;
514 void *data;
515 };
516
517 struct ent_miniworld {
518 mdl_transform transform;
519 u32 pstr_world;
520 u32 camera;
521 u32 proxy;
522 };
523
524 struct ent_prop {
525 mdl_transform transform;
526 u32 submesh_start, submesh_count, flags;
527 };
528
529 #include "world.h"
530 static void entity_call( world_instance *world, ent_call *call );
531
532 #endif /* ENTITY_H */