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