MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / beginBodyStateChange

Method beginBodyStateChange

game/state/battle/battleunit.cpp:4880–4953  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4878}
4879
4880void BattleUnit::beginBodyStateChange(GameState &state, BodyState bodyState)
4881{
4882
4883 // This is ONLY called from BattleUnit::updateBody, which already ensures that:
4884 // - bodyState is legal for this unit
4885 // - there is no current body change going on
4886 // Therefore, we're not checking here for those conditions
4887
4888 // Already in target body state -> Exit
4889 if (target_body_state == bodyState)
4890 {
4891 return;
4892 }
4893
4894 // Cease hand animation immediately
4895 if (hand_animation_ticks_remaining != 0)
4896 setHandState(target_hand_state);
4897
4898 // Find which animation is possible
4899 int frameCount = agent->getAnimationPack()->getFrameCountBody(displayedItem, current_body_state,
4900 bodyState, current_hand_state,
4901 current_movement_state, facing);
4902 // No such animation -> Try without movement
4903 if (frameCount == 0 && current_movement_state != MovementState::None)
4904 {
4905 frameCount = agent->getAnimationPack()->getFrameCountBody(displayedItem, current_body_state,
4906 bodyState, current_hand_state,
4907 MovementState::None, facing);
4908 if (frameCount != 0)
4909 {
4910 setMovementState(MovementState::None);
4911 }
4912 }
4913 // No such animation -> Try without aiming
4914 if (frameCount == 0 && current_hand_state != HandState::AtEase)
4915 {
4916 frameCount = agent->getAnimationPack()->getFrameCountBody(displayedItem, current_body_state,
4917 bodyState, HandState::AtEase,
4918 current_movement_state, facing);
4919 if (frameCount != 0)
4920 {
4921 setHandState(HandState::AtEase);
4922 }
4923 }
4924 // No such animation -> Try without both
4925 if (frameCount == 0 && current_movement_state != MovementState::None &&
4926 current_hand_state != HandState::AtEase)
4927 {
4928 frameCount = agent->getAnimationPack()->getFrameCountBody(displayedItem, current_body_state,
4929 bodyState, HandState::AtEase,
4930 MovementState::None, facing);
4931 if (frameCount != 0)
4932 {
4933 setMovementState(MovementState::None);
4934 setHandState(HandState::AtEase);
4935 }
4936 }
4937 int ticks = frameCount * TICKS_PER_FRAME_UNIT;

Callers

nothing calls this directly

Calls 2

getFrameCountBodyMethod · 0.80
getAnimationPackMethod · 0.80

Tested by

no test coverage detected