// File: /workspace/github_cpp_makefile_star2_O1/wrighteagle2d[P]wrighteaglebase/Debug/../src/VisualSystem.cpp
// Function: VisualSystem::DealWithSetPlayMode()
bool VisualSystem::DealWithSetPlayMode() {
  static bool check_both_side = false;
  static bool check_one_side = false;

  PlayMode play_mode = mpWorldState->GetPlayMode();
  PlayMode last_play_mode = mpWorldState->GetLastPlayMode();

  if (play_mode == PM_Our_Penalty_Ready || play_mode == PM_Our_Penalty_Setup ||
      play_mode == PM_Our_Penalty_Taken)
    return false;

  if (play_mode != PM_Play_On && !(mForceToSeeObject.GetOfBall()) &&
      !mpSelfState->IsGoalie() && play_mode != PM_Before_Kick_Off &&
      last_play_mode != PM_Before_Kick_Off &&
      last_play_mode != PM_Our_Kick_Off && last_play_mode != PM_Opp_Kick_Off) {
    //特殊模式下要强制看看全场， 防止遗漏
    if (mpWorldState->CurrentTime() <
        mpWorldState->GetPlayModeTime() + 3) { //前三个周期等视觉信息到来
      check_both_side = false;
      check_one_side = false;
    } else {
      if (!mpAgent->IsNewSight())
        return true;

      if (!check_both_side) {
        if (!check_one_side) {
          int diff =
              mpWorldState->CurrentTime() - mpWorldState->GetPlayModeTime();
          int flag = diff % 6;
          int base = mpSelfState->GetUnum() %
                     6; //不要大家都一起改变视角，这样可能一起错过对方发球的瞬间

          if (flag == base) {
            mPreBodyDir = mpAgent->GetSelfBodyDirWithQueuedActions();
            mCanTurn = false;
            mBestVisualAction.mDir = GetNormalizeAngleDeg(mPreBodyDir + 90.0);
            ChangeViewWidth(VW_Wide); // new info will come in 3 cycle
            mCanForceChangeViewWidth = false;
            DoVisualExecute();
            check_one_side = true;

            return true;
          }
        } else {
          mBestVisualAction.mDir =
              GetNormalizeAngleDeg(mpSelfState->GetNeckGlobalDir() + 180.0);
          ChangeViewWidth(VW_Wide); // new info will come in 3 cycle
          mCanForceChangeViewWidth = false;
          DoVisualExecute();
          check_one_side = false;
          check_both_side = true;

          return true;
        }
      }
    }
  }

  return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
movq 0x10(%rdi), %rcx
movl 0x1c(%rcx), %eax
movl 0x20(%rcx), %edx
leal -0x1(%rax), %esi
cmpl $0x10, %esi
jae 0x580fb
movl $0xe001, %edi           # imm = 0xE001
btl %esi, %edi
jb 0x58105
cmpb $0x0, 0x5f0(%r14)
je 0x58114
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
xorl %ebx, %ebx
cmpl $0x25, %edx
je 0x58107
cmpl $0x2, %edx
je 0x58107
cmpl $0x16, %edx
je 0x58107
cmpl $0x16, %eax
je 0x58107
movq 0x20(%r14), %rdi
cmpb $0x0, 0x175(%rdi)
jne 0x58107
leaq 0x10(%rcx), %rax
leaq 0x24(%rcx), %rsi
movl 0x24(%rcx), %edx
addl $0x3, %edx
cmpl %edx, 0x10(%rcx)
jge 0x5815a
xorl %ebx, %ebx
movb %bl, 0x31322e(%rip)     # 0x36b380
movb %bl, 0x313229(%rip)     # 0x36b381
jmp 0x58107
jne 0x58162
cmpl $0x0, 0x14(%rcx)
js 0x5814a
movq 0x8(%r14), %rcx
movb $0x1, %bl
cmpb $0x1, 0x28(%rcx)
jne 0x58107
cmpb $0x0, 0x31320b(%rip)    # 0x36b380
jne 0x58105
cmpb $0x0, 0x313203(%rip)    # 0x36b381
je 0x581b6
callq 0x5b2be
addsd 0x12ebb(%rip), %xmm0    # 0x6b048
movsd 0x12ecb(%rip), %xmm1    # 0x6b060
ucomisd %xmm0, %xmm1
jbe 0x58258
movsd 0x12ec9(%rip), %xmm2    # 0x6b070
addsd %xmm2, %xmm0
ucomisd %xmm0, %xmm1
ja 0x581a7
jmp 0x5827c
movq %rax, %rdi
callq 0x55ef4
cltq
imulq $0x2aaaaaab, %rax, %rcx # imm = 0x2AAAAAAB
movq %rcx, %rdx
shrq $0x3f, %rdx
shrq $0x20, %rcx
addl %edx, %ecx
addl %ecx, %ecx
leal (%rcx,%rcx,2), %ecx
subl %ecx, %eax
movq 0x20(%r14), %rcx
movslq 0x11c(%rcx), %rcx
imulq $0x2aaaaaab, %rcx, %rdx # imm = 0x2AAAAAAB
movq %rdx, %rsi
shrq $0x3f, %rsi
shrq $0x20, %rdx
addl %esi, %edx
addl %edx, %edx
leal (%rdx,%rdx,2), %edx
subl %edx, %ecx
cmpl %ecx, %eax
jne 0x58105
movq 0x8(%r14), %rdi
callq 0xef28
movq %rax, %rdi
callq 0xe29c
movsd %xmm0, 0x648(%r14)
addsd 0x12e85(%rip), %xmm0    # 0x6b0b0
movb $0x0, 0x63c(%r14)
movsd 0x12e25(%rip), %xmm1    # 0x6b060
ucomisd %xmm0, %xmm1
jbe 0x582b5
movsd 0x12e27(%rip), %xmm2    # 0x6b070
addsd %xmm2, %xmm0
ucomisd %xmm0, %xmm1
ja 0x58249
jmp 0x582d9
ucomisd 0x12de8(%rip), %xmm0    # 0x6b048
jb 0x5827c
movsd 0x12dfe(%rip), %xmm1    # 0x6b068
movsd 0x12dd6(%rip), %xmm2    # 0x6b048
addsd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
jae 0x58272
movsd %xmm0, 0x670(%r14)
movl $0x3, 0x640(%r14)
xorl %r15d, %r15d
movb %r15b, 0x639(%r14)
movq %r14, %rdi
callq 0x5a870
movb %r15b, 0x3130d8(%rip)   # 0x36b381
movb $0x1, 0x3130d0(%rip)    # 0x36b380
jmp 0x58107
ucomisd 0x12d8b(%rip), %xmm0    # 0x6b048
jb 0x582d9
movsd 0x12da1(%rip), %xmm1    # 0x6b068
movsd 0x12d79(%rip), %xmm2    # 0x6b048
addsd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
jae 0x582cf
movsd %xmm0, 0x670(%r14)
movl $0x3, 0x640(%r14)
movb $0x0, 0x639(%r14)
movq %r14, %rdi
callq 0x5a870
movb $0x1, 0x31307d(%rip)    # 0x36b381
jmp 0x58107
nop