// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movsd %xmm0, -0x28(%rbp)
movsd %xmm1, -0x30(%rbp)
cmpb $0x0, 0xe92(%rdi)
jne 0xaf33
movq %rdi, %rbx
cmpb $0x0, 0xe90(%rdi)
jne 0xaf33
leaq -0x28(%rbp), %r14
movq %r14, %rdi
callq 0xce6b
movsd %xmm0, (%r14)
leaq -0x30(%rbp), %r14
movq %r14, %rdi
callq 0xcea0
movsd %xmm0, (%r14)
callq 0x3db2c
movsd 0x4c259(%rip), %xmm0    # 0x57040
ucomisd 0x33a8(%rax), %xmm0
ja 0xae2e
callq 0x3db2c
movsd 0x33a8(%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
callq 0x3db2c
movsd -0x40(%rbp), %xmm0
divsd 0x33a8(%rax), %xmm0
callq 0x96d0
mulsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
leaq -0x28(%rbp), %r14
leaq -0x30(%rbp), %rsi
movq %r14, %rdi
callq 0xced5
movq 0x20(%rbx), %rdi
movsd 0x78(%rdi), %xmm0
movsd %xmm0, -0x38(%rbp)
callq 0xcf86
movsd -0x38(%rbp), %xmm2
addsd (%rax), %xmm2
movsd (%r14), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
jbe 0xae89
mulsd 0x4c1e7(%rip), %xmm0    # 0x57058
ucomisd %xmm2, %xmm0
jbe 0xae9c
mulsd 0x4c1e1(%rip), %xmm2    # 0x57060
addsd 0x4c1b9(%rip), %xmm2    # 0x57040
jmp 0xae97
ucomisd %xmm2, %xmm0
jbe 0xae9c
addsd 0x4c1b9(%rip), %xmm2    # 0x57050
movsd %xmm2, -0x28(%rbp)
movq 0x8(%rbx), %rdi
callq 0xcd42
movq %rax, %rdi
callq 0xcfba
testb %al, %al
je 0xaeb8
movsd -0x28(%rbp), %xmm0
jmp 0xaed3
movq 0x8(%rbx), %rdi
callq 0xcd42
movsd -0x28(%rbp), %xmm0
movq %rax, %rdi
callq 0x3a8ce
movsd %xmm0, -0x28(%rbp)
andpd 0x4c135(%rip), %xmm0    # 0x57010
movsd 0x4c15d(%rip), %xmm1    # 0x57040
ucomisd %xmm0, %xmm1
ja 0xaf33
leaq -0x30(%rbp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0xced5
leaq 0xc0(%rbx), %r12
movsd (%r14), %xmm0
movsd (%r15), %xmm1
movq %r12, %rdi
callq 0xdfe0
leaq 0x28(%rbx), %rsi
movq %r12, %rdi
callq 0xde70
incl 0xe44(%rbx)
movb $0x1, %al
movb %al, 0xe92(%rbx)
movb %al, 0xe90(%rbx)
jmp 0xaf35
xorl %eax, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq