fix regression with gate flipping
[carveJwlIkooP6JGAAIwe30JlM.git] / player_walk.h
1 #pragma once
2 #include "player.h"
3 #include "player_api.h"
4 #include "vg/vg_rigidbody.h"
5
6 #define PLAYER_JUMP_EPSILON 0.1 /* 100ms jump allowance */
7
8 struct player_walk
9 {
10 rb_capsule collider;
11
12 struct player_walk_state{
13 v3f prev_pos;
14 v3f drop_in_target,
15 drop_in_start,
16 drop_in_normal;
17
18 float drop_in_start_angle,
19 drop_in_angle;
20
21 enum walk_activity{
22 k_walk_activity_air,
23 k_walk_activity_ground,
24 k_walk_activity_sit,
25 k_walk_activity_sit_up,
26
27 /* transitions */
28 k_walk_activity_inone,
29 k_walk_activity_ipopoff,
30 k_walk_activity_oair,
31 k_walk_activity_odrop_in,
32 k_walk_activity_oregular,
33
34 k_walk_activity_max,
35 }
36 activity;
37
38 f32 transition_t;
39
40 int jump_queued;
41 f64 jump_input_time;
42
43 f32 walk_timer;
44 int step_phase;
45 v3f steer;
46 }
47 state;
48
49 f32 move_speed;
50
51 enum mdl_surface_prop surface;
52 struct skeleton_anim *anim_walk, *anim_run, *anim_idle, *anim_jump,
53 *anim_jump_to_air, *anim_drop_in, *anim_intro,
54 *anim_sit, *anim_popoff;
55
56 struct player_walk_animator {
57 v3f root_co;
58 v4f root_q;
59 f32 fly,
60 run,
61 walk;
62
63 f32 walk_timer, yaw, pitch, board_yaw;
64
65 enum walk_activity activity;
66 f32 transition_t;
67 }
68 animator;
69 }
70 extern player_walk;
71 extern struct player_subsystem_interface player_subsystem_walk;
72
73 enum player_walk_soundeffect {
74 k_player_walk_soundeffect_splash
75 };
76
77 static f32
78 k_walkspeed = 4.4f,
79 k_runspeed = 10.0f,
80 k_airspeed = 1.2f,
81 k_stopspeed = 4.0f,
82 k_walk_accel = 10.0f,
83 k_walk_air_accel = 7.0f,
84 k_walk_friction = 6.0f,
85 k_walk_step_height = 0.2f,
86
87 k_sit_yaw_limit = VG_PIf/1.7f,
88 k_sit_pitch_limit = VG_PIf/4.0f;
89
90 static void player__walk_register(void){
91 VG_VAR_F32( k_walkspeed, flags=VG_VAR_CHEAT );
92 VG_VAR_F32( k_runspeed, flags=VG_VAR_CHEAT );
93 VG_VAR_F32( k_stopspeed, flags=VG_VAR_CHEAT );
94 VG_VAR_F32( k_airspeed, flags=VG_VAR_CHEAT );
95 VG_VAR_F32( k_walk_friction, flags=VG_VAR_CHEAT );
96 VG_VAR_F32( k_walk_air_accel, flags=VG_VAR_CHEAT );
97 VG_VAR_F32( k_walk_accel, flags=VG_VAR_CHEAT );
98 }
99
100 void player__walk_pre_update (void);
101 void player__walk_update (void);
102 void player__walk_post_update (void);
103 void player__walk_animate (void);
104 void player__walk_pose (void *animator, player_pose *pose);
105 void player__walk_post_animate(void);
106 void player__walk_im_gui (void);
107 void player__walk_bind (void);
108 void player__walk_reset (void);
109 void player__walk_restore (void);
110 void player__walk_animator_exchange( bitpack_ctx *ctx, void *data );
111 void player__walk_transition( bool grounded, f32 board_yaw );