ce87366421522049a14c304c74331c2dee5766fc
6 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 ){ /* unlock() */
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 if( (localplayer
.subsystem
== k_player_subsystem_walk
) &&
25 (world_static
.challenge_target
== NULL
) ){
26 world_static
.challenge_target
= NULL
;
27 world_entity_focus( call
->id
);
31 if( gui_new_helper( input_button_list
[k_srbind_maccept
], &text
))
32 vg_strcat( &text
, "start" );
33 if( gui_new_helper( input_button_list
[k_srbind_mback
], &text
))
34 vg_strcat( &text
, "exit" );
39 vg_error( "Unhandled function id: %u\n", call
->function
);
43 void ent_challenge_preupdate( ent_challenge
*challenge
, int active
)
45 world_instance
*world
= world_current_instance();
47 /* maximum distance from active challenge */
49 f32 min_dist2
= 999999.9f
;
51 if( mdl_entity_id_type( challenge
->first
) == k_ent_objective
){
52 u32 next
= challenge
->first
;
53 while( mdl_entity_id_type(next
) == k_ent_objective
){
54 u32 index
= mdl_entity_id_id( next
);
55 ent_objective
*objective
= mdl_arritm(&world
->ent_objective
,index
);
56 next
= objective
->id_next
;
58 f32 d2
= v3_dist2( localplayer
.rb
.co
, objective
->transform
.co
);
64 f32 max_dist
= 100.0f
;
65 if( min_dist2
> max_dist
*max_dist
){
66 world_static
.challenge_target
= NULL
;
67 world_static
.challenge_timer
= 0.0f
;
68 world_static
.focused_entity
= 0;
70 audio_oneshot_3d( &audio_challenge
[6], localplayer
.rb
.co
,
77 world_entity_focus_camera( world
, challenge
->camera
);
79 if( mdl_entity_id_type( challenge
->first
) == k_ent_objective
){
80 if( button_down( k_srbind_maccept
) ){
81 u32 index
= mdl_entity_id_id( challenge
->first
);
82 world_static
.challenge_target
= mdl_arritm( &world
->ent_objective
,
84 world_static
.challenge_timer
= 0.0f
;
85 world_entity_unfocus();
88 u32 next
= challenge
->first
;
89 while( mdl_entity_id_type(next
) == k_ent_objective
){
90 u32 index
= mdl_entity_id_id( next
);
91 ent_objective
*objective
= mdl_arritm(&world
->ent_objective
,index
);
92 objective
->flags
&= ~k_ent_objective_passed
;
93 next
= objective
->id_next
;
94 v3_fill( objective
->transform
.s
, 1.0f
);
97 audio_oneshot( &audio_challenge
[5], 1.0f
, 0.0f
);
103 if( button_down( k_srbind_mback
) ){
104 world_static
.challenge_target
= NULL
;
105 world_entity_unfocus();
108 audio_oneshot( &audio_challenge
[4], 1.0f
, 0.0f
);
114 static void ent_challenge_render( ent_challenge
*challenge
){