// File: wrighteagle2d[P]wrighteaglebase/Debug/../src/ActionEffector.cpp
// Function: ActionEffector::SetTackleAction(double, bool)
bool ActionEffector::SetTackleAction(AngleDeg angle, const bool foul) {
  if (mIsTackle == true || mIsMutex == true) {
    return true;
  }

  if (angle < ServerParam::instance().minMoment() ||
      angle > ServerParam::instance().maxMoment()) {
    return false;
  }

  if (mSelfState.GetIdleCycle() > 0) {
    return false;
  }

  double tackle_prob = mSelfState.GetTackleProb(foul);
  if (tackle_prob < FLOAT_EPS &&
      mWorldState.GetPlayMode() !=
          PM_Opp_Penalty_Taken) // 守门员防点球时能tackle就tackle
  {
    return false;
  }

  if (mWorldState.GetPlayMode() == PM_Before_Kick_Off ||
      mWorldState.GetPlayMode() == PM_Goal_Ours ||
      mWorldState.GetPlayMode() == PM_Goal_Opps ||
      mWorldState.GetPlayMode() == PM_Opp_Offside_Kick ||
      mWorldState.GetPlayMode() == PM_Our_Offside_Kick ||
      mWorldState.GetPlayMode() == PM_Our_Foul_Charge_Kick ||
      mWorldState.GetPlayMode() == PM_Opp_Foul_Charge_Kick ||
      mWorldState.GetPlayMode() == PM_Our_Back_Pass_Kick ||
      mWorldState.GetPlayMode() == PM_Opp_Back_Pass_Kick ||
      mWorldState.GetPlayMode() == PM_Our_Free_Kick_Fault_Kick ||
      mWorldState.GetPlayMode() == PM_Opp_Free_Kick_Fault_Kick ||
      mWorldState.GetPlayMode() == PM_Our_CatchFault_Kick ||
      mWorldState.GetPlayMode() == PM_Opp_CatchFault_Kick ||
      mWorldState.GetPlayMode() == PM_Time_Over) {
    return false;
  }

  mTackle.Plan(angle, foul);
  mTackle.Execute(mCommandQueue);
  ++mTackleCount;
  mIsTackle = true;
  mIsMutex = true;
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movb %sil, %al
movq %rdi, -0x10(%rbp)
movsd %xmm0, -0x18(%rbp)
andb $0x1, %al
movb %al, -0x19(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movb 0xe97(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
je 0xd1e5
movq -0x30(%rbp), %rax
movb 0xe90(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0xd1ee
movb $0x1, -0x1(%rbp)
jmp 0xd411
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
callq 0x855e0
movq %rax, %rdi
callq 0x10f30
movsd -0x38(%rbp), %xmm1
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
ja 0xd236
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
callq 0x855e0
movq %rax, %rdi
callq 0x10f50
movsd -0x40(%rbp), %xmm0
ucomisd (%rax), %xmm0
jbe 0xd23f
movb $0x0, -0x1(%rbp)
jmp 0xd411
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x10f70
cmpl $0x0, %eax
jle 0xd25a
movb $0x0, -0x1(%rbp)
jmp 0xd411
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rdi
movb -0x19(%rbp), %al
andb $0x1, %al
movzbl %al, %esi
callq 0x10fb0
movsd %xmm0, -0x28(%rbp)
movsd 0xb3d8c(%rip), %xmm0    # 0xc1008
ucomisd -0x28(%rbp), %xmm0
jbe 0xd29e
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x10ed0
cmpl $0x33, %eax
je 0xd29e
movb $0x0, -0x1(%rbp)
jmp 0xd411
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x10ed0
cmpl $0x16, %eax
je 0xd3b2
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x10ed0
cmpl $0x20, %eax
je 0xd3b2
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x10ed0
cmpl $0x21, %eax
je 0xd3b2
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x10ed0
cmpl $0x2c, %eax
je 0xd3b2
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x10ed0
cmpl $0x9, %eax
je 0xd3b2
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x10ed0
cmpl $0xd, %eax
je 0xd3b2
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x10ed0
cmpl $0x30, %eax
je 0xd3b2
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x10ed0
cmpl $0xa, %eax
je 0xd3b2
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x10ed0
cmpl $0x2e, %eax
je 0xd3b2
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x10ed0
cmpl $0xb, %eax
je 0xd3b2
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x10ed0
cmpl $0x2d, %eax
je 0xd3b2
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x10ed0
cmpl $0xc, %eax
je 0xd3b2
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x10ed0
cmpl $0x2f, %eax
je 0xd3b2
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x10ed0
cmpl $0x1d, %eax
jne 0xd3b8
movb $0x0, -0x1(%rbp)
jmp 0xd411
movq -0x30(%rbp), %rdi
addq $0x340, %rdi            # imm = 0x340
movsd -0x18(%rbp), %xmm0
movb -0x19(%rbp), %al
andb $0x1, %al
movzbl %al, %esi
callq 0x15040
movq -0x30(%rbp), %rsi
movq %rsi, %rdi
addq $0x340, %rdi            # imm = 0x340
addq $0x28, %rsi
callq 0x144b0
movq -0x30(%rbp), %rax
movl 0xe58(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xe58(%rax)
movb $0x1, 0xe97(%rax)
movb $0x1, 0xe90(%rax)
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)