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