basic replayable replays
[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 static i32 k_replay_test = 0;
9
10 typedef struct replay_buffer replay_buffer;
11 typedef struct replay_frame replay_frame;
12 typedef struct replay_gamestate replay_gamestate;
13 typedef struct replay_sfx replay_sfx;
14
15 struct replay_buffer {
16 void *data;
17 u32 size; /* bytes */
18
19 enum replay_control {
20 k_replay_control_scrub,
21 k_replay_control_play,
22 }
23 control;
24
25 replay_frame *head, *tail, *cursor_frame,
26 *statehead;
27 f64 cursor;
28 };
29
30 struct replay_frame {
31 player_animation anim;
32 struct board_pose board_pose;
33
34 v3f cam_pos, cam_angles;
35 f32 cam_fov;
36
37 f64 time;
38 replay_frame *l, *r;
39
40 u16 gamestate_count, sfx_count;
41 };
42
43 struct replay_gamestate {
44 enum player_subsystem system;
45 rigidbody rb;
46 v3f angles;
47
48 struct player_cam_controller cam_control;
49
50 union {
51 struct player_skate_state skate;
52 struct player_walk_state walk;
53 };
54 };
55
56 struct replay_sfx {
57 u32 none;
58 };
59
60 VG_STATIC void replay_debug_info( player_instance *player );
61 VG_STATIC replay_frame *replay_newframe( replay_buffer *replay,
62 u16 gamestate_count, u16 sfx_count );
63 VG_STATIC void replay_imgui( player_instance *player );
64 VG_STATIC void replay_seek( replay_buffer *replay, f64 t );
65
66 replay_gamestate *replay_frame_gamestate( replay_frame *frame, u16 index );
67 replay_sfx *replay_frame_sfx( replay_frame *frame, u16 index );
68 VG_STATIC replay_frame *replay_find_recent_stateframe( replay_buffer *replay );
69
70 #endif /* PLAYER_REPLAY_H */