basic replayable replays
[carveJwlIkooP6JGAAIwe30JlM.git] / player_replay.h
index 1befaada2a0f5f8a86747c58be5be61178d080d2..2c18d4c68a17797ca5425f9ae8e42948baeb81fe 100644 (file)
@@ -9,13 +9,21 @@ static i32 k_replay_test = 0;
 
 typedef struct replay_buffer replay_buffer;
 typedef struct replay_frame replay_frame;
+typedef struct replay_gamestate replay_gamestate;
+typedef struct replay_sfx replay_sfx;
 
 struct replay_buffer {
    void *data;
    u32 size; /* bytes */
 
-   replay_frame *head, *tail, *cursor_frame;
+   enum replay_control {
+      k_replay_control_scrub,
+      k_replay_control_play,
+   }
+   control;
 
+   replay_frame *head, *tail, *cursor_frame,
+                *statehead;
    f64 cursor;
 };
 
@@ -23,15 +31,40 @@ struct replay_frame {
    player_animation anim;
    struct board_pose board_pose;
 
+   v3f cam_pos, cam_angles;
+   f32 cam_fov;
+
    f64 time;
    replay_frame *l, *r;
 
-   /* eventually, sound events, player iframes and stuff? */
+   u16 gamestate_count, sfx_count;
+};
+
+struct replay_gamestate {
+   enum player_subsystem system;
+   rigidbody rb;
+   v3f angles;
+
+   struct player_cam_controller cam_control;
+
+   union {
+      struct player_skate_state skate;
+      struct player_walk_state  walk;
+   };
+};
+
+struct replay_sfx {
+   u32 none;
 };
 
 VG_STATIC void replay_debug_info( player_instance *player );
-VG_STATIC replay_frame *replay_newframe( replay_buffer *replay );
+VG_STATIC replay_frame *replay_newframe( replay_buffer *replay, 
+                                         u16 gamestate_count, u16 sfx_count );
 VG_STATIC void replay_imgui( player_instance *player );
 VG_STATIC void replay_seek( replay_buffer *replay, f64 t );
 
+replay_gamestate *replay_frame_gamestate( replay_frame *frame, u16 index );
+replay_sfx *replay_frame_sfx( replay_frame *frame, u16 index );
+VG_STATIC replay_frame *replay_find_recent_stateframe( replay_buffer *replay );
+
 #endif /* PLAYER_REPLAY_H */