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