switch to entity list
[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_challenge.c"
10
11 typedef void (*fn_entity_call_handler)( world_instance *, ent_call *);
12
13 VG_STATIC void entity_call( world_instance *world, ent_call *call ){
14 u32 type = mdl_entity_id_type( call->id );
15
16 fn_entity_call_handler table[] = {
17 [k_ent_volume] = ent_volume_call,
18 [k_ent_audio] = ent_audio_call,
19 [k_ent_skateshop] = ent_skateshop_call,
20 [k_ent_challenge] = ent_challenge_call,
21 [k_ent_ccmd] = ent_ccmd_call
22 };
23
24 if( type > vg_list_size(table) ){
25 vg_error( "call to entity type: %u is out of range\n", type );
26 return;
27 }
28
29 fn_entity_call_handler fn = table[ type ];
30
31 if( !fn ){
32 vg_error( "call to entity type: %u is undefined\n", type );
33 return;
34 }
35
36 fn( world, call );
37 }
38
39 #endif /* ENTITY_C */