smooth block ui
[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 f32 ui_stopper, ui_residual;
211
212 ui_px ui_first_block_width, ui_residual_block_w;
213 };
214
215 struct ent_water{
216 mdl_transform transform;
217 float max_dist;
218 u32 reserved0, reserved1;
219 };
220
221 struct ent_audio_clip{
222 union{
223 mdl_file file;
224 audio_clip clip;
225 }_;
226
227 float probability;
228 };
229
230 struct volume_particles{
231 u32 blank, blank2;
232 };
233
234 struct volume_trigger{
235 u32 event, event_leave;
236 };
237
238 enum ent_volume_flag {
239 k_ent_volume_flag_particles = 0x1,
240 k_ent_volume_flag_disabled = 0x2
241 };
242
243 struct ent_volume{
244 mdl_transform transform;
245 m4x3f to_world, to_local;
246 u32 flags;
247
248 u32 target;
249 union{
250 volume_trigger trigger;
251 volume_particles particles;
252 };
253 };
254
255 struct ent_audio{
256 mdl_transform transform;
257 u32 flags,
258 clip_start,
259 clip_count;
260 float volume, crossfade;
261 u32 behaviour,
262 group,
263 probability_curve,
264 max_channels;
265 };
266
267 struct ent_marker{
268 mdl_transform transform;
269 u32 pstr_alias;
270 };
271
272 enum skateshop_type{
273 k_skateshop_type_boardshop = 0,
274 k_skateshop_type_charshop = 1,
275 k_skateshop_type_worldshop = 2,
276 k_skateshop_type_DELETED = 3,
277 k_skateshop_type_server = 4
278 };
279
280 struct ent_skateshop{
281 mdl_transform transform;
282 u32 type, id_camera;
283
284 union{
285 struct{
286 u32 id_display,
287 id_info,
288 id_rack;
289 }
290 boards;
291
292 struct{
293 u32 id_display,
294 id_info;
295 }
296 character;
297
298 struct{
299 u32 id_display,
300 id_info;
301 }
302 worlds;
303
304 struct{
305 u32 id_lever;
306 }
307 server;
308 };
309 };
310
311 struct ent_swspreview{
312 u32 id_camera, id_display, id_display1;
313 };
314
315 struct ent_traffic{
316 mdl_transform transform;
317 u32 submesh_start,
318 submesh_count,
319 start_node,
320 node_count;
321 float speed,
322 t;
323 u32 index; /* into the path */
324 };
325
326 struct ent_camera{
327 mdl_transform transform;
328 float fov;
329 };
330
331 enum ent_menuitem_type{
332 k_ent_menuitem_type_visual = 0,
333 k_ent_menuitem_type_event_button = 1,
334 k_ent_menuitem_type_page_button = 2,
335 k_ent_menuitem_type_toggle = 3,
336 k_ent_menuitem_type_slider = 4,
337 k_ent_menuitem_type_page = 5,
338 k_ent_menuitem_type_binding = 6,
339 k_ent_menuitem_type_visual_nocol = 7,
340 k_ent_menuitem_type_disabled = 90
341 };
342
343 enum ent_menuitem_stack_behaviour{
344 k_ent_menuitem_stack_append = 0,
345 k_ent_menuitem_stack_replace = 1
346 };
347
348 typedef struct ent_menuitem ent_menuitem;
349 struct ent_menuitem{
350 u32 type, groups,
351 id_links[4]; /* ent_menuitem */
352 f32 factive, fvisible;
353
354 mdl_transform transform;
355 u32 submesh_start, submesh_count;
356
357 union{ u64 _u64; /* force storage for 64bit pointers */
358 i32 *pi32;
359 f32 *pf32;
360 void *pvoid;
361 };
362
363 union{
364 struct{
365 u32 pstr_name;
366 }
367 visual;
368
369 struct{
370 u32 id_min, /* ent_marker */
371 id_max, /* . */
372 id_handle, /* ent_menuitem */
373 pstr_data;
374 }
375 slider;
376
377 struct{
378 u32 pstr,
379 stack_behaviour;
380 }
381 button;
382
383 struct{
384 u32 id_check, /* ent_menuitem */
385 pstr_data;
386 v3f offset; /* relative to parent */
387 }
388 checkmark;
389
390 struct{
391 u32 pstr_name,
392 id_entrypoint, /* ent_menuitem */
393 id_viewpoint; /* ent_camera */
394 }
395 page;
396
397 struct{
398 u32 pstr_bind,
399 font_variant;
400 }
401 binding;
402 };
403 };
404
405 struct ent_worldinfo{
406 u32 pstr_name, pstr_author, pstr_desc;
407 f32 timezone;
408 u32 pstr_skybox;
409 };
410
411 static ent_marker *ent_find_marker( mdl_context *mdl,
412 mdl_array_ptr *arr, const char *alias )
413 {
414 for( u32 i=0; i<mdl_arrcount(arr); i++ ){
415 ent_marker *marker = mdl_arritm( arr, i );
416
417 if( !strcmp( mdl_pstr( mdl, marker->pstr_alias ), alias ) ){
418 return marker;
419 }
420 }
421
422 return NULL;
423 }
424
425 enum channel_behaviour{
426 k_channel_behaviour_unlimited = 0,
427 k_channel_behaviour_discard_if_full = 1,
428 k_channel_behaviour_crossfade_if_full = 2
429 };
430
431 enum probability_curve{
432 k_probability_curve_constant = 0,
433 k_probability_curve_wildlife_day = 1,
434 k_probability_curve_wildlife_night = 2
435 };
436
437 struct ent_font{
438 u32 alias,
439 variant_start,
440 variant_count,
441 glyph_start,
442 glyph_count,
443 glyph_utf32_base;
444 };
445
446 struct ent_font_variant{
447 u32 name,
448 material_id;
449 };
450
451 struct ent_glyph{
452 v2f size;
453 u32 indice_start,
454 indice_count;
455 };
456
457 struct ent_ccmd{
458 u32 pstr_command;
459 };
460
461 enum ent_objective_filter{
462 k_ent_objective_filter_none = 0x00000000,
463 k_ent_objective_filter_trick_shuvit = 0x00000001,
464 k_ent_objective_filter_trick_kickflip = 0x00000002,
465 k_ent_objective_filter_trick_treflip = 0x00000004,
466 k_ent_objective_filter_trick_any =
467 k_ent_objective_filter_trick_shuvit|
468 k_ent_objective_filter_trick_treflip|
469 k_ent_objective_filter_trick_kickflip,
470 k_ent_objective_filter_flip_back = 0x00000008,
471 k_ent_objective_filter_flip_front = 0x00000010,
472 k_ent_objective_filter_flip_any =
473 k_ent_objective_filter_flip_back|
474 k_ent_objective_filter_flip_front,
475 k_ent_objective_filter_grind_truck_any = 0x00000020,
476 k_ent_objective_filter_grind_board_any = 0x00000040,
477 k_ent_objective_filter_grind_any =
478 k_ent_objective_filter_grind_truck_any|
479 k_ent_objective_filter_grind_board_any,
480 k_ent_objective_filter_footplant = 0x00000080,
481 k_ent_objective_filter_passthrough = 0x00000100
482 };
483
484 enum ent_objective_flag {
485 k_ent_objective_hidden = 0x1,
486 k_ent_objective_passed = 0x2
487 };
488
489 struct ent_objective{
490 mdl_transform transform;
491 u32 submesh_start,
492 submesh_count,
493 flags,
494 id_next,
495 filter,filter2,
496 id_win,
497 win_event;
498 f32 time_limit;
499 };
500
501 enum ent_challenge_flag {
502 k_ent_challenge_timelimit = 0x1
503 };
504
505 struct ent_challenge{
506 mdl_transform transform;
507 u32 pstr_alias,
508 flags,
509 target,
510 target_event,
511 reset,
512 reset_event,
513 first,
514 camera,
515 status;
516 };
517
518 struct ent_relay {
519 u32 targets[4][2];
520 };
521
522 struct ent_cubemap {
523 v3f co;
524 u32 resolution, live, texture_id,
525 framebuffer_id, renderbuffer_id, placeholder[2];
526 };
527
528 typedef struct ent_call ent_call;
529 struct ent_call{
530 u32 id, function;
531 void *data;
532 };
533
534 struct ent_miniworld {
535 mdl_transform transform;
536 u32 pstr_world;
537 u32 camera;
538 u32 proxy;
539 };
540
541 struct ent_prop {
542 mdl_transform transform;
543 u32 submesh_start, submesh_count, flags;
544 };
545
546 struct ent_region {
547 mdl_transform transform;
548 u32 submesh_start, submesh_count, pstr_title, flags, zone_volume;
549 };
550
551 #include "world.h"
552 static void entity_call( world_instance *world, ent_call *call );
553
554 #endif /* ENTITY_H */