bb870288f9ce1971ce181c42dd431d206bfcc974
[carveJwlIkooP6JGAAIwe30JlM.git] / player.h
1 #ifndef PLAYER_H
2 #define PLAYER_H
3
4 #include "skaterift.h"
5 #include "player_common.h"
6 #include "network_compression.h"
7
8 enum player_subsystem{
9 k_player_subsystem_walk = 0,
10 k_player_subsystem_skate = 1,
11 k_player_subsystem_dead = 2,
12 k_player_subsystem_drive = 3,
13 k_player_subsystem_max,
14 k_player_subsystem_invalid = 255
15 };
16
17 struct player_cam_controller {
18 enum camera_mode{
19 k_cam_firstperson = 1,
20 k_cam_thirdperson = 0
21 }
22 camera_mode;
23 f32 camera_type_blend;
24
25 v3f fpv_offset, /* expressed relative to rigidbody */
26 tpv_offset,
27 tpv_offset_extra,
28 fpv_viewpoint, /* expressed relative to neck bone inverse final*/
29 fpv_offset_smooth,
30 fpv_viewpoint_smooth,
31 tpv_offset_smooth,
32 tpv_lpf,
33 cam_velocity_smooth;
34 };
35
36 struct player_subsystem_interface{
37 void(*system_register)(void);
38 void(*bind)(void);
39 void(*reset)( ent_spawn *rp );
40 void(*pre_update)(void);
41 void(*update)(void);
42 void(*post_update)(void);
43 void(*im_gui)(void);
44 void(*animate)(void);
45 void(*pose)( void *animator, player_pose *pose );
46 void(*post_animate)(void);
47 void(*network_animator_exchange)( bitpack_ctx *ctx, void *data );
48
49 void *animator_data;
50 u32 animator_size;
51
52 const char *name;
53 };
54
55 #include "player_ragdoll.h"
56 #include "player_render.h"
57 #include "player_model.h"
58 #include "player_walk.h"
59 #include "player_skate.h"
60 #include "player_dead.h"
61 #include "player_drive.h"
62 #include "player_replay.h"
63
64 #define PLAYER_REWIND_FRAMES 60*4
65 #define RESET_MAX_TIME 45.0
66
67 static i32 k_cinema_fixed = 0;
68 static f32 k_cinema = 0.0f;
69 static i32 k_invert_y = 0;
70
71 struct {
72 /* transform definition */
73 rigidbody rb;
74 v3f angles;
75
76 v4f qbasis;
77 m3x3f basis, invbasis, basis_gate;
78 world_instance *viewable_world;
79
80 /*
81 * Camera management
82 * ---------------------------
83 */
84 camera cam;
85 struct player_cam_controller cam_control;
86 f32 cam_trackshake;
87
88 float cam_velocity_influence,
89 cam_velocity_coefficient,
90 cam_velocity_constant,
91 cam_velocity_coefficient_smooth,
92 cam_velocity_constant_smooth,
93 cam_velocity_influence_smooth;
94
95 v3f cam_land_punch, cam_land_punch_v;
96 ent_gate *gate_waiting;
97 u16 boundary_hash;
98
99 int immobile;
100
101 /*
102 * Animation
103 * --------------------------------------------------
104 */
105
106 struct player_avatar *playeravatar;
107 struct player_ragdoll ragdoll;
108 struct player_model fallback_model;
109
110 u16 board_view_slot, playermodel_view_slot;
111
112 player_pose pose;
113 player_pose holdout_pose;
114 float holdout_time;
115
116 m4x3f *final_mtx;
117
118 /*
119 * Subsystems
120 * -------------------------------------------------
121 */
122
123 enum player_subsystem subsystem; /* .. prev */
124 }
125 static localplayer = {
126 .rb = {
127 .co = { 0,0,0 },
128 .w = { 0,0,0 },
129 .v = { 0,0,0 },
130 .q = { 0,0,0,1 },
131 .to_world = M4X3_IDENTITY,
132 .to_local = M4X3_IDENTITY
133 }
134 };
135
136 struct player_subsystem_interface static *player_subsystems[] = {
137 [k_player_subsystem_walk] = &player_subsystem_walk,
138 [k_player_subsystem_dead] = &player_subsystem_dead,
139 [k_player_subsystem_drive] = &player_subsystem_drive,
140 [k_player_subsystem_skate] = &player_subsystem_skate
141 };
142
143 /*
144 * Gameloop tables
145 * ---------------------------------------------------------
146 */
147
148 static void player__debugtext( int size, const char *fmt, ... );
149 static void player__use_avatar( struct player_avatar *av );
150 static void player__use_mesh( glmesh *mesh );
151 static void player__use_texture( vg_tex2d *tex );
152 static void player__use_model( u16 reg_id );
153
154 static void player__bind(void);
155 static void player__pre_update(void);
156 static void player__update(void);
157 static void player__post_update(void);
158
159 static void player__pass_gate( u32 id );
160 static void player__im_gui(void);
161 static void player__setpos( v3f pos );
162 static void player__spawn( ent_spawn *rp );
163 static void player__kill(void);
164 static void player__begin_holdout(void);
165
166 static int localplayer_cmd_respawn( int argc, const char *argv[] );
167 static void player_apply_transport_to_cam( m4x3f transport );
168
169 #endif /* PLAYER_H */