Merge branch 'master' of harrygodden.com:/home/carveJwlIkooP6JGAAIwe30JlM
[carveJwlIkooP6JGAAIwe30JlM.git] / player_walk.c
index e269166630dfd85c0eb909fbdc8b34e3c7902867..34ad072a8a5b5d9d27f1cf38dc174f1386cddd28 100644 (file)
@@ -432,7 +432,9 @@ static void player__walk_update(void){
 
    if( world->water.enabled ){
       if( localplayer.rb.co[1]+0.4f < world->water.height ){
-         audio_oneshot_3d( &audio_splash, localplayer.rb.co, 40.0f, 1.0f );
+         player__networked_sfx( k_player_subsystem_walk, 32, 
+                                k_player_walk_soundeffect_splash,
+                                localplayer.rb.co, 1.0f );
          player__dead_transition();
          return;
       }
@@ -709,20 +711,21 @@ static void player__walk_post_update(void){
       audio_lock();
       if( w->surface == k_surface_prop_concrete ){
          audio_oneshot_3d( 
-               &audio_footsteps[vg_randu32()%vg_list_size(audio_footsteps)], 
+               &audio_footsteps[vg_randu32(&vg.rand) % 
+                                 vg_list_size(audio_footsteps)], 
                localplayer.rb.co, 40.0f, 1.0f 
          );
       }
       else if( w->surface == k_surface_prop_grass ){
          audio_oneshot_3d( 
-           &audio_footsteps_grass[ vg_randu32()%
+           &audio_footsteps_grass[ vg_randu32(&vg.rand) %
                                     vg_list_size(audio_footsteps_grass)],
             localplayer.rb.co, 40.0f, 1.0f 
          );
       }
       else if( w->surface == k_surface_prop_wood ){
          audio_oneshot_3d( 
-           &audio_footsteps_wood[ vg_randu32()%
+           &audio_footsteps_wood[ vg_randu32(&vg.rand) %
                                     vg_list_size(audio_footsteps_wood)],
             localplayer.rb.co, 40.0f, 1.0f 
          );
@@ -1035,6 +1038,13 @@ static void player__walk_reset(void){
    w->state.activity = k_walk_activity_air;
    w->state.outro_type = k_walk_outro_none;
    w->state.outro_start_time = 0.0;
+
+   v3f fwd = { 0.0f, 0.0f, 1.0f };
+   q_mulv( localplayer.rb.q, fwd, fwd );
+   q_axis_angle( localplayer.rb.q, (v3f){0.0f,1.0f,0.0f}, 
+                 atan2f(fwd[0], fwd[2]) );
+
+   rb_update_transform( &localplayer.rb );
 }
 
 static void player__walk_animator_exchange( bitpack_ctx *ctx, void *data ){
@@ -1064,4 +1074,14 @@ static void player__walk_animator_exchange( bitpack_ctx *ctx, void *data ){
                      &animator->pitch );
    }
 }
+
+static void player__walk_sfx_oneshot( u8 id, v3f pos, f32 volume ){
+   audio_lock();
+
+   if( id == k_player_walk_soundeffect_splash ){
+      audio_oneshot_3d( &audio_splash, pos, 40.0f, 1.0f );
+   }
+
+   audio_unlock();
+}
 #endif /* PLAYER_DEVICE_WALK_H */