move audio comp to its own thing
[carveJwlIkooP6JGAAIwe30JlM.git] / player_skate.h
index 6dbb897872cf906e7118c1517ddbf1a7dbb70bec..4118fd63f8552b8c8647c69225772db21d744a7b 100644 (file)
@@ -12,6 +12,7 @@ struct player_skate{
          k_skate_activity_air,
          k_skate_activity_air_to_grind,
          k_skate_activity_ground,
+         k_skate_activity_handplant,
          k_skate_activity_undefined,
          k_skate_activity_grind_any,
          k_skate_activity_grind_boardslide,
@@ -44,11 +45,13 @@ struct player_skate{
          k_trick_type_none,
          k_trick_type_kickflip,
          k_trick_type_shuvit,
-         k_trick_type_treflip
+         k_trick_type_treflip,
       }
       trick_type;
       float gravity_bias;
 
+      f32 trick_input_collect;
+
       v3f up_dir;
       v3f head_position;
 
@@ -76,17 +79,25 @@ struct player_skate{
       float land_dist;
       v3f land_normal;
       v4f smoothed_rotation;
+
+      f32 velocity_limit, grind_y_start, skid;
+      f32 handplant_t;
+
+      v3f store_cog_v, store_cog, store_co;
+      v4f store_smoothed, store_q;
    }
    state;
 
    struct player_skate_animator {
       v3f root_co;
       v4f root_q;
+      v3f root_v;
 
       v3f offset,
           local_cog;
 
       f32 slide,
+          skid,
           z,
           x,
           fly,
@@ -116,10 +127,12 @@ struct player_skate{
 
       f32 jump_charge;
 
-      /* linear anims */
-      f32 push_time, jump_time;
+      /* linear anims. TODO: we can union a bunch of variables here depending
+       * on activity. */
+      f32 push_time, jump_time, handplant_t;
       u8 jump_dir;
-      u8 trick_type;
+      u8 trick_type; /* todo: should encode grind type */
+      u8 activity, surface;
    }
    animator;
 
@@ -129,7 +142,8 @@ struct player_skate{
                         *anim_air, *anim_grind, *anim_grind_jump,
                         *anim_push,  *anim_push_reverse,
                         *anim_ollie, *anim_ollie_reverse,
-                        *anim_grabs, *anim_stop;
+                        *anim_grabs, *anim_stop,
+                        *anim_handplant;
 
    /* vectors representing the direction of the axels in localspace */
    v3f truckv0[2];
@@ -196,6 +210,15 @@ struct player_skate{
 }
 static player_skate;
 
+enum player_skate_soundeffect {
+   k_player_skate_soundeffect_jump,
+   k_player_skate_soundeffect_tap,
+   k_player_skate_soundeffect_land_good,
+   k_player_skate_soundeffect_land_bad,
+   k_player_skate_soundeffect_grind_metal,
+   k_player_skate_soundeffect_grind_wood,
+};
+
 static float 
    k_friction_lat          = 12.0f,
    k_friction_resistance   = 0.01f,
@@ -246,10 +269,10 @@ static float
    k_board_end_radius      = 0.1f,
    k_board_radius          = 0.14f,    /* 0.07 */
    
-   k_grind_balance         = -40.0f;
+   k_grind_balance         = -40.0f,
+   k_anim_transition       = 0.12f;
 
-static void player__skate_register(void)
-{
+static void player__skate_register(void){
    VG_VAR_F32( k_grind_dampener,       flags=VG_VAR_CHEAT );
    VG_VAR_F32( k_grind_spring,         flags=VG_VAR_CHEAT );
    VG_VAR_F32( k_grind_aligment,       flags=VG_VAR_CHEAT );
@@ -276,6 +299,7 @@ static void player__skate_register(void)
    VG_VAR_F32( k_mmcollect_vert,       flags=VG_VAR_CHEAT );
    VG_VAR_F32( k_mmdecay,              flags=VG_VAR_CHEAT );
    VG_VAR_F32( k_mmthrow_steer,        flags=VG_VAR_CHEAT );
+   VG_VAR_F32( k_anim_transition,      flags=VG_VAR_CHEAT );
 }
 
 static void player__skate_bind         (void);
@@ -285,27 +309,38 @@ static void player__skate_post_update  (void);
 static void player__skate_im_gui       (void);
 static void player__skate_animate      (void);
 static void player__skate_pose         (void *animator, player_pose *pose);
+static void player__skate_effects( void *_animator, m4x3f *final_mtx,
+                                   struct player_board *board,
+                                   struct player_effects_data *effect_data );
 static void player__skate_post_animate (void);
-static void player__skate_reset        (ent_spawn *rp);
+static void player__skate_animator_exchange( bitpack_ctx *ctx, void *data );
+static void player__skate_sfx_oneshot  ( u8 id, v3f pos, f32 volume );
 
 static void player__skate_clear_mechanics(void);
 static void player__skate_reset_animator(void);
 static void player__approximate_best_trajectory(void);
+static void player__skate_comp_audio( void *animator );
+static void player__skate_kill_audio(void);
 
 struct player_subsystem_interface static player_subsystem_skate = {
    .system_register = player__skate_register,
    .bind = player__skate_bind,
-   .reset = player__skate_reset,
    .pre_update = player__skate_pre_update,
    .update = player__skate_update,
    .post_update = player__skate_post_update,
    .im_gui = player__skate_im_gui,
    .animate = player__skate_animate,
    .pose = player__skate_pose,
+   .effects = player__skate_effects,
    .post_animate = player__skate_post_animate,
+   .network_animator_exchange = player__skate_animator_exchange,
+   .sfx_oneshot = player__skate_sfx_oneshot,
+   .sfx_comp = player__skate_comp_audio,
+   .sfx_kill = player__skate_kill_audio,
 
    .animator_data = &player_skate.animator,
-   .animator_size = sizeof(player_skate.animator)
+   .animator_size = sizeof(player_skate.animator),
+   .name = "Skate"
 };
 
 #endif /* PLAYER_SKATE_H */