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