{
if( world_set_event( k_world_event_challenge ) )
{
- _world.active_challenge = challenge;
+ _world.challenge_state = k_challenge_state_none;
+ _world.active_challenge_id = call->id;
gui_helper_reset( 1 );
vg_str text;
if( gui_new_helper( input_button_list[k_srbind_maccept], &text ))
- vg_strcat( &text, "Start" );
+ vg_strcat( &text, "View Challenge" );
}
}
}
else if( call->function == -1 ) /* unview() */
{
- if( world_clear_event( k_world_event_challenge ) )
- {
- _world.active_challenge = NULL;
- gui_helper_reset( k_gui_helper_mode_clear );
- }
- return k_entity_call_result_OK;
-
-#if 0
- if( (localplayer.subsystem == k_player_subsystem_walk) &&
- (_world.challenge_target == NULL) )
+ if( _world.challenge_state != k_challenge_state_running )
{
- _world.challenge_target = NULL;
- world_entity_set_focus( call->id );
- world_entity_focus_modal();
-
- gui_helper_clear();
- vg_str text;
- if( gui_new_helper( input_button_list[k_srbind_maccept], &text ))
- vg_strcat( &text, "Start" );
- if( gui_new_helper( input_button_list[k_srbind_mback], &text ))
- vg_strcat( &text, "Exit" );
+ if( world_clear_event( k_world_event_challenge ) )
+ {
+ _world.challenge_state = k_challenge_state_none;
+ _world.active_challenge_id = 0;
+ gui_helper_reset( k_gui_helper_mode_clear );
+ }
}
return k_entity_call_result_OK;
-#endif
}
else
return k_entity_call_result_unhandled;
}
-#if 0
-void ent_challenge_preupdate( ent_focus_context *ctx )
+void ent_challenge_update(void)
{
- world_instance *world = ctx->world;
- ent_challenge *challenge = af_arritm( &world->ent_challenge, ctx->index );
-
- /* maximum distance from active challenge */
- if( !ctx->active )
- {
- f32 min_dist2 = 999999.9f;
+ if( _world.event != k_world_event_challenge )
+ return;
- 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 = af_arritm(&world->ent_objective,index);
- next = objective->id_next;
+ world_instance *world = &_world.main;
- f32 d2 = v3_dist2( localplayer.rb.co, objective->transform.co );
- if( d2 < min_dist2 )
- min_dist2 = d2;
- }
- }
+ u32 index = mdl_entity_id_id( _world.active_challenge_id );
+ ent_challenge *challenge = af_arritm( &world->ent_challenge, index );
- f32 max_dist = 100.0f;
- if( min_dist2 > max_dist*max_dist ){
- _world.challenge_target = NULL;
- _world.challenge_timer = 0.0f;
- world_entity_clear_focus();
- audio_lock();
- audio_oneshot_3d( &audio_challenge[6], localplayer.rb.co,
- 30.0f, 1.0f );
- audio_unlock();
+ if( _world.challenge_state == k_challenge_state_viewing )
+ {
+ if( challenge->camera )
+ {
+ vg_camera temp;
+ ent_camera_unpack( af_arritm( &world->ent_camera, mdl_entity_id_id(challenge->camera) ), &temp );
+ world_set_entity_driven_camera( &temp );
}
- return;
- }
- world_entity_focus_camera( world, challenge->camera );
-
- if( mdl_entity_id_type( challenge->first ) == k_ent_objective )
- {
if( button_down( k_srbind_maccept ) )
{
- u32 index = mdl_entity_id_id( challenge->first );
- _world.challenge_target = af_arritm( &world->ent_objective,
- index );
+ gui_helper_reset( k_gui_helper_mode_clear );
+ _world.challenge_state = k_challenge_state_running;
+ localplayer.immobile = 0; /* TODO: Unify this probably after eating some potats */
+ menu.disable_open = 0;
+ srinput.state = k_input_state_resume;
+
+ u32 first_objective_index = mdl_entity_id_id( challenge->first );
+ _world.challenge_target = af_arritm( &world->ent_objective, first_objective_index );
_world.challenge_timer = 0.0f;
- world_entity_exit_modal();
- gui_helper_clear();
u32 next = challenge->first;
- while( mdl_entity_id_type(next) == k_ent_objective ){
+ while( mdl_entity_id_type(next) == k_ent_objective )
+ {
u32 index = mdl_entity_id_id( next );
ent_objective *objective = af_arritm(&world->ent_objective,index);
objective->flags &= ~k_ent_objective_passed;
audio_lock();
audio_oneshot( &audio_challenge[5], 1.0f, 0.0f );
audio_unlock();
- return;
}
- }
- else
- {
- if( button_down( k_srbind_maccept ) )
+ else if( button_down( k_srbind_mback ) )
{
- ent_call call;
- call.data = NULL;
- call.function = challenge->target_event;
- call.id = challenge->target;
- entity_call( world, &call );
+ gui_helper_reset( k_gui_helper_mode_clear );
+ _world.challenge_state = k_challenge_state_none;
+ localplayer.immobile = 0; /* TODO: Unify this probably after eating some potats */
+ menu.disable_open = 0;
+ srinput.state = k_input_state_resume;
}
}
-
- if( button_down( k_srbind_mback ) )
+ else if( _world.challenge_state == k_challenge_state_running )
{
- _world.challenge_target = NULL;
- world_entity_exit_modal();
- world_entity_clear_focus();
- gui_helper_clear();
- audio_lock();
- audio_oneshot( &audio_challenge[4], 1.0f, 0.0f );
- audio_unlock();
- return;
- }
-}
+ f32 min_dist2 = 999999.9f;
-static void ent_challenge_render( ent_challenge *challenge ){
-
-}
-#endif
+ 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 = af_arritm(&world->ent_objective,index);
+ next = objective->id_next;
-void ent_challenge_update(void)
-{
- if( _world.event != k_world_event_challenge )
- return;
+ f32 d2 = v3_dist2( localplayer.rb.co, objective->transform.co );
+ if( d2 < min_dist2 )
+ min_dist2 = d2;
+ }
+ }
- if( _world.challenge_running )
- {
+ f32 max_dist = 100.0f;
+ if( min_dist2 > max_dist*max_dist )
+ {
+ if( world_clear_event( k_world_event_challenge ) )
+ {
+ _world.active_challenge_id = 0;
+ _world.challenge_target = NULL;
+ _world.challenge_timer = 0.0f;
+ audio_lock();
+ audio_oneshot_3d( &audio_challenge[6], localplayer.rb.co, 30.0f, 1.0f );
+ audio_unlock();
+ vg_info( "Challenge expired due to player being out of range.\n" );
+ }
+ }
}
- else
+ else if( _world.challenge_state == k_challenge_state_none )
{
- ent_challenge *challenge = _world.active_challenge;
if( challenge->flags & k_ent_challenge_is_story )
{
if( button_down( k_srbind_maccept ) )
}
else
{
- /* activate the actual challenge blah blah */
+ if( button_down( k_srbind_maccept ) )
+ {
+ gui_helper_reset( k_gui_helper_mode_clear );
+ vg_str text;
+ if( gui_new_helper( input_button_list[k_srbind_maccept], &text ))
+ vg_strcat( &text, "Start" );
+ if( gui_new_helper( input_button_list[k_srbind_mback], &text ))
+ vg_strcat( &text, "Exit" );
+
+ localplayer.immobile = 1;
+ menu.disable_open = 1;
+ srinput.state = k_input_state_resume;
+ _world.challenge_state = k_challenge_state_viewing;
+ }
}
}
}
#include "player.h"
#include "player_skate.h"
-static void ent_objective_pass( world_instance *world,
- ent_objective *objective ){
+static void ent_objective_pass( world_instance *world, ent_objective *objective )
+{
if( objective->id_next )
{
u32 index = mdl_entity_id_id( objective->id_next );
if( next->filter & k_ent_objective_filter_passthrough )
ent_objective_pass( world, next );
- else{
+ else
+ {
vg_info( "pass challenge point\n" );
audio_lock();
- audio_oneshot_3d( &audio_challenge[0], localplayer.rb.co,
- 30.0f, 1.0f );
+ audio_oneshot_3d( &audio_challenge[0], localplayer.rb.co, 30.0f, 1.0f );
audio_unlock();
}
}
- else {
+ else
+ {
vg_success( "challenge win\n" );
audio_lock();
audio_oneshot( &audio_challenge[2], 1.0f, 0.0f );
audio_unlock();
- _world.challenge_target = NULL;
- //_world.focused_entity = 0;
- if( objective->id_win ){
+ if( objective->id_win )
+ {
ent_call call;
call.data = NULL;
call.function = objective->win_event;
}
ent_region_re_eval( world );
+
+ if( world_clear_event( k_world_event_challenge ) )
+ {
+ _world.active_challenge_id = 0;
+ _world.challenge_target = NULL;
+ _world.challenge_timer = 0.0f;
+ }
}
}
-static int ent_objective_check_filter( ent_objective *objective ){
- if( objective->filter ){
+static int ent_objective_check_filter( ent_objective *objective )
+{
+ if( objective->filter )
+ {
struct player_skate_state *s = &player_skate.state;
enum trick_type trick = s->trick_type;
return ((objective->filter & state) || !objective->filter) &&
((objective->filter2 & state) || !objective->filter2);
}
- else {
+ else
+ {
return 1;
}
}
if( _world.challenge_target )
{
- if( (_world.challenge_target == objective) &&
- ent_objective_check_filter( objective )){
+ if( (_world.challenge_target == objective) && ent_objective_check_filter( objective ))
+ {
ent_objective_pass( world, objective );
}
else
{
audio_lock();
- audio_oneshot_3d( &audio_challenge[6], localplayer.rb.co,
- 30.0f, 1.0f );
+ audio_oneshot_3d( &audio_challenge[6], localplayer.rb.co, 30.0f, 1.0f );
audio_unlock();
- vg_error( "challenge failed\n" );
- _world.challenge_target = NULL;
- //_world.focused_entity = 0;
+ vg_error( "challenge failed, filter was not met\n" );
+
+ if( world_clear_event( k_world_event_challenge ) )
+ {
+ _world.active_challenge_id = 0;
+ _world.challenge_target = NULL;
+ _world.challenge_timer = 0.0f;
+ }
}
}
{
objective->flags &= ~k_ent_objective_hidden;
- if( mdl_entity_id_type( objective->id_next ) == k_ent_objective ){
+ if( mdl_entity_id_type( objective->id_next ) == k_ent_objective )
+ {
call->id = objective->id_next;
entity_call( world, call );
}
{
objective->flags |= k_ent_objective_hidden;
- if( mdl_entity_id_type( objective->id_next ) == k_ent_objective ){
+ if( mdl_entity_id_type( objective->id_next ) == k_ent_objective )
+ {
call->id = objective->id_next;
entity_call( world, call );
}
_world.challenge_target = NULL;
_world.challenge_timer = 0.0f;
_world.active_trigger_volume_count = 0;
-#if 0
- world_entity_exit_modal();
- world_entity_clear_focus();
-#endif
+ _world.event = k_world_event_none;
localplayer.boundary_hash ^= NETMSG_BOUNDARY_BIT;
world_routes_clear( &_world.main );
event;
/* World event: Challenges */
- ent_challenge *active_challenge;
- bool challenge_running;
+ u32 active_challenge_id;
+
+ enum challenge_state
+ {
+ k_challenge_state_none = 0,
+ k_challenge_state_viewing,
+ k_challenge_state_running
+ }
+ challenge_state;
ent_objective *challenge_target;
f32 challenge_timer; /* unused */
glEnable(GL_CULL_FACE);
}
-static void world_render_challenges( world_instance *world,
- struct world_pass *pass, v3f pos )
+static void world_render_challenges( world_instance *world, struct world_pass *pass, v3f pos )
{
-#if 0
if( !world ) return;
if( skaterift.activity == k_skaterift_replay ) return;
if( world != &_world.main ) return;
u32 objective_list[ 32 ],
challenge_list[ 16 ];
- v2f objective_uv_offsets[ 32 ];
-
u32 objective_count = 0,
challenge_count = 0;
- ent_challenge *active_challenge = NULL;
- int running = 0;
- if( mdl_entity_id_type( _world.focused_entity ) == k_ent_challenge )
- {
- if( (skaterift.activity == k_skaterift_default) &&
- _world.challenge_target )
- {
- running = 1;
- }
+ u32 challenge_index = mdl_entity_id_id( _world.active_challenge_id );
+ ent_challenge *challenge = af_arritm( &world->ent_challenge, challenge_index );
- if( !((skaterift.activity != k_skaterift_ent_focus) &&
- !_world.challenge_target) )
- {
- world_instance *challenge_world = &_world.main;
- u32 index = mdl_entity_id_id( _world.focused_entity );
- active_challenge = af_arritm(&challenge_world->ent_challenge, index);
- }
- }
-
- if( active_challenge )
+ if( (_world.event == k_world_event_challenge) && (_world.challenge_state == k_challenge_state_running) )
{
shader_scene_fxglow_uUvOffset( (v2f){ 8.0f/256.0f, 0.0f } );
- challenge_list[ challenge_count ++ ] =
- mdl_entity_id_id( _world.focused_entity );
+ challenge_list[ challenge_count ++ ] = challenge_index;
- u32 next = active_challenge->first;
+ u32 next = challenge->first;
while( mdl_entity_id_type(next) == k_ent_objective )
{
u32 index = mdl_entity_id_id( next );
{
u32 index = objective_list[ i ];
ent_objective *objective = af_arritm( &world->ent_objective, index );
- if( (objective->flags & k_ent_objective_hidden) && !active_challenge )
- continue;
f32 scale = 1.0f;
- if( running )
+ if( (_world.event == k_world_event_challenge) &&
+ (_world.challenge_state == k_challenge_state_running || _world.challenge_state == k_challenge_state_viewing) )
{
u32 passed = objective->flags & k_ent_objective_passed;
f32 target = passed? 0.0f: 1.0f;
else
shader_scene_fxglow_uUvOffset( (v2f){ 8.0f/256.0f, 0.0f } );
}
- else
+ else
{
+ /* TODO: Rename this flag. its misleading */
+ if( objective->flags & k_ent_objective_hidden )
+ continue;
+
f32 dist = v3_dist( objective->transform.co, pos ) * (1.0f/radius);
scale = vg_smoothstepf( vg_clampf( 5.0f-dist*5.0f, 0.0f,1.0f ) );
}
font3d_bind( &gui.font, k_font_shader_world, 0, world, &g_render.cam );
u32 count = 0;
-
for( u32 i=0; i<af_arrcount(&world->ent_challenge); i++ )
{
ent_challenge *challenge = af_arritm( &world->ent_challenge, i );
- if( challenge->status ) count ++;
+ if( challenge->status )
+ count ++;
}
char buf[32];
shader_scene_font_uColourize( colour );
font3d_simple_draw( 1, buf, &g_render.cam, mmdl );
}
-#endif
}
static void bindpoint_fxglow( world_instance *world,
if( !viewing_from_gate )
{
f32 greyout = 0.0f;
-#if 0
- if( mdl_entity_id_type(_world.focused_entity) == k_ent_challenge )
- greyout = _world.focus_strength;
-#endif
+
+ if( _world.event == k_world_event_challenge )
+ {
+ if( _world.challenge_state == k_challenge_state_viewing )
+ {
+ greyout = 1.0f;
+ }
+ }
if( greyout > 0.0f )
{