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