}
}
-VG_STATIC void ent_challenge_preupdate( ent_challenge *challenge ){
+VG_STATIC void ent_challenge_preupdate( ent_challenge *challenge, int active ){
world_instance *world = world_current_instance();
+ /* maximum distance from active challenge */
+ if( !active ){
+ f32 min_dist2 = 999999.9f;
+
+ if( mdl_entity_id_type( challenge->first ) == k_ent_objective ){
+ u32 next = challenge->first;
+ while( mdl_entity_id_type(next) == k_ent_objective ){
+ u32 index = mdl_entity_id_id( next );
+ ent_objective *objective = mdl_arritm(&world->ent_objective,index);
+ next = objective->id_next;
+
+ f32 d2 = v3_dist2( localplayer.rb.co, objective->transform.co );
+ if( d2 < min_dist2 )
+ min_dist2 = d2;
+ }
+ }
+
+ f32 max_dist = 100.0f;
+ if( min_dist2 > max_dist*max_dist ){
+ world_static.challenge_target = NULL;
+ world_static.challenge_timer = 0.0f;
+ world_static.focused_entity = 0;
+ audio_oneshot_3d( &audio_challenge[6], localplayer.rb.co,
+ 30.0f, 1.0f );
+ }
+ return;
+ }
+
if( mdl_entity_id_type( challenge->camera ) == k_ent_camera ){
u32 index = mdl_entity_id_id( challenge->camera );
ent_camera *cam = mdl_arritm( &world->ent_camera, index );
#include "entity.h"
-VG_STATIC void ent_challenge_preupdate( ent_challenge *challenge );
+VG_STATIC void ent_challenge_preupdate( ent_challenge *challenge, int active );
VG_STATIC void ent_challenge_call( world_instance *world, ent_call *call );
#endif /* ENT_CHALLENGE_H */
else {
audio_oneshot_3d( &audio_challenge[6], localplayer.rb.co,
30.0f, 1.0f );
- vg_error( "challenge fialed\n" );
+ vg_error( "challenge failed\n" );
world_static.challenge_target = NULL;
world_static.challenge_timer = 0.0f;
+ world_static.focused_entity = 0;
}
}
}
* VG event preupdate
*/
void temp_update_playermodel(void);
-VG_STATIC void ent_skateshop_preupdate( ent_skateshop *shop ){
+VG_STATIC void ent_skateshop_preupdate( ent_skateshop *shop, int active ){
+ if( !active ) return;
+
/* input filter */
world_instance *world = world_current_instance();
}
static global_skateshop={.render={.reg_id=0xffffffff,.world_reg=0xffffffff}};
-VG_STATIC void ent_skateshop_preupdate( ent_skateshop *shop );
+VG_STATIC void ent_skateshop_preupdate( ent_skateshop *shop, int active );
VG_STATIC void skateshop_render( ent_skateshop *shop );
#endif /* ENT_SKATESHOP_H */
vg_slewf( &world_static.focus_strength, active,
vg.time_frame_delta * (1.0f/0.5f) );
- if( !active ) return;
-
u32 type = mdl_entity_id_type( world_static.focused_entity ),
index = mdl_entity_id_id( world_static.focused_entity );
world_instance *world = world_current_instance();
if( type == k_ent_skateshop ){
ent_skateshop *skateshop = mdl_arritm( &world->ent_skateshop, index );
- ent_skateshop_preupdate( skateshop );
+ ent_skateshop_preupdate( skateshop, active );
}
else if( type == k_ent_challenge ){
ent_challenge *challenge = mdl_arritm( &world->ent_challenge, index );
- ent_challenge_preupdate( challenge );
- }
- else {
- vg_fatal_error( "Programming error\n" );
+ ent_challenge_preupdate( challenge, active );
}
}