basic replayable replays
[carveJwlIkooP6JGAAIwe30JlM.git] / player.h
1 #ifndef PLAYER_H
2 #define PLAYER_H
3
4 #include "skaterift.h"
5
6 enum player_subsystem{
7 k_player_subsystem_walk = 0,
8 k_player_subsystem_skate = 1,
9 k_player_subsystem_dead = 2,
10 k_player_subsystem_drive = 3
11 };
12
13 struct player_cam_controller {
14 enum camera_mode{
15 k_cam_firstperson = 1,
16 k_cam_thirdperson = 0
17 }
18 camera_mode;
19 f32 camera_type_blend;
20
21 v3f fpv_offset, /* expressed relative to rigidbody */
22 tpv_offset,
23 tpv_offset_extra,
24 fpv_viewpoint, /* expressed relative to neck bone inverse final*/
25 fpv_offset_smooth,
26 fpv_viewpoint_smooth,
27 tpv_offset_smooth,
28 tpv_lpf,
29 cam_velocity_smooth;
30 };
31
32 #include "player_ragdoll.h"
33 #include "player_render.h"
34 #include "player_model.h"
35 #include "player_common.h"
36 #include "player_walk.h"
37 #include "player_skate.h"
38 #include "player_dead.h"
39 #include "player_drive.h"
40 #include "player_replay.h"
41
42 #define PLAYER_REWIND_FRAMES 60*4
43 #define RESET_MAX_TIME 45.0
44
45 static i32 k_cinema_fixed = 0;
46 static f32 k_cinema = 0.0f;
47 static i32 k_invert_y = 0;
48
49 struct player_instance{
50 /* transform definition */
51 rigidbody rb;
52 v3f angles;
53
54 v4f qbasis;
55 m3x3f basis, invbasis, basis_gate;
56 world_instance *viewable_world;
57
58 /*
59 * Camera management
60 * ---------------------------
61 */
62 camera cam;
63 struct player_cam_controller cam_control;
64
65 v3f cam_override_pos;
66 v3f cam_override_angles;
67 float cam_override_fov;
68 float cam_override_strength;
69 f32 cam_trackshake;
70
71 float cam_velocity_influence,
72 cam_velocity_coefficient,
73 cam_velocity_constant,
74 cam_velocity_coefficient_smooth,
75 cam_velocity_constant_smooth,
76 cam_velocity_influence_smooth;
77
78 v3f cam_land_punch, cam_land_punch_v;
79 ent_gate *gate_waiting;
80
81 int immobile;
82
83 /*
84 * Animation
85 * --------------------------------------------------
86 */
87
88 struct player_avatar *playeravatar;
89 struct player_ragdoll ragdoll;
90 struct player_model fallback_model;
91
92 u16 board_view_slot, playermodel_view_slot;
93
94 player_pose holdout_pose;
95 float holdout_time;
96
97 struct board_pose board_pose;
98
99 /*
100 * Replay
101 * -------------------------------------------------
102 */
103 replay_buffer replay;
104
105 /*
106 * Subsystems
107 * -------------------------------------------------
108 */
109
110 enum player_subsystem subsystem; /* .. prev */
111
112 struct player_skate _skate;
113 struct player_walk _walk;
114 struct player_dead _dead;
115 struct player_drive _drive;
116 }
117 static localplayer;
118
119 /*
120 * Gameloop tables
121 * ---------------------------------------------------------
122 */
123
124 VG_STATIC
125 void (*_player_system_register[])(void) =
126 {
127 player__walk_register,
128 player__skate_register,
129 NULL,
130 NULL
131 };
132
133 VG_STATIC
134 void (*_player_bind[])( player_instance *player ) =
135 {
136 player__walk_bind,
137 player__skate_bind,
138 NULL,
139 player__drive_bind
140 };
141
142 VG_STATIC
143 void (*_player_reset[])( player_instance *player, ent_spawn *rp ) =
144 {
145 player__walk_reset,
146 player__skate_reset,
147 NULL,
148 player__drive_reset
149 };
150
151 VG_STATIC
152 void (*_player_pre_update[])( player_instance *player ) =
153 {
154 player__walk_pre_update,
155 player__skate_pre_update,
156 NULL,
157 player__drive_pre_update
158 };
159
160 VG_STATIC
161 void( *_player_update[])( player_instance *player ) =
162 {
163 player__walk_update,
164 player__skate_update,
165 player__dead_update,
166 player__drive_update
167 };
168
169 VG_STATIC
170 void( *_player_post_update[])( player_instance *player ) =
171 {
172 player__walk_post_update,
173 player__skate_post_update,
174 NULL,
175 player__drive_post_update
176 };
177
178 VG_STATIC
179 void( *_player_im_gui[])( player_instance *player ) =
180 {
181 player__walk_im_gui,
182 player__skate_im_gui,
183 NULL,
184 player__drive_im_gui
185 };
186
187 VG_STATIC
188 void( *_player_animate[])( player_instance *player, player_animation *dest ) =
189 {
190 player__walk_animate,
191 player__skate_animate,
192 player__dead_animate,
193 player__drive_animate
194 };
195
196 VG_STATIC
197 void( *_player_post_animate[])( player_instance *player ) =
198 {
199 player__walk_post_animate,
200 player__skate_post_animate,
201 player__dead_post_animate,
202 player__drive_post_animate
203 };
204
205 VG_STATIC
206 void( *_player_store_state[] )( player_instance *player ) =
207 {
208 NULL,
209 NULL,
210 NULL,
211 NULL
212 };
213
214 VG_STATIC
215 void( *_player_load_state_lerp[] )( player_instance *player,
216 void *A, void *B, f32 t ) =
217 {
218 NULL,
219 NULL,
220 NULL,
221 NULL
222 };
223
224 PLAYER_API void player__debugtext( int size, const char *fmt, ... );
225 PLAYER_API void player__create( player_instance *inst );
226 PLAYER_API void player__use_avatar( player_instance *player,
227 struct player_avatar *av );
228 PLAYER_API void player__use_mesh( player_instance *player, glmesh *mesh );
229 PLAYER_API void player__use_texture( player_instance *player, vg_tex2d *tex );
230 PLAYER_API void player__use_model( player_instance *player, u16 reg_id );
231
232 PLAYER_API void player__bind( player_instance *player );
233 PLAYER_API void player__pre_update( player_instance *player );
234 PLAYER_API void player__update( player_instance *player );
235 PLAYER_API void player__post_update( player_instance *player );
236
237 PLAYER_API void player__pass_gate( player_instance *player, ent_gate *gate );
238 PLAYER_API void player__im_gui( player_instance *player );
239 PLAYER_API void player__setpos( player_instance *player, v3f pos );
240 PLAYER_API void player__spawn( player_instance *player, ent_spawn *rp );
241 PLAYER_API void player__kill( player_instance *player );
242
243 VG_STATIC int localplayer_cmd_respawn( int argc, const char *argv[] );
244 VG_STATIC void player_apply_transport_to_cam( m4x3f transport );
245
246 #endif /* PLAYER_H */