input update 1
[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 int immobile;
65
66 /*
67 * Animation
68 * --------------------------------------------------
69 */
70
71 struct player_avatar *playeravatar;
72 struct player_model *playermodel;
73 struct player_ragdoll ragdoll;
74 struct player_board *board;
75
76 player_pose holdout_pose;
77 float holdout_time;
78
79 /*
80 * Rewind
81 * ----------------------------------------------------
82 */
83 int rewinding, rewind_sound_wait;
84
85 struct rewind_frame{
86 v3f pos;
87 v3f ang;
88 }
89 *rewind_buffer;
90 u32 rewind_length;
91 float rewind_accum;
92 ent_gate *rewind_gate;
93
94 float rewind_total_length, rewind_predicted_time,
95 dist_accum;
96 double rewind_start, rewind_time;
97
98 /*
99 * Subsystems
100 * -------------------------------------------------
101 */
102
103 enum player_subsystem{
104 k_player_subsystem_walk = 0,
105 k_player_subsystem_skate = 1,
106 k_player_subsystem_dead = 2,
107 k_player_subsystem_drive = 3
108 }
109 subsystem,
110 subsystem_gate;
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_restore[] )( player_instance *player ) =
207 {
208 player__walk_restore,
209 player__skate_restore,
210 NULL,
211 NULL
212 };
213
214 PLAYER_API void player__debugtext( int size, const char *fmt, ... );
215 PLAYER_API void player__create( player_instance *inst );
216 PLAYER_API void player__use_avatar( player_instance *player,
217 struct player_avatar *av );
218 PLAYER_API void player__use_mesh( player_instance *player, glmesh *mesh );
219 PLAYER_API void player__use_texture( player_instance *player, vg_tex2d *tex );
220 PLAYER_API void player__bind( player_instance *player );
221 PLAYER_API void player__pre_update( player_instance *player );
222 PLAYER_API void player__update( player_instance *player );
223 PLAYER_API void player__post_update( player_instance *player );
224
225 PLAYER_API void player__pass_gate( player_instance *player, ent_gate *gate );
226 PLAYER_API void player__im_gui( player_instance *player );
227 PLAYER_API void player__spawn( player_instance *player, ent_spawn *rp );
228 PLAYER_API void player__kill( player_instance *player );
229
230 /* implementation */
231
232 #include "player.c"
233 #include "player_common.c"
234 #include "player_walk.c"
235 #include "player_skate.c"
236 #include "player_dead.c"
237 #include "player_drive.c"
238 #include "player_render.c"
239 #include "player_ragdoll.c"
240
241 #endif /* PLAYER_H */