// File: /workspace/github_cpp_makefile_star2_O2/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 0x49541
movl $0xe001, %edi           # imm = 0xE001
btl %esi, %edi
jb 0x4954b
cmpb $0x0, 0x5f0(%r14)
je 0x4955a
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 0x4954d
cmpl $0x2, %edx
je 0x4954d
cmpl $0x16, %edx
je 0x4954d
cmpl $0x16, %eax
je 0x4954d
movq 0x20(%r14), %rdi
cmpb $0x0, 0x175(%rdi)
jne 0x4954d
leaq 0x10(%rcx), %rax
leaq 0x24(%rcx), %rsi
movl 0x24(%rcx), %edx
addl $0x3, %edx
cmpl %edx, 0x10(%rcx)
jge 0x495a0
xorl %ebx, %ebx
movb %bl, 0x311de8(%rip)     # 0x35b380
movb %bl, 0x311de3(%rip)     # 0x35b381
jmp 0x4954d
jne 0x495a8
cmpl $0x0, 0x14(%rcx)
js 0x49590
movq 0x8(%r14), %rcx
movb $0x1, %bl
cmpb $0x1, 0x28(%rcx)
jne 0x4954d
cmpb $0x0, 0x311dc5(%rip)    # 0x35b380
jne 0x4954b
cmpb $0x0, 0x311dbd(%rip)    # 0x35b381
je 0x49622
callq 0x4bef2
addsd 0xda95(%rip), %xmm0     # 0x57068
movabsq $-0x3f99800000000000, %rax # imm = 0xC066800000000000
leaq -0x20(%rbp), %rdi
movq %rax, (%rdi)
callq 0xd305
movsd %xmm0, 0x670(%r14)
movl $0x3, 0x640(%r14)
xorl %r15d, %r15d
movb %r15b, 0x639(%r14)
movq %r14, %rdi
callq 0x4b678
movb %r15b, 0x311d6b(%rip)   # 0x35b381
movb $0x1, 0x311d63(%rip)    # 0x35b380
jmp 0x4954d
movq %rax, %rdi
callq 0x4770c
pushq $0x6
popq %rsi
cltd
idivl %esi
movl %edx, %ecx
movq 0x20(%r14), %rax
movl 0x11c(%rax), %eax
cltd
idivl %esi
cmpl %edx, %ecx
jne 0x4954b
movq 0x8(%r14), %rdi
callq 0x4bee0
movsd %xmm0, 0x648(%r14)
xorl %r15d, %r15d
addsd 0xda24(%rip), %xmm0     # 0x57088
movb %r15b, 0x63c(%r14)
movabsq $-0x3f99800000000000, %rax # imm = 0xC066800000000000
leaq -0x20(%rbp), %rdi
movq %rax, (%rdi)
callq 0xd305
movsd %xmm0, 0x670(%r14)
movl $0x3, 0x640(%r14)
movb %r15b, 0x639(%r14)
movq %r14, %rdi
callq 0x4b678
movb $0x1, 0x311cd6(%rip)    # 0x35b381
jmp 0x4954d