refactor rewind tape 1
[carveJwlIkooP6JGAAIwe30JlM.git] / player_replay.h
1 #ifndef PLAYER_REPLAY_H
2 #define PLAYER_REPLAY_H
3
4 #include "skaterift.h"
5 #include "player.h"
6 #include "player_render.h"
7
8 typedef struct replay_buffer replay_buffer;
9 typedef struct replay_frame replay_frame;
10 typedef struct replay_gamestate replay_gamestate;
11 typedef struct replay_sfx replay_sfx;
12
13 struct replay_buffer {
14 void *data;
15 u32 size; /* bytes */
16
17 enum replay_control {
18 k_replay_control_none,
19 k_replay_control_scrub,
20 k_replay_control_play,
21 k_replay_control_resume
22 }
23 control;
24
25 replay_frame *head, *tail, *cursor_frame,
26 *statehead;
27 f64 cursor;
28 f32 track_velocity;
29 };
30
31 struct replay_frame {
32 player_animation anim;
33 struct board_pose board_pose;
34
35 v3f cam_pos, cam_angles;
36 f32 cam_fov;
37
38 f64 time;
39 replay_frame *l, *r;
40
41 u16 gamestate_count, sfx_count;
42 };
43
44 struct replay_gamestate {
45 enum player_subsystem system;
46 rigidbody rb;
47 v3f angles;
48
49 struct player_cam_controller cam_control;
50
51 union {
52 struct player_skate_state skate;
53 struct player_walk_state walk;
54 };
55 };
56
57 struct replay_sfx {
58 u32 none;
59 };
60
61 VG_STATIC void replay_debug_info( player_instance *player );
62 VG_STATIC replay_frame *replay_newframe( replay_buffer *replay,
63 u16 gamestate_count, u16 sfx_count );
64 VG_STATIC void replay_imgui( player_instance *player );
65 VG_STATIC void replay_seek( replay_buffer *replay, f64 t );
66
67 replay_gamestate *replay_frame_gamestate( replay_frame *frame, u16 index );
68 replay_sfx *replay_frame_sfx( replay_frame *frame, u16 index );
69 VG_STATIC replay_frame *replay_find_recent_stateframe( replay_buffer *replay );
70 VG_STATIC void player_replay_control_update( player_instance *player );
71
72 #endif /* PLAYER_REPLAY_H */