// File: /workspace/github_cpp_makefile_star2_O2/wrighteagle2d[P]wrighteaglebase/Debug/../src/BehaviorPenalty.cpp
// Function: BehaviorPenaltyExecuter::Execute(ActiveBehavior const&)
bool BehaviorPenaltyExecuter::Execute(const ActiveBehavior &beh) {
  const PlayerState &opp_goalie_state =
      mWorldState.GetOpponent(mWorldState.GetOpponentGoalieUnum());

  switch (beh.mDetailType) {
  case BDT_Setplay_Scan:
    mAgent.Turn(beh.mAngle);
    VisualSystem::instance().SetCanTurn(mAgent, false);
    break;
  case BDT_Setplay_Move:
    if (mSelfState.IsGoalie()) {
      Dasher::instance().GoToPoint(mAgent, beh.mTarget, 0.26);
      VisualSystem::instance().RaiseBall(mAgent, 1.0);
    } else {
      Dasher::instance().GoToPoint(mAgent, beh.mTarget, 0.26);
    }
    break;
  case BDT_Setplay_GetBall:
    if (mAgent.GetSelfUnum() == mStrategy.GetPenaltyTaker()) {
      if (mWorldState.GetPlayMode() == PM_Our_Penalty_Ready) {
        if (mWorldState.CurrentTime() - mWorldState.GetPlayModeTime() <
            ServerParam::instance().penReadyWait() - 6) // wait
        {
          Dasher::instance()
              .GetTurnBodyToAngleAction(mAgent, 0.0)
              .Execute(mAgent);
          VisualSystem::instance().RaisePlayer(mAgent,
                                               opp_goalie_state.GetUnum(), 1.0);
          VisualSystem::instance().SetCanTurn(mAgent, false);
        } else if (mSelfState.IsKickable() == true) {
          Kicker::instance().KickBall(mAgent, beh.mAngle, beh.mKickSpeed);
        } else // 一般不会刚开始就不可踢，以防万一
        {
          Dasher::instance().GoToPoint(mAgent, beh.mTarget, 0.26);
        }
      } else if (mWorldState.GetPlayMode() == PM_Our_Penalty_Taken) {
        Dasher::instance().GoToPoint(mAgent, beh.mTarget, 0.26);
      } else {
        std::cerr << "what penalty_taker will do ???" << std::endl;
      }
    } else {
      Dasher::instance().GetTurnBodyToAngleAction(mAgent, 0.0).Execute(mAgent);
      VisualSystem::instance().RaisePlayer(mAgent, opp_goalie_state.GetUnum(),
                                           1.0);
      VisualSystem::instance().SetCanTurn(mAgent, false);
    }
    break;
  default:
    break;
  }
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x30, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movl 0x98(%rsi), %eax
cmpl $0xf, %eax
je 0x15c1b
cmpl $0x11, %eax
je 0x15b48
cmpl $0x10, %eax
jne 0x15d03
movq 0x8(%rbx), %rdi
movsd 0x20(%r14), %xmm0
callq 0xccb0
jmp 0x15bfc
movq 0x10(%rbx), %rsi
movslq 0x2114(%rsi), %rax
imulq $0x178, %rax, %rax      # imm = 0x178
leaq (%rax,%rsi), %r12
addq $0xf58, %r12            # imm = 0xF58
movq 0x8(%rbx), %rax
movq 0x38(%rbx), %rcx
movl 0x8(%rax), %eax
cmpl 0x148(%rcx), %eax
jne 0x15bb4
movl 0x1c(%rsi), %eax
cmpl $0x10, %eax
je 0x15cd1
cmpl $0xf, %eax
jne 0x15c80
leaq 0x10(%rsi), %rdi
addq $0x24, %rsi
callq 0x4770c
movl %eax, %r15d
callq 0x3db2c
movl 0x3254(%rax), %eax
addl $-0x6, %eax
cmpl %eax, %r15d
jge 0x15c9d
callq 0x1a77c
movq 0x8(%rbx), %rdx
leaq -0x50(%rbp), %r14
xorps %xmm0, %xmm0
movq %r14, %rdi
movq %rax, %rsi
callq 0x1bf64
movq 0x8(%rbx), %rsi
movq %r14, %rdi
callq 0xa74c
callq 0x49230
movq 0x8(%rbx), %rsi
movl 0x11c(%r12), %edx
movsd 0x41454(%rip), %xmm0    # 0x57048
movq %rax, %rdi
callq 0x1270c
callq 0x49230
movq 0x8(%rax), %rcx
cmpq 0x8(%rbx), %rcx
jne 0x15d03
movb $0x0, 0x63c(%rax)
jmp 0x15d03
movq 0x20(%rbx), %rax
movb 0x175(%rax), %r15b
callq 0x1a77c
movq 0x8(%rbx), %rsi
movsd 0x28(%r14), %xmm0
movsd 0x30(%r14), %xmm1
movsd 0x42055(%rip), %xmm2    # 0x57c98
movsd 0x41abd(%rip), %xmm3    # 0x57708
pushq $0x1
popq %rdx
movq %rax, %rdi
xorl %ecx, %ecx
callq 0x1bd48
cmpb $0x1, %r15b
jne 0x15d03
callq 0x49230
movq 0x8(%rbx), %rsi
movsd 0x413d5(%rip), %xmm0    # 0x57048
movq %rax, %rdi
callq 0x163b0
jmp 0x15d03
movq 0x61369(%rip), %rdi     # 0x76ff0
leaq 0x42079(%rip), %rsi     # 0x57d07
callq 0x94b0
movq %rax, %rdi
callq 0x99e8
jmp 0x15d03
movq 0x20(%rbx), %rax
cmpb $0x1, 0x128(%rax)
jne 0x15cd1
callq 0x26f9c
movq 0x8(%rbx), %rsi
movsd 0x20(%r14), %xmm0
movsd 0x48(%r14), %xmm1
pushq $0x1
popq %rdx
movq %rax, %rdi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x29212
jmp 0x15d03
callq 0x1a77c
movq 0x8(%rbx), %rsi
movsd 0x28(%r14), %xmm0
movsd 0x30(%r14), %xmm1
movsd 0x41faa(%rip), %xmm2    # 0x57c98
movsd 0x41a12(%rip), %xmm3    # 0x57708
pushq $0x1
popq %rdx
movq %rax, %rdi
xorl %ecx, %ecx
callq 0x1bd48
movb $0x1, %al
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq