switch to entity list
[carveJwlIkooP6JGAAIwe30JlM.git] / ent_challenge.c
1 #ifndef ENT_CHALLENGE_C
2 #define ENT_CHALLENGE_C
3
4 #include "world.h"
5 #include "world_load.h"
6 #include "entity.h"
7
8 VG_STATIC void ent_challenge_pass( world_instance *world,
9 ent_challenge *challenge ){
10 if( challenge->id_next ){
11 world->challenge_timer += challenge->filter;
12
13 u32 index = mdl_entity_id_id( challenge->id_next );
14 ent_challenge *next = mdl_arritm( &world->ent_challenge, index );
15 world->challenge_target = next;
16
17 vg_info( "pass challenge point\n" );
18 }
19 else {
20 vg_success( "NYU Film school graduate SUCKAH\n" );
21 world->challenge_target = NULL;
22 world->challenge_timer = 0.0f;
23 }
24 }
25
26 VG_STATIC void ent_challenge_call( world_instance *world, ent_call *call ){
27 u32 index = mdl_entity_id_id( call->id );
28 ent_challenge *challenge = mdl_arritm( &world->ent_challenge, index );
29
30 if( call->function == 0 ){
31 if( world->challenge_target ){
32 if( world->challenge_target == challenge ){
33 ent_challenge_pass( world, challenge );
34 }
35 else {
36 vg_error( "womp womp\n" );
37 world->challenge_target = NULL;
38 world->challenge_timer = 0.0f;
39 }
40 }
41 }
42 else if( call->function == 1 ){
43 vg_info( "begin the challenge\n" );
44 world->challenge_timer = 0.0f;
45 ent_challenge_pass( world, challenge );
46 }
47 else {
48 vg_print_backtrace();
49 vg_error( "Unhandled function id: %u\n", call->function );
50 }
51 }
52
53 #endif /* ENT_CHALLENGE_C */