Merge all features from glider feature branch
[carveJwlIkooP6JGAAIwe30JlM.git] / entity.c
1 #ifndef ENTITY_C
2 #define ENTITY_C
3
4 #include "world.h"
5 #include "entity.h"
6 #include "world_entity.h"
7
8 #include "ent_skateshop.c"
9 #include "ent_objective.c"
10 #include "ent_challenge.c"
11 #include "ent_relay.c"
12 #include "ent_route.c"
13 #include "ent_miniworld.c"
14 #include "ent_region.c"
15 #include "ent_traffic.c"
16 #include "ent_glider.c"
17
18 typedef void (*fn_entity_call_handler)( world_instance *, ent_call *);
19
20 static void entity_call( world_instance *world, ent_call *call ){
21 u32 type = mdl_entity_id_type( call->id );
22
23 fn_entity_call_handler table[] = {
24 [k_ent_volume] = ent_volume_call,
25 [k_ent_audio] = ent_audio_call,
26 [k_ent_skateshop] = ent_skateshop_call,
27 [k_ent_objective] = ent_objective_call,
28 [k_ent_ccmd] = ent_ccmd_call,
29 [k_ent_gate] = ent_gate_call,
30 [k_ent_relay] = ent_relay_call,
31 [k_ent_challenge] = ent_challenge_call,
32 [k_ent_route] = ent_route_call,
33 [k_ent_miniworld] = ent_miniworld_call,
34 [k_ent_region] = ent_region_call,
35 [k_ent_glider] = ent_glider_call
36 };
37
38 if( type >= vg_list_size(table) ){
39 vg_error( "call to entity type: %u is out of range\n", type );
40 return;
41 }
42
43 fn_entity_call_handler fn = table[ type ];
44
45 if( !fn ){
46 vg_error( "call to entity type: %u is undefined\n", type );
47 return;
48 }
49
50 fn( world, call );
51 }
52
53 #endif /* ENTITY_C */