TurboFisto
[carveJwlIkooP6JGAAIwe30JlM.git] / player.h
index 8ecce407508b9c4b0adddbce198cb33055c902a5..cd7fd57a5996b28554968ed1c2b626fa043783c1 100644 (file)
--- a/player.h
+++ b/player.h
@@ -8,20 +8,23 @@
 #include "player_skate.h"
 #include "player_dead.h"
 
+#define PLAYER_REWIND_FRAMES 60*4
+
 struct player_instance
 {
    /* transform definition */
-   rigidbody rb;
-   v3f angles;
+   rigidbody rb, rb_gate_storage;
+   v3f angles, angles_storage;
 
    v4f   qbasis;
    m3x3f basis, invbasis, basis_gate;
+   world_instance *viewable_world;
 
    /*
     * Camera management
     * ---------------------------
     */
-   camera cam; /* output final camera */
+   camera cam;
 
    enum camera_mode
    {
@@ -31,7 +34,6 @@ struct player_instance
    camera_mode;
    float camera_type_blend;
 
-
    v3f fpv_offset,         /* expressed relative to rigidbody */
        tpv_offset,
        fpv_viewpoint,      /* expressed relative to neck bone inverse final */
@@ -41,6 +43,10 @@ struct player_instance
        tpv_lpf,
        cam_velocity_smooth;
 
+   v3f cam_override_pos;
+   v2f cam_override_angles;
+   float cam_override_strength;
+
    float cam_velocity_influence,
          cam_velocity_coefficient,
          cam_velocity_constant,
@@ -50,7 +56,7 @@ struct player_instance
          cam_land_punch,
          cam_land_punch_v;
 
-   teleport_gate *gate_waiting;
+   ent_gate *gate_waiting;
 
    /*
     * Input 
@@ -86,6 +92,25 @@ struct player_instance
    player_pose            holdout_pose;
    float                  holdout_time;
 
+   /*
+    * Rewind
+    * ----------------------------------------------------
+    */
+   int rewinding, rewind_sound_wait;
+
+   struct rewind_frame{
+      v3f pos;
+      v3f ang;
+   }
+   *rewind_buffer;
+   u32 rewind_length;
+   float rewind_accum;
+   ent_gate *rewind_gate;
+
+   float rewind_total_length, rewind_predicted_time,
+         dist_accum;
+   double rewind_start, rewind_time;
+
    /*
     * Subsystems
     * -------------------------------------------------
@@ -97,7 +122,8 @@ struct player_instance
       k_player_subsystem_skate = 1,
       k_player_subsystem_dead = 2
    }
-   subsystem;
+   subsystem,
+   subsystem_gate;
 
    struct player_skate  _skate;
    struct player_walk   _walk;
@@ -118,9 +144,9 @@ void (*_player_bind[])( player_instance *player ) =
 };
 
 VG_STATIC
-void (*_player_reset[])( player_instance *player, struct respawn_point *rp ) =
+void (*_player_reset[])( player_instance *player, ent_spawn *rp ) =
 {
-   NULL,
+   player__walk_reset,
    player__skate_reset,
    NULL
 };
@@ -173,6 +199,14 @@ void( *_player_post_animate[])( player_instance *player ) =
    player__dead_post_animate
 };
 
+VG_STATIC
+void( *_player_restore[] )( player_instance *player ) =
+{
+   player__walk_restore,
+   player__skate_restore,
+   NULL
+};
+
 /* implementation */
 
 #include "player.c"
@@ -413,7 +447,6 @@ VG_STATIC void player_init(void)                                         /* 1 */
    VG_VAR_I32( cl_thirdperson );
    VG_VAR_F32_PERSISTENT( fc_speed );
 
-   /* TODO: NOT PERSISTENT */
    VG_VAR_F32( k_ragdoll_limit_scale );
    VG_VAR_I32( k_ragdoll_div );
    VG_VAR_I32( k_ragdoll_debug_collider );