// File: /workspace/github_cpp_makefile_star2_O3/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 0x568b5
movl $0xe001, %edi           # imm = 0xE001
btl %esi, %edi
jb 0x568bf
cmpb $0x0, 0x5f0(%r14)
je 0x568ce
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 0x568c1
cmpl $0x2, %edx
je 0x568c1
cmpl $0x16, %edx
je 0x568c1
cmpl $0x16, %eax
je 0x568c1
movq 0x20(%r14), %rdi
cmpb $0x0, 0x175(%rdi)
jne 0x568c1
leaq 0x10(%rcx), %rax
leaq 0x24(%rcx), %rsi
movl 0x24(%rcx), %edx
addl $0x3, %edx
cmpl %edx, 0x10(%rcx)
jge 0x56914
xorl %ebx, %ebx
movb %bl, 0x311a74(%rip)     # 0x368380
movb %bl, 0x311a6f(%rip)     # 0x368381
jmp 0x568c1
jne 0x5691c
cmpl $0x0, 0x14(%rcx)
js 0x56904
movq 0x8(%r14), %rcx
movb $0x1, %bl
cmpb $0x1, 0x28(%rcx)
jne 0x568c1
cmpb $0x0, 0x311a51(%rip)    # 0x368380
jne 0x568bf
cmpb $0x0, 0x311a49(%rip)    # 0x368381
je 0x56970
callq 0x59a22
addsd 0x12701(%rip), %xmm0    # 0x69048
movsd 0x12711(%rip), %xmm1    # 0x69060
ucomisd %xmm0, %xmm1
jbe 0x56a12
movsd 0x1270f(%rip), %xmm2    # 0x69070
addsd %xmm2, %xmm0
ucomisd %xmm0, %xmm1
ja 0x56961
jmp 0x56a36
movq %rax, %rdi
callq 0x546de
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 0x568bf
movq 0x8(%r14), %rdi
callq 0xee28
movq %rax, %rdi
callq 0xe1ac
movsd %xmm0, 0x648(%r14)
addsd 0x126cb(%rip), %xmm0    # 0x690b0
movb $0x0, 0x63c(%r14)
movsd 0x1266b(%rip), %xmm1    # 0x69060
ucomisd %xmm0, %xmm1
jbe 0x56a6f
movsd 0x1266d(%rip), %xmm2    # 0x69070
addsd %xmm2, %xmm0
ucomisd %xmm0, %xmm1
ja 0x56a03
jmp 0x56a93
ucomisd 0x1262e(%rip), %xmm0    # 0x69048
jb 0x56a36
movsd 0x12644(%rip), %xmm1    # 0x69068
movsd 0x1261c(%rip), %xmm2    # 0x69048
addsd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
jae 0x56a2c
movsd %xmm0, 0x670(%r14)
movl $0x3, 0x640(%r14)
xorl %r15d, %r15d
movb %r15b, 0x639(%r14)
movq %r14, %rdi
callq 0x59006
movb %r15b, 0x31191e(%rip)   # 0x368381
movb $0x1, 0x311916(%rip)    # 0x368380
jmp 0x568c1
ucomisd 0x125d1(%rip), %xmm0    # 0x69048
jb 0x56a93
movsd 0x125e7(%rip), %xmm1    # 0x69068
movsd 0x125bf(%rip), %xmm2    # 0x69048
addsd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
jae 0x56a89
movsd %xmm0, 0x670(%r14)
movl $0x3, 0x640(%r14)
movb $0x0, 0x639(%r14)
movq %r14, %rdi
callq 0x59006
movb $0x1, 0x3118c3(%rip)    # 0x368381
jmp 0x568c1
nop