// File: /workspace/github_cpp_makefile_star2_O3/wrighteagle2d[P]wrighteaglebase/Debug/../src/ActionEffector.cpp
// Function: ActionEffector::SetDashAction(double, double)
bool ActionEffector::SetDashAction(double power, AngleDeg dir) {
  Assert(dir > -180.0 - FLOAT_EPS && dir < 180.0 + FLOAT_EPS);

  if (mIsDash == true || mIsMutex == true) {
    return false;
  }

  power = GetNormalizeDashPower(power);
  dir = GetNormalizeDashAngle(dir);

  // 注意，在rcssserver13.1.0版本下，dash只需要考虑下面四种情况即可：
  // @ -power 0.0
  // @ +power 0.0
  // @ +power 90.0
  // @ +power -90.0
  //
  // from rcssserver13.1.0

  // 注意，在rcssserver v14 下，dash需要考虑的情况包括：
  // @ +power, 0
  // @ +power, 45
  // @ +power, 90
  // @ +power, 135 | -power, -45
  // @ -power, 0 | +power, 180
  // @ +power, -45
  // @ +power, -90
  // @ -power, 45 | +power, -135
  if (ServerParam::instance().dashAngleStep() < FLOAT_EPS) {
    // players can dash in any direction.
  } else {
    // The dash direction is discretized by server::dash_angle_step
    dir = ServerParam::instance().dashAngleStep() *
          Rint(dir / ServerParam::instance().dashAngleStep());
  }

  TransformDash(power, dir);

  double max_stamina = mSelfState.GetStamina() + mSelfState.GetExtraStamina();
  if (power < 0.0) {
    if ((-2.0 * power) > max_stamina) {
      power = -max_stamina * 0.5 + FLOAT_EPS;
    }
  } else {
    if (power > max_stamina) {
      power = max_stamina - FLOAT_EPS;
    }
  }

  if (!mAgent.GetSelf().IsOutOfStamina()) {
    power = mAgent.GetSelf().CorrectDashPowerForStamina(
        power); // 保证不降到最低体力以下
  }

  if (std::fabs(power) < FLOAT_EPS)
    return false;

  TransformDash(power, dir);

  mDash.Plan(power, dir);
  mDash.Execute(mCommandQueue);
  ++mDashCount;
  mIsDash = true;
  mIsMutex = true;
  return true;
}

// Assembly:
cmpb $0x0, 0xe92(%rdi)
je 0xbc94
xorl %eax, %eax
retq
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x40, %rsp
movq %rdi, %rbx
cmpb $0x0, 0xe90(%rdi)
jne 0xbfc4
movsd %xmm1, -0x18(%rbp)
movsd %xmm0, -0x40(%rbp)
callq 0x49360
movq %rax, %r14
callq 0x49360
movsd -0x40(%rbp), %xmm1
maxsd 0x33c8(%r14), %xmm1
movsd 0x33c0(%rax), %xmm0
minsd %xmm1, %xmm0
movapd %xmm0, -0x40(%rbp)
callq 0x49360
movq %rax, %r14
callq 0x49360
movsd -0x18(%rbp), %xmm1
maxsd 0x33a0(%r14), %xmm1
movsd 0x3398(%rax), %xmm0
minsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
callq 0x49360
movsd 0x5d322(%rip), %xmm0    # 0x69040
ucomisd 0x33a8(%rax), %xmm0
jbe 0xbd2f
movsd -0x18(%rbp), %xmm0
jmp 0xbd5d
callq 0x49360
movsd 0x33a8(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
callq 0x49360
movsd -0x18(%rbp), %xmm0
divsd 0x33a8(%rax), %xmm0
callq 0x96b0
mulsd -0x30(%rbp), %xmm0
xorpd %xmm2, %xmm2
movapd -0x40(%rbp), %xmm1
ucomisd %xmm1, %xmm2
movsd %xmm0, -0x18(%rbp)
jbe 0xbe27
movapd 0x5d2a3(%rip), %xmm2    # 0x69020
xorpd %xmm1, %xmm2
movapd %xmm2, -0x30(%rbp)
callq 0xe7f9
mulsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd 0x5d2ab(%rip), %xmm0    # 0x69048
addsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
callq 0xe7f9
movsd -0x30(%rbp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, -0x30(%rbp)
callq 0x49360
movsd -0x30(%rbp), %xmm2
movsd 0x33c0(%rax), %xmm0
ucomisd %xmm2, %xmm0
jbe 0xbe27
movsd 0x5d286(%rip), %xmm0    # 0x69060
movsd -0x48(%rbp), %xmm3
ucomisd %xmm3, %xmm0
jbe 0xbdf9
movsd 0x5d283(%rip), %xmm1    # 0x69070
addsd %xmm1, %xmm3
ucomisd %xmm3, %xmm0
ja 0xbded
jmp 0xbe1d
ucomisd 0x5d247(%rip), %xmm3    # 0x69048
jb 0xbe1d
movsd 0x5d25d(%rip), %xmm0    # 0x69068
movsd 0x5d235(%rip), %xmm1    # 0x69048
addsd %xmm0, %xmm3
ucomisd %xmm1, %xmm3
jae 0xbe13
movsd %xmm3, -0x18(%rbp)
movapd %xmm2, -0x40(%rbp)
movq 0x20(%rbx), %r14
movsd 0x78(%r14), %xmm0
movsd %xmm0, -0x30(%rbp)
callq 0x43dce
movsd -0x30(%rbp), %xmm2
movq 0x5c38(%rax), %rax
movslq 0x114(%r14), %rcx
imulq $0x3700, %rcx, %rcx     # imm = 0x3700
addsd 0x3050(%rax,%rcx), %xmm2
xorpd %xmm0, %xmm0
movapd -0x40(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0xbe91
movsd 0x5d20b(%rip), %xmm0    # 0x69080
mulsd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
jbe 0xbea3
mulsd 0x5d201(%rip), %xmm2    # 0x69088
addsd 0x5d1b1(%rip), %xmm2    # 0x69040
jmp 0xbe9f
ucomisd %xmm2, %xmm1
jbe 0xbea3
addsd 0x5d1d9(%rip), %xmm2    # 0x69078
movapd %xmm2, %xmm1
movapd %xmm1, -0x40(%rbp)
movq 0x8(%rbx), %rdi
callq 0xe75a
movsd 0x78(%rax), %xmm0
addsd 0x88(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
callq 0x43dce
movsd 0x5c60(%rax), %xmm0
addsd 0x5d168(%rip), %xmm0    # 0x69040
ucomisd -0x30(%rbp), %xmm0
jbe 0xbee6
movapd -0x40(%rbp), %xmm1
jmp 0xbf00
movq 0x8(%rbx), %rdi
callq 0xe75a
movq %rax, %rdi
movapd -0x40(%rbp), %xmm0
callq 0x45d84
movapd %xmm0, %xmm1
movapd 0x5d108(%rip), %xmm0    # 0x69010
andpd %xmm1, %xmm0
movsd 0x5d12c(%rip), %xmm2    # 0x69040
ucomisd %xmm0, %xmm2
ja 0xbfc4
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jbe 0xbfc8
movapd 0x5d0ec(%rip), %xmm0    # 0x69020
xorpd %xmm1, %xmm0
movapd %xmm0, -0x30(%rbp)
movsd -0x18(%rbp), %xmm0
movapd %xmm1, -0x40(%rbp)
callq 0xe7f9
mulsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd 0x5d0ea(%rip), %xmm0    # 0x69048
addsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
callq 0xe7f9
movsd -0x30(%rbp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, -0x30(%rbp)
callq 0x49360
movsd -0x18(%rbp), %xmm3
movsd -0x30(%rbp), %xmm2
movapd -0x40(%rbp), %xmm1
movsd 0x33c0(%rax), %xmm0
ucomisd %xmm2, %xmm0
jbe 0xbff7
movsd 0x5d0bb(%rip), %xmm0    # 0x69060
movsd -0x48(%rbp), %xmm3
ucomisd %xmm3, %xmm0
jbe 0xbfcf
movsd 0x5d0b8(%rip), %xmm1    # 0x69070
addsd %xmm1, %xmm3
ucomisd %xmm3, %xmm0
ja 0xbfb8
jmp 0xbff3
xorl %eax, %eax
jmp 0xc02e
movsd -0x18(%rbp), %xmm3
jmp 0xbff7
ucomisd 0x5d071(%rip), %xmm3    # 0x69048
jb 0xbff3
movsd 0x5d087(%rip), %xmm0    # 0x69068
movsd 0x5d05f(%rip), %xmm1    # 0x69048
addsd %xmm0, %xmm3
ucomisd %xmm1, %xmm3
jae 0xbfe9
movapd %xmm2, %xmm1
leaq 0xc0(%rbx), %r14
movq %r14, %rdi
movapd %xmm1, %xmm0
movapd %xmm3, %xmm1
callq 0xf7be
leaq 0x28(%rbx), %rsi
movq %r14, %rdi
callq 0xf5c8
incl 0xe44(%rbx)
movb $0x1, %al
movb %al, 0xe92(%rbx)
movb %al, 0xe90(%rbx)
addq $0x40, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nop