// File: /workspace/github_cpp_makefile_star2_O1/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 0xbd60
xorl %eax, %eax
retq
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x40, %rsp
movq %rdi, %rbx
cmpb $0x0, 0xe90(%rdi)
je 0xbd7e
xorl %eax, %eax
jmp 0xc0fc
movsd %xmm1, -0x18(%rbp)
movsd %xmm0, -0x40(%rbp)
callq 0x4a75c
movq %rax, %r14
callq 0x4a75c
movsd 0x33c0(%rax), %xmm0
movsd -0x40(%rbp), %xmm1
maxsd 0x33c8(%r14), %xmm1
minsd %xmm1, %xmm0
movapd %xmm0, -0x40(%rbp)
callq 0x4a75c
movq %rax, %r14
callq 0x4a75c
movsd 0x3398(%rax), %xmm0
movsd -0x18(%rbp), %xmm1
maxsd 0x33a0(%r14), %xmm1
minsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
callq 0x4a75c
movsd 0x5f253(%rip), %xmm0    # 0x6b040
ucomisd 0x33a8(%rax), %xmm0
jbe 0xbdfe
movsd -0x18(%rbp), %xmm0
jmp 0xbe2c
callq 0x4a75c
movsd 0x33a8(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
callq 0x4a75c
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 0xbef6
movapd 0x5f1d4(%rip), %xmm2    # 0x6b020
xorpd %xmm1, %xmm2
movapd %xmm2, -0x30(%rbp)
callq 0xe8f9
mulsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd 0x5f1dc(%rip), %xmm0    # 0x6b048
addsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
callq 0xe8f9
movsd -0x30(%rbp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, -0x30(%rbp)
callq 0x4a75c
movsd -0x30(%rbp), %xmm2
movsd 0x33c0(%rax), %xmm0
ucomisd %xmm2, %xmm0
jbe 0xbef6
movsd 0x5f1b7(%rip), %xmm0    # 0x6b060
movsd -0x48(%rbp), %xmm3
ucomisd %xmm3, %xmm0
jbe 0xbec8
movsd 0x5f1b4(%rip), %xmm1    # 0x6b070
addsd %xmm1, %xmm3
ucomisd %xmm3, %xmm0
ja 0xbebc
jmp 0xbeec
ucomisd 0x5f178(%rip), %xmm3    # 0x6b048
jb 0xbeec
movsd 0x5f18e(%rip), %xmm0    # 0x6b068
movsd 0x5f166(%rip), %xmm1    # 0x6b048
addsd %xmm0, %xmm3
ucomisd %xmm1, %xmm3
jae 0xbee2
movsd %xmm3, -0x18(%rbp)
movapd %xmm2, -0x40(%rbp)
movq 0x20(%rbx), %r14
movsd 0x78(%r14), %xmm0
movsd %xmm0, -0x30(%rbp)
callq 0x450ba
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 0xbf60
movsd 0x5f13c(%rip), %xmm0    # 0x6b080
mulsd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
jbe 0xbf72
mulsd 0x5f132(%rip), %xmm2    # 0x6b088
addsd 0x5f0e2(%rip), %xmm2    # 0x6b040
jmp 0xbf6e
ucomisd %xmm2, %xmm1
jbe 0xbf72
addsd 0x5f10a(%rip), %xmm2    # 0x6b078
movapd %xmm2, %xmm1
movapd %xmm1, -0x40(%rbp)
movq 0x8(%rbx), %rdi
callq 0xe85a
movsd 0x78(%rax), %xmm0
addsd 0x88(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
callq 0x450ba
movsd 0x5c60(%rax), %xmm0
addsd 0x5f099(%rip), %xmm0    # 0x6b040
ucomisd -0x30(%rbp), %xmm0
jbe 0xbfb5
movapd -0x40(%rbp), %xmm1
jmp 0xbfcf
movq 0x8(%rbx), %rdi
callq 0xe85a
movq %rax, %rdi
movapd -0x40(%rbp), %xmm0
callq 0x470e2
movapd %xmm0, %xmm1
movapd 0x5f039(%rip), %xmm0    # 0x6b010
andpd %xmm1, %xmm0
movsd 0x5f05d(%rip), %xmm2    # 0x6b040
ucomisd %xmm0, %xmm2
setbe %al
ja 0xc0fc
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jbe 0xc096
movapd 0x5f01a(%rip), %xmm0    # 0x6b020
xorpd %xmm1, %xmm0
movapd %xmm0, -0x30(%rbp)
movsd -0x18(%rbp), %xmm0
movapd %xmm1, -0x40(%rbp)
callq 0xe8f9
mulsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd 0x5f018(%rip), %xmm0    # 0x6b048
addsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
callq 0xe8f9
movsd -0x30(%rbp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, -0x30(%rbp)
callq 0x4a75c
movsd -0x18(%rbp), %xmm3
movsd -0x30(%rbp), %xmm2
movapd -0x40(%rbp), %xmm1
movsd 0x33c0(%rax), %xmm0
ucomisd %xmm2, %xmm0
jbe 0xc0c5
movsd 0x5efe9(%rip), %xmm0    # 0x6b060
movsd -0x48(%rbp), %xmm3
ucomisd %xmm3, %xmm0
jbe 0xc09d
movsd 0x5efe6(%rip), %xmm1    # 0x6b070
addsd %xmm1, %xmm3
ucomisd %xmm3, %xmm0
ja 0xc08a
jmp 0xc0c1
movsd -0x18(%rbp), %xmm3
jmp 0xc0c5
ucomisd 0x5efa3(%rip), %xmm3    # 0x6b048
jb 0xc0c1
movsd 0x5efb9(%rip), %xmm0    # 0x6b068
movsd 0x5ef91(%rip), %xmm1    # 0x6b048
addsd %xmm0, %xmm3
ucomisd %xmm1, %xmm3
jae 0xc0b7
movapd %xmm2, %xmm1
leaq 0xc0(%rbx), %r14
movq %r14, %rdi
movapd %xmm1, %xmm0
movapd %xmm3, %xmm1
callq 0xf8ce
leaq 0x28(%rbx), %rsi
movq %r14, %rdi
callq 0xf6d8
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