now fall in immobile mode
[carveJwlIkooP6JGAAIwe30JlM.git] / ent_skateshop.c
index 4c5817dd31e91ca1c9344adf8a450d515842f57b..56d8c01fe8557bcde628799fde5cb8c3d377f988 100644 (file)
@@ -163,20 +163,9 @@ 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){
-   float rate = vg_minf( 1.0f, vg.time_frame_delta * 2.0f );
-   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( !active ) return;
-
+VG_STATIC void ent_skateshop_preupdate( ent_skateshop *shop ){
    /* input filter */
    world_instance *world = world_current_instance();
-   ent_skateshop *shop = global_skateshop.ptr_ent;
 
    /* camera positioning */
    ent_camera *ref = mdl_arritm( &world->ent_camera, 
@@ -185,7 +174,7 @@ 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( global_skateshop.cam.angles, dir, 1.0f, 0.0f );
+   player_vector_angles( world_static.focus_cam.angles, dir, 1.0f, 0.0f );
 
    v3f lookat;
    if( shop->type == k_skateshop_type_boardshop ||
@@ -202,8 +191,8 @@ VG_STATIC void global_skateshop_preupdate(void){
    q_axis_angle( localplayer.rb.q, (v3f){0.0f,1.0f,0.0f}, 
                  atan2f(lookat[0],lookat[2]) );
 
-   v3_copy( ref->transform.co, global_skateshop.cam.pos );
-   global_skateshop.cam.fov = ref->fov;
+   v3_copy( ref->transform.co, world_static.focus_cam.pos );
+   world_static.focus_cam.fov = ref->fov;
 
    /* input */
    if( shop->type == k_skateshop_type_boardshop ){
@@ -251,7 +240,7 @@ VG_STATIC void global_skateshop_preupdate(void){
          addon_cache_watch( k_addon_type_board, cache_id );
          localplayer.board_view_slot = cache_id;
 
-         global_skateshop_exit();
+         world_entity_unfocus();
          skaterift_autosave(1);
          return;
       }
@@ -295,7 +284,7 @@ VG_STATIC void global_skateshop_preupdate(void){
       }
 
       if( button_down( k_srbind_maccept ) ){
-         global_skateshop_exit();
+         world_entity_unfocus();
       }
    }
    else if( shop->type == k_skateshop_type_worldshop ){
@@ -377,15 +366,13 @@ VG_STATIC void global_skateshop_preupdate(void){
    }
 
    if( button_down( k_srbind_mback ) ){
-      global_skateshop_exit();
+      world_entity_unfocus();
       return;
    }
 }
 
-VG_STATIC void skateshop_render_boardshop(void){
+VG_STATIC void skateshop_render_boardshop( ent_skateshop *shop ){
    world_instance *world = world_current_instance();
-   ent_skateshop *shop = global_skateshop.ptr_ent;
-
    u32 slot_count = vg_list_size(global_skateshop.shop_view_slots);
 
    ent_marker *mark_rack = mdl_arritm( &world->ent_marker, 
@@ -549,15 +536,12 @@ fade_out:;
    SDL_AtomicUnlock( &addon_system.sl_cache_using_resources );
 }
 
-VG_STATIC void skateshop_render_charshop(void)
-{
+VG_STATIC void skateshop_render_charshop( ent_skateshop *shop ){
 }
 
-VG_STATIC void skateshop_render_worldshop(void)
-{
+VG_STATIC void skateshop_render_worldshop( ent_skateshop *shop ){
    world_instance *world = world_current_instance();
 
-   ent_skateshop *shop = global_skateshop.ptr_ent;
    ent_marker *mark_display = mdl_arritm( &world->ent_marker,
                                   mdl_entity_id_id(shop->worlds.id_display)),
               *mark_info = mdl_arritm( &world->ent_marker, 
@@ -659,30 +643,21 @@ VG_STATIC void skateshop_render_worldshop(void)
 /*
  * World: render event
  */
-VG_STATIC void skateshop_render(void){
-   if( skaterift.activity != k_skaterift_skateshop ) return;
-      
-   ent_skateshop *shop = global_skateshop.ptr_ent;
-
-   if( shop->type == k_skateshop_type_boardshop ){
-      skateshop_render_boardshop();
-   }
-   else if( shop->type == k_skateshop_type_charshop ){
-      skateshop_render_charshop();
-   }
-   else if( shop->type == k_skateshop_type_worldshop ){
-      skateshop_render_worldshop();
-   }
-   else{
+VG_STATIC void skateshop_render( ent_skateshop *shop ){
+   if( shop->type == k_skateshop_type_boardshop )
+      skateshop_render_boardshop( shop );
+   else if( shop->type == k_skateshop_type_charshop )
+      skateshop_render_charshop( shop );
+   else if( shop->type == k_skateshop_type_worldshop )
+      skateshop_render_worldshop( shop );
+   else
       vg_fatal_error( "Unknown store (%u)\n", shop->type );
-   }
 }
 
 /*
  * Entity logic: entrance event
  */
-VG_STATIC void ent_skateshop_call( world_instance *world, ent_call *call )
-{
+VG_STATIC void ent_skateshop_call( world_instance *world, ent_call *call ){
    u32 index = mdl_entity_id_id( call->id );
    ent_skateshop *shop = mdl_arritm( &world->ent_skateshop, index );
    vg_info( "skateshop_call\n" );
@@ -695,6 +670,8 @@ VG_STATIC void ent_skateshop_call( world_instance *world, ent_call *call )
       
       vg_info( "Entering skateshop\n" );
 
+      world_entity_focus( call->id );
+#if 0
       localplayer.immobile = 1;
       menu.disable_open = 1;
       skaterift.activity = k_skaterift_skateshop;
@@ -703,6 +680,7 @@ VG_STATIC void ent_skateshop_call( world_instance *world, ent_call *call )
       v3_zero( localplayer.rb.w );
       localplayer._walk.move_speed = 0.0f;
       global_skateshop.ptr_ent = shop;
+#endif
       
       if( shop->type == k_skateshop_type_boardshop ){
          skateshop_update_viewpage();
@@ -718,15 +696,4 @@ VG_STATIC void ent_skateshop_call( world_instance *world, ent_call *call )
    }
 }
 
-/*
- * Entity logic: exit event
- */
-VG_STATIC void global_skateshop_exit(void){
-   vg_info( "exit skateshop\n" );
-   localplayer.immobile = 0;
-   skaterift.activity = k_skaterift_default;
-   menu.disable_open = 0;
-   srinput.enabled = 0;
-}
-
 #endif /* ENT_SKATESHOP_C */