// File: 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:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movsd %xmm0, -0x18(%rbp)
movsd %xmm1, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movb 0xe92(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
je 0xc932
movq -0x38(%rbp), %rax
movb 0xe90(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0xc93b
movb $0x0, -0x1(%rbp)
jmp 0xcb46
leaq -0x18(%rbp), %rdi
callq 0x10af0
movsd %xmm0, -0x18(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x10b40
movsd %xmm0, -0x20(%rbp)
callq 0x855e0
movq %rax, %rdi
callq 0x10b90
movsd 0xb469c(%rip), %xmm0    # 0xc1008
ucomisd (%rax), %xmm0
jbe 0xc974
jmp 0xc9c9
callq 0x855e0
movq %rax, %rdi
callq 0x10b90
movsd (%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
callq 0x855e0
movq %rax, %rdi
callq 0x10b90
movsd -0x48(%rbp), %xmm0
divsd (%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x10bb0
movaps %xmm0, %xmm1
movsd -0x40(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
leaq -0x18(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x10bd0
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x10cd0
movq %rax, %rcx
movq -0x38(%rbp), %rax
movsd (%rcx), %xmm0
movsd %xmm0, -0x50(%rbp)
movq 0x20(%rax), %rdi
callq 0x10cf0
movsd -0x50(%rbp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
xorps %xmm0, %xmm0
ucomisd -0x18(%rbp), %xmm0
jbe 0xca63
movsd 0xb45fc(%rip), %xmm0    # 0xc1018
mulsd -0x18(%rbp), %xmm0
ucomisd -0x30(%rbp), %xmm0
jbe 0xca61
movsd -0x30(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd 0xb45d4(%rip), %xmm1    # 0xc1020
mulsd %xmm1, %xmm0
movsd 0xb45b0(%rip), %xmm1    # 0xc1008
addsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
jmp 0xca87
movsd -0x18(%rbp), %xmm0
ucomisd -0x30(%rbp), %xmm0
jbe 0xca85
movsd -0x30(%rbp), %xmm0
movsd 0xb458c(%rip), %xmm1    # 0xc1008
subsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
jmp 0xca87
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x10590
movq %rax, %rdi
callq 0x10d30
testb $0x1, %al
jne 0xcabf
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x10590
movq %rax, %rdi
movsd -0x18(%rbp), %xmm0
callq 0x7c940
movsd %xmm0, -0x18(%rbp)
movsd -0x18(%rbp), %xmm1
movaps 0xb4595(%rip), %xmm0    # 0xc1060
pand %xmm0, %xmm1
movsd 0xb4531(%rip), %xmm0    # 0xc1008
ucomisd %xmm1, %xmm0
jbe 0xcae3
movb $0x0, -0x1(%rbp)
jmp 0xcb46
leaq -0x18(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x10bd0
movq -0x38(%rbp), %rdi
addq $0xc0, %rdi
movsd -0x18(%rbp), %xmm0
movsd -0x20(%rbp), %xmm1
callq 0x14710
movq -0x38(%rbp), %rsi
movq %rsi, %rdi
addq $0xc0, %rdi
addq $0x28, %rsi
callq 0x144b0
movq -0x38(%rbp), %rax
movl 0xe44(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xe44(%rax)
movb $0x1, 0xe92(%rax)
movb $0x1, 0xe90(%rax)
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)