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