X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=ent_skateshop.c;h=7dd11c0bcd46ea4e9446061b2343805e4991f81a;hb=844527ec68c063d78d4993bd8e4053f9ddc47b78;hp=4c55bb939477117aac5c1cb36ae900aa50830ed9;hpb=67928190c66b05bd48b6b515278e930974d25cd2;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/ent_skateshop.c b/ent_skateshop.c index 4c55bb9..7dd11c0 100644 --- a/ent_skateshop.c +++ b/ent_skateshop.c @@ -163,14 +163,18 @@ VG_STATIC void skateshop_load_world_preview( addon_reg *reg ){ * VG event preupdate */ void temp_update_playermodel(void); -VG_STATIC void global_skateshop_preupdate(void) -{ +VG_STATIC void global_skateshop_preupdate(void){ float rate = vg_minf( 1.0f, vg.time_frame_delta * 2.0f ); - global_skateshop.factive = vg_lerpf( global_skateshop.factive, - global_skateshop.active, rate ); + int active = 0; + if( skaterift.activity == k_skaterift_skateshop ) + active = 1; + + vg_slewf( &global_skateshop.factive, active, + vg.time_frame_delta * (1.0f/0.5f) ); - if( !global_skateshop.active ) return; + if( !active ) return; + /* input filter */ world_instance *world = world_current_instance(); ent_skateshop *shop = global_skateshop.ptr_ent; @@ -181,30 +185,25 @@ VG_STATIC void global_skateshop_preupdate(void) v3f dir = {0.0f,-1.0f,0.0f}; mdl_transform_vector( &ref->transform, dir, dir ); m3x3_mulv( localplayer.invbasis, dir, dir ); - player_vector_angles( localplayer.cam_override_angles, dir, 1.0f, 0.0f ); + player_vector_angles( global_skateshop.cam.angles, dir, 1.0f, 0.0f ); v3f lookat; if( shop->type == k_skateshop_type_boardshop || shop->type == k_skateshop_type_worldshop ){ ent_marker *display = mdl_arritm( &world->ent_marker, mdl_entity_id_id(shop->boards.id_display) ); - v3_sub( display->transform.co, localplayer.rb.co, lookat ); - } - else if( shop->type == k_skateshop_type_charshop ){ + else if( shop->type == k_skateshop_type_charshop ) v3_sub( ref->transform.co, localplayer.rb.co, lookat ); - } - else{ + else vg_fatal_error( "Unknown store (%u)\n", shop->type ); - } q_axis_angle( localplayer.rb.q, (v3f){0.0f,1.0f,0.0f}, atan2f(lookat[0],lookat[2]) ); - v3_copy( ref->transform.co, localplayer.cam_override_pos ); - localplayer.cam_override_fov = ref->fov; - localplayer.cam_override_strength = global_skateshop.factive; + v3_copy( ref->transform.co, global_skateshop.cam.pos ); + global_skateshop.cam.fov = ref->fov; /* input */ if( shop->type == k_skateshop_type_boardshop ){ @@ -347,9 +346,7 @@ VG_STATIC void global_skateshop_preupdate(void) if( loadable && button_down( k_srbind_maccept ) ){ vg_info( "Select rift (%u)\n", global_skateshop.selected_world_id ); - world_loader.reg = reg; - world_loader.override_name[0] = '\0'; - skaterift_change_world_start(); + skaterift_change_world_start( reg ); return; } else{ @@ -385,8 +382,7 @@ VG_STATIC void global_skateshop_preupdate(void) } } -VG_STATIC void skateshop_render_boardshop(void) -{ +VG_STATIC void skateshop_render_boardshop(void){ world_instance *world = world_current_instance(); ent_skateshop *shop = global_skateshop.ptr_ent; @@ -432,10 +428,10 @@ VG_STATIC void skateshop_render_boardshop(void) q_nlerp( xform.q, mark_display->transform.q, t, xform.q ); v3_lerp( xform.s, mark_display->transform.s, t, xform.s ); - struct board_pose pose = {0}; + struct player_board_pose pose = {0}; m4x3f mmdl; mdl_transform_m4x3( &xform, mmdl ); - render_board( &main_camera, world, board, mmdl, + render_board( &skaterift.cam, world, board, mmdl, &pose, k_board_shader_entity ); fade_out:; @@ -460,7 +456,7 @@ fade_out:; float scale = 0.2f, thickness = 0.03f; - font3d_bind( &gui.font, &main_camera ); + font3d_bind( &gui.font, &skaterift.cam ); shader_model_font_uColour( (v4f){1.0f,1.0f,1.0f,1.0f} ); /* Selection counter @@ -481,11 +477,11 @@ fade_out:; i+=highscore_intl( buf+i, addon_count(k_addon_type_board), 3 ); buf[i++] = '\0'; - font3d_simple_draw( &gui.font, 0, buf, &main_camera, mmdl ); + font3d_simple_draw( &gui.font, 0, buf, &skaterift.cam, mmdl ); } else{ font3d_simple_draw( &gui.font, 0, - "Nothing installed", &main_camera, mmdl ); + "Nothing installed", &skaterift.cam, mmdl ); } u16 cache_id = skateshop_selected_cache_id(); @@ -532,7 +528,7 @@ fade_out:; mlocal[3][2] = 0.0f; m4x3_mul( mtext, mlocal, mmdl ); font3d_simple_draw( &gui.font, 0, global_skateshop.render.item_title, - &main_camera, mmdl ); + &skaterift.cam, mmdl ); /* Author name * ----------------------------------------------------------------- */ @@ -545,7 +541,7 @@ fade_out:; mlocal[3][2] = 0.0f; m4x3_mul( mtext, mlocal, mmdl ); font3d_simple_draw( &gui.font, 0, global_skateshop.render.item_desc, - &main_camera, mmdl ); + &skaterift.cam, mmdl ); SDL_AtomicUnlock( &addon_system.sl_cache_using_resources ); } @@ -622,7 +618,7 @@ VG_STATIC void skateshop_render_worldshop(void) m4x3f mtext,mlocal,mtextmdl; mdl_transform_m4x3( &mark_info->transform, mtext ); - font3d_bind( &gui.font, &main_camera ); + font3d_bind( &gui.font, &skaterift.cam ); shader_model_font_uColour( (v4f){1.0f,1.0f,1.0f,1.0f} ); float scale = 0.2f, thickness = 0.015f, scale1 = 0.08f; @@ -633,14 +629,14 @@ VG_STATIC void skateshop_render_worldshop(void) mlocal[3][1] = 0.1f; mlocal[3][2] = 0.0f; m4x3_mul( mtext, mlocal, mtextmdl ); - font3d_simple_draw( &gui.font, 0, buftext, &main_camera, mtextmdl ); + font3d_simple_draw( &gui.font, 0, buftext, &skaterift.cam, mtextmdl ); m3x3_setdiagonalv3( mlocal, (v3f){ scale1, scale1, thickness } ); mlocal[3][0] = -font3d_string_width( &gui.font, 0, bufsubtext ); mlocal[3][0] *= scale1*0.5f; mlocal[3][1] = -scale1*0.3f; m4x3_mul( mtext, mlocal, mtextmdl ); - font3d_simple_draw( &gui.font, 0, bufsubtext, &main_camera, mtextmdl ); + font3d_simple_draw( &gui.font, 0, bufsubtext, &skaterift.cam, mtextmdl ); /* pointcloud */ m4x3f mmdl; @@ -650,7 +646,7 @@ VG_STATIC void skateshop_render_worldshop(void) glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE); glDisable(GL_DEPTH_TEST); - pointcloud_render( world, &main_camera, mmdl ); + pointcloud_render( world, &skaterift.cam, mmdl ); glDisable(GL_BLEND); glEnable(GL_DEPTH_TEST); } @@ -658,9 +654,8 @@ VG_STATIC void skateshop_render_worldshop(void) /* * World: render event */ -VG_STATIC void skateshop_render(void) -{ - if( !global_skateshop.active ) return; +VG_STATIC void skateshop_render(void){ + if( skaterift.activity != k_skaterift_skateshop ) return; ent_skateshop *shop = global_skateshop.ptr_ent; @@ -687,19 +682,17 @@ VG_STATIC void ent_skateshop_call( world_instance *world, ent_call *call ) ent_skateshop *shop = mdl_arritm( &world->ent_skateshop, index ); vg_info( "skateshop_call\n" ); - if( menu.active ) return; + if( skaterift.activity != k_skaterift_default ) return; if( !vg_loader_availible() ) return; if( call->function == k_ent_function_trigger ){ - if( localplayer.subsystem != k_player_subsystem_walk ){ - return; - } + if( localplayer.subsystem != k_player_subsystem_walk ) return; vg_info( "Entering skateshop\n" ); localplayer.immobile = 1; menu.disable_open = 1; - global_skateshop.active = 1; + skaterift.activity = k_skaterift_skateshop; v3_zero( localplayer.rb.v ); v3_zero( localplayer.rb.w ); @@ -723,13 +716,12 @@ VG_STATIC void ent_skateshop_call( world_instance *world, ent_call *call ) /* * Entity logic: exit event */ -VG_STATIC void global_skateshop_exit(void) -{ +VG_STATIC void global_skateshop_exit(void){ vg_info( "exit skateshop\n" ); localplayer.immobile = 0; - global_skateshop.active = 0; + skaterift.activity = k_skaterift_default; menu.disable_open = 0; - srinput.ignore_input_frames = 2; + srinput.enabled = 0; } #endif /* ENT_SKATESHOP_C */