MCPcopy Create free account
hub / github.com/Panzerschrek/Chasm-Reverse / Tick

Method Tick

PanzerChasm/server/player.cpp:53–277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51{}
52
53void Player::Tick(
54 Map& map,
55 const EntityId monster_id,
56 const Time current_time,
57 const Time last_tick_delta )
58{
59 teleported_= false;
60
61 // Process invisibility
62 if( has_invisibility_ )
63 {
64 const float invisiblity_time_s= ( current_time - invisibility_take_time_ ).ToSeconds();
65 if( invisiblity_time_s > GameConstants::invisibility_time_s )
66 {
67 has_invisibility_= false;
68 inviible_in_this_moment_= false;
69 }
70 else if( invisiblity_time_s >= GameConstants::invisibility_flashing_start_time_s )
71 {
72 inviible_in_this_moment_=
73 ( static_cast<int>( 2.0f * ( invisiblity_time_s - GameConstants::invisibility_flashing_start_time_s ) ) & 1 ) != 0;
74 }
75 else
76 inviible_in_this_moment_= true;
77 }
78 else
79 inviible_in_this_moment_= false;
80
81 // Process animations.
82 if( state_ == State::Alive )
83 {
84 if( mevement_acceleration_ > 0.0f )
85 {
86 float angle_diff= movement_direction_ - angle_;
87 if( angle_diff > +Constants::pi )
88 angle_diff-= Constants::two_pi;
89 if( angle_diff < -Constants::pi )
90 angle_diff+= Constants::two_pi;
91
92 if( std::abs(angle_diff) <= Constants::half_pi )
93 current_animation_= GetAnimation( AnimationId::Run );
94 else
95 current_animation_= GetAnimation( AnimationId::MeleeAttackLeftHand ); // TODO - select backwalk animation
96 }
97 else
98 current_animation_= GetAnimation( AnimationId::Idle0 );
99
100 const float frame= ( current_time - spawn_time_ ).ToSeconds() * GameConstants::animations_frames_per_second;
101 current_animation_frame_=
102 static_cast<unsigned int>( std::round( frame ) ) %
103 game_resources_->monsters_models[0].animations[ current_animation_ ].frame_count;
104 }
105 if( state_ == State::DeathAnimation )
106 {
107 current_animation_= GetAnimation( AnimationId::Respawn ); // For player "respawn" animation is death animation.
108
109 const float animation_time_delta_s= ( current_time - last_state_change_time_ ).ToSeconds();
110 const unsigned int frame=

Callers

nothing calls this directly

Calls 5

ToSecondsMethod · 0.80
PlantMineMethod · 0.80
RandPointInSphereMethod · 0.80
ShootMethod · 0.80

Tested by

no test coverage detected