515aeb09d5e456b813dbb00c40642cc7fa72348a
1 #ifndef ENT_CHALLENGE_C
2 #define ENT_CHALLENGE_C
7 VG_STATIC
void ent_challenge_call( world_instance
*world
, ent_call
*call
){
8 u32 index
= mdl_entity_id_id( call
->id
);
9 ent_challenge
*challenge
= mdl_arritm( &world
->ent_challenge
, index
);
11 if( call
->function
== 0 ){ /* challenge() */
12 if( !challenge
->status
){
13 vg_info( "challenge( '%s' )\n",
14 mdl_pstr( &world
->meta
, challenge
->pstr_alias
) );
17 call
.function
= challenge
->target_event
;
18 call
.id
= challenge
->target
;
19 entity_call( world
, &call
);
21 challenge
->status
= 1;
23 else if( call
->function
== 1 ){ /* view() */
24 world_entity_focus( call
->id
);
28 vg_error( "Unhandled function id: %u\n", call
->function
);
32 VG_STATIC
void ent_challenge_preupdate( ent_challenge
*challenge
){
33 world_instance
*world
= world_current_instance();
35 if( mdl_entity_id_type( challenge
->camera
) == k_ent_camera
){
36 u32 index
= mdl_entity_id_id( challenge
->camera
);
37 ent_camera
*cam
= mdl_arritm( &world
->ent_camera
, index
);
39 /* TODO COMPRESSION */
40 v3f dir
= {0.0f
,-1.0f
,0.0f
};
41 mdl_transform_vector( &cam
->transform
, dir
, dir
);
42 m3x3_mulv( localplayer
.invbasis
, dir
, dir
);
43 player_vector_angles( world_static
.focus_cam
.angles
, dir
, 1.0f
, 0.0f
);
44 v3_copy( cam
->transform
.co
, world_static
.focus_cam
.pos
);
45 world_static
.focus_cam
.fov
= cam
->fov
;
48 /* TODO COMPRESSION */
49 v3_copy( localplayer
.cam
.pos
, world_static
.focus_cam
.pos
);
50 v3_copy( localplayer
.cam
.angles
, world_static
.focus_cam
.angles
);
51 world_static
.focus_cam
.fov
= localplayer
.cam
.fov
;
52 world_static
.focus_cam
.nearz
= localplayer
.cam
.nearz
;
53 world_static
.focus_cam
.farz
= localplayer
.cam
.farz
;
56 if( button_down( k_srbind_mback
) ){
57 world_entity_unfocus();
62 VG_STATIC
void ent_challenge_render( ent_challenge
*challenge
){
66 #endif /* ENT_CHALLENGE_C */