5 #include "player_common.h"
6 #include "network_compression.h"
7 #include "player_effects.h"
10 k_player_subsystem_walk
= 0,
11 k_player_subsystem_skate
= 1,
12 k_player_subsystem_dead
= 2,
13 k_player_subsystem_drive
= 3,
14 k_player_subsystem_basic_info
= 4,
15 k_player_subsystem_glide
= 5,
16 k_player_subsystem_max
,
17 k_player_subsystem_invalid
= 255
20 struct player_cam_controller
{
22 k_cam_firstperson
= 1,
26 f32 camera_type_blend
;
28 v3f fpv_offset
, /* expressed relative to rigidbody */
31 fpv_viewpoint
, /* expressed relative to neck bone inverse final*/
39 struct player_subsystem_interface
{
40 void(*system_register
)(void);
42 void(*pre_update
)(void);
44 void(*post_update
)(void);
47 void(*pose
)( void *animator
, player_pose
*pose
);
48 void(*effects
)( void *animator
, m4x3f
*final_mtx
, struct player_board
*board
,
49 struct player_effects_data
*effect_data
);
50 void(*post_animate
)(void);
51 void(*network_animator_exchange
)( bitpack_ctx
*ctx
, void *data
);
52 void(*sfx_oneshot
)( u8 id
, v3f pos
, f32 volume
);
54 void(*sfx_comp
)(void *animator
);
55 void(*sfx_kill
)(void);
63 #include "player_ragdoll.h"
64 #include "player_render.h"
65 #include "player_model.h"
67 /* subsystem headers */
68 #include "player_walk.h"
69 #include "player_skate.h"
70 #include "player_dead.h"
71 #include "player_drive.h"
72 #include "player_glide.h"
73 #include "player_basic_info.h"
75 #include "player_replay.h"
77 #define PLAYER_REWIND_FRAMES 60*4
78 #define RESET_MAX_TIME 45.0
80 static i32 k_cinema_fixed
= 0;
81 static f32 k_cinema
= 0.0f
;
82 static i32 k_invert_y
= 0;
85 /* transform definition */
91 * ---------------------------
94 struct player_cam_controller cam_control
;
97 float cam_velocity_influence
,
98 cam_velocity_coefficient
,
99 cam_velocity_constant
,
100 cam_velocity_coefficient_smooth
,
101 cam_velocity_constant_smooth
,
102 cam_velocity_influence_smooth
;
104 v3f cam_land_punch
, cam_land_punch_v
;
105 ent_gate
*gate_waiting
;
106 int deferred_frame_record
;
110 int rewinded_since_last_gate
;
114 * --------------------------------------------------
118 u8 system
, priority
, id
;
119 f32 subframe
, volume
;
122 sfx_buffer
[4], /* large timeframe 1/10s; for networking */
123 local_sfx_buffer
[2]; /* per framerate 1/30s; for replay */
124 u32 sfx_buffer_count
,
125 local_sfx_buffer_count
;
129 * --------------------------------------------------
132 struct player_ragdoll ragdoll
;
133 struct player_model fallback_model
;
134 struct player_board fallback_board
;
136 u16 board_view_slot
, playermodel_view_slot
;
139 player_pose holdout_pose
;
146 * -------------------------------------------------
149 enum player_subsystem subsystem
,
155 mdl_context skeleton_meta
;
156 struct skeleton skeleton
;
177 u8 skeleton_mirror
[32];
179 struct player_effects_data effect_data
;
181 static localplayer
= {
187 .to_world
= M4X3_IDENTITY
,
188 .to_local
= M4X3_IDENTITY
192 struct player_subsystem_interface
static *player_subsystems
[] = {
193 [k_player_subsystem_walk
] = &player_subsystem_walk
,
194 [k_player_subsystem_dead
] = &player_subsystem_dead
,
195 [k_player_subsystem_drive
] = &player_subsystem_drive
,
196 [k_player_subsystem_skate
] = &player_subsystem_skate
,
197 [k_player_subsystem_basic_info
]=&player_subsystem_basic_info
,
198 [k_player_subsystem_glide
] = &player_subsystem_glide
,
203 * ---------------------------------------------------------
206 static void player__debugtext( int size
, const char *fmt
, ... );
207 static void player__use_mesh( glmesh
*mesh
);
208 static void player__use_texture( vg_tex2d
*tex
);
209 static void player__use_model( u16 reg_id
);
211 static void player__bind(void);
212 static void player__pre_update(void);
213 static void player__update(void);
214 static void player__post_update(void);
216 static void player__pass_gate( u32 id
);
217 static void player__im_gui(void);
218 static void player__setpos( v3f pos
);
219 static void player__spawn( ent_spawn
*rp
);
220 static void player__clean_refs(void);
221 static void player__reset(void);
222 static void player__kill(void);
223 static void player__begin_holdout( v3f offset
);
225 static int localplayer_cmd_respawn( int argc
, const char *argv
[] );
226 static void player_apply_transport_to_cam( m4x3f transport
);
228 static void player__clear_sfx_buffer(void);
229 static void player__networked_sfx( u8 system
, u8 priority
, u8 id
,
230 v3f pos
, f32 volume
);
231 static void net_sfx_exchange( bitpack_ctx
*ctx
, struct net_sfx
*sfx
);
232 static void net_sfx_play( struct net_sfx
*sfx
);
234 #endif /* PLAYER_H */