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);
52 void(*network_animator_exchange
)( bitpack_ctx
*ctx
, void *data
);
53 void(*sfx_oneshot
)( u8 id
, v3f pos
, f32 volume
);
55 void(*sfx_comp
)(void *animator
);
56 void(*sfx_kill
)(void);
64 #include "player_ragdoll.h"
65 #include "player_render.h"
66 #include "player_model.h"
68 /* subsystem headers */
69 #include "player_walk.h"
70 #include "player_skate.h"
71 #include "player_dead.h"
72 #include "player_drive.h"
73 #include "player_glide.h"
74 #include "player_basic_info.h"
76 #include "player_replay.h"
78 #define PLAYER_REWIND_FRAMES 60*4
79 #define RESET_MAX_TIME 45.0
81 static i32 k_cinema_fixed
= 0;
82 static f32 k_cinema
= 0.0f
;
83 static i32 k_invert_y
= 0;
84 static f32 k_cam_dist
= 1.8f
;
87 /* transform definition */
91 bool have_glider
, glider_orphan
;
95 * ---------------------------
98 struct player_cam_controller cam_control
;
101 float cam_velocity_influence
,
102 cam_velocity_coefficient
,
103 cam_velocity_constant
,
104 cam_velocity_coefficient_smooth
,
105 cam_velocity_constant_smooth
,
106 cam_velocity_influence_smooth
,
110 v3f cam_land_punch
, cam_land_punch_v
;
111 ent_gate
*gate_waiting
;
112 int deferred_frame_record
;
116 int rewinded_since_last_gate
;
120 * --------------------------------------------------
124 u8 system
, priority
, id
;
125 f32 subframe
, volume
;
128 sfx_buffer
[4], /* large timeframe 1/10s; for networking */
129 local_sfx_buffer
[2]; /* per framerate 1/30s; for replay */
130 u32 sfx_buffer_count
,
131 local_sfx_buffer_count
;
135 * --------------------------------------------------
138 struct player_ragdoll ragdoll
;
139 struct player_model fallback_model
;
140 struct player_board fallback_board
;
142 u16 board_view_slot
, playermodel_view_slot
;
145 player_pose holdout_pose
;
152 * -------------------------------------------------
155 enum player_subsystem subsystem
,
161 mdl_context skeleton_meta
;
162 struct skeleton skeleton
;
183 u8 skeleton_mirror
[32];
185 struct player_effects_data effect_data
;
187 static localplayer
= {
193 .to_world
= M4X3_IDENTITY
,
194 .to_local
= M4X3_IDENTITY
198 struct player_subsystem_interface
static *player_subsystems
[] = {
199 [k_player_subsystem_walk
] = &player_subsystem_walk
,
200 [k_player_subsystem_dead
] = &player_subsystem_dead
,
201 [k_player_subsystem_drive
] = &player_subsystem_drive
,
202 [k_player_subsystem_skate
] = &player_subsystem_skate
,
203 [k_player_subsystem_basic_info
]=&player_subsystem_basic_info
,
204 [k_player_subsystem_glide
] = &player_subsystem_glide
,
209 * ---------------------------------------------------------
212 static void player__debugtext( int size
, const char *fmt
, ... );
213 static void player__use_mesh( glmesh
*mesh
);
214 static void player__use_model( u16 reg_id
);
216 static void player__bind(void);
217 static void player__pre_update(void);
218 static void player__update(void);
219 static void player__post_update(void);
221 static void player__pass_gate( u32 id
);
222 static void player__im_gui(void);
223 static void player__setpos( v3f pos
);
224 static void player__spawn( ent_spawn
*rp
);
225 static void player__clean_refs(void);
226 static void player__reset(void);
227 static void player__kill(void);
228 static void player__begin_holdout( v3f offset
);
230 static int localplayer_cmd_respawn( int argc
, const char *argv
[] );
231 static void player_apply_transport_to_cam( m4x3f transport
);
233 static void player__clear_sfx_buffer(void);
234 static void player__networked_sfx( u8 system
, u8 priority
, u8 id
,
235 v3f pos
, f32 volume
);
236 static void net_sfx_exchange( bitpack_ctx
*ctx
, struct net_sfx
*sfx
);
237 static void net_sfx_play( struct net_sfx
*sfx
);
239 #endif /* PLAYER_H */