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