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