wrong port
[carveJwlIkooP6JGAAIwe30JlM.git] / player_walk.h
1 #ifndef PLAYER_WALK_H
2 #define PLAYER_WALK_H
3
4 #include "player.h"
5 #include "player_api.h"
6 #include "rigidbody.h"
7
8 #define PLAYER_JUMP_EPSILON 0.1 /* 100ms jump allowance */
9
10 struct player_walk{
11 rb_capsule collider;
12
13 struct player_walk_state{
14 v3f prev_pos;
15 v3f drop_in_target,
16 drop_in_foot_anchor,
17 drop_in_start,
18 drop_in_normal;
19
20 float drop_in_start_angle,
21 drop_in_angle;
22
23 enum walk_activity{
24 k_walk_activity_air,
25 k_walk_activity_ground,
26 k_walk_activity_sleep,
27 k_walk_activity_lockedmove,
28 k_walk_activity_sit,
29 k_walk_activity_sit_up
30 }
31 activity;
32
33 enum walk_outro{
34 k_walk_outro_none,
35 k_walk_outro_jump_to_air,
36 k_walk_outro_drop_in,
37 k_walk_outro_regular
38 }
39 outro_type;
40 double outro_start_time;
41
42 int jump_queued;
43 f64 jump_input_time;
44
45 f32 walk_timer;
46 f32 sit_t;
47 int step_phase;
48 }
49 state;
50
51 f32 move_speed;
52
53 enum mdl_surface_prop surface;
54 struct skeleton_anim *anim_walk, *anim_run, *anim_idle, *anim_jump,
55 *anim_jump_to_air, *anim_drop_in, *anim_intro,
56 *anim_sit;
57
58 struct player_walk_animator {
59 v3f root_co;
60 v4f root_q;
61 f32 fly,
62 run,
63 walk;
64
65 f32 walk_timer, yaw, pitch;
66
67 v3f foot_anchor;
68 enum walk_outro outro_type;
69 f32 outro_t,
70 commit_t,
71 sit_t;
72 }
73 animator;
74 }
75 static player_walk;
76
77 static f32
78 k_walkspeed = 10.0f,
79 k_airspeed = 1.2f,
80 k_stopspeed = 4.0f,
81 k_walk_accel = 10.0f,
82 k_walk_air_accel = 7.0f,
83 k_walk_friction = 10.0f,
84 k_walk_step_height = 0.2f,
85
86 k_sit_yaw_limit = VG_PIf/1.7f,
87 k_sit_pitch_limit = VG_PIf/4.0f;
88
89 static void player__walk_register(void){
90 VG_VAR_F32( k_walkspeed, flags=VG_VAR_CHEAT );
91 VG_VAR_F32( k_stopspeed, flags=VG_VAR_CHEAT );
92 VG_VAR_F32( k_airspeed, flags=VG_VAR_CHEAT );
93 VG_VAR_F32( k_walk_friction, flags=VG_VAR_CHEAT );
94 VG_VAR_F32( k_walk_air_accel, flags=VG_VAR_CHEAT );
95 VG_VAR_F32( k_walk_accel, flags=VG_VAR_CHEAT );
96 }
97
98 static void player__walk_pre_update (void);
99 static void player__walk_update (void);
100 static void player__walk_post_update (void);
101 static void player__walk_animate (void);
102 static void player__walk_pose (void *animator, player_pose *pose);
103 static void player__walk_post_animate(void);
104 static void player__walk_im_gui (void);
105 static void player__walk_bind (void);
106 static void player__walk_transition (void);
107 static void player__walk_reset (ent_spawn *rp );
108 static void player__walk_restore (void);
109 static void player__walk_animator_exchange( bitpack_ctx *ctx, void *data );
110
111 struct player_subsystem_interface static player_subsystem_walk = {
112 .system_register = player__walk_register,
113 .bind = player__walk_bind,
114 .reset = player__walk_reset,
115 .pre_update = player__walk_pre_update,
116 .update = player__walk_update,
117 .post_update = player__walk_post_update,
118 .im_gui = player__walk_im_gui,
119 .animate = player__walk_animate,
120 .post_animate = player__walk_post_animate,
121 .pose = player__walk_pose,
122 .network_animator_exchange = player__walk_animator_exchange,
123
124 .animator_data = &player_walk.animator,
125 .animator_size = sizeof(player_walk.animator),
126 .name = "Walk"
127 };
128
129 #endif /* PLAYER_WALK_H */