// File: 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
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x48(%rbp)
movq 0x10(%rax), %rdi
callq 0x10ed0
movl %eax, %ecx
movq -0x48(%rbp), %rax
movl %ecx, -0x14(%rbp)
movq 0x10(%rax), %rdi
callq 0x27300
movl %eax, -0x18(%rbp)
cmpl $0xf, -0x14(%rbp)
je 0xa4cf4
cmpl $0xe, -0x14(%rbp)
je 0xa4cf4
cmpl $0x10, -0x14(%rbp)
jne 0xa4cfd
movb $0x0, -0x1(%rbp)
jmp 0xa4f35
cmpl $0x1, -0x14(%rbp)
je 0xa4f31
movq -0x48(%rbp), %rdi
addq $0x5f0, %rdi            # imm = 0x5F0
callq 0xa9140
testb $0x1, (%rax)
jne 0xa4f31
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x1d780
testb $0x1, %al
jne 0xa4f31
cmpl $0x16, -0x14(%rbp)
je 0xa4f31
cmpl $0x16, -0x18(%rbp)
je 0xa4f31
cmpl $0x2, -0x18(%rbp)
je 0xa4f31
cmpl $0x25, -0x18(%rbp)
je 0xa4f31
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x12100
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, -0x50(%rbp)
movq 0x10(%rax), %rdi
callq 0x253d0
movq %rax, %rdi
movl $0x3, %esi
callq 0xa9550
movq -0x50(%rbp), %rdi
movq %rax, -0x20(%rbp)
leaq -0x20(%rbp), %rsi
callq 0x36140
testb $0x1, %al
jne 0xa4da2
jmp 0xa4db5
movb $0x0, 0x33d737(%rip)    # 0x3e24e0
movb $0x0, 0x33d731(%rip)    # 0x3e24e1
jmp 0xa4f2f
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0xa8f80
testb $0x1, %al
jne 0xa4dcf
movb $0x1, -0x1(%rbp)
jmp 0xa4f35
testb $0x1, 0x33d70a(%rip)    # 0x3e24e0
jne 0xa4f2d
testb $0x1, 0x33d6fe(%rip)    # 0x3e24e1
jne 0xa4ec2
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x12100
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, -0x58(%rbp)
movq 0x10(%rax), %rdi
callq 0x253d0
movq -0x58(%rbp), %rdi
movq %rax, %rsi
callq 0x9ed10
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl $0x6, %ecx
cltd
idivl %ecx
movq -0x48(%rbp), %rax
movl %edx, -0x28(%rbp)
movq 0x20(%rax), %rdi
callq 0x1b470
movl $0x6, %ecx
cltd
idivl %ecx
movl %edx, -0x2c(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jne 0xa4ec0
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0xa9580
movq -0x48(%rbp), %rax
movsd %xmm0, 0x648(%rax)
movb $0x0, 0x63c(%rax)
movsd 0x1c1d1(%rip), %xmm0    # 0xc1040
addsd 0x648(%rax), %xmm0
movsd 0x1c1b1(%rip), %xmm1    # 0xc1030
movsd %xmm1, -0x38(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x116b0
movq -0x48(%rbp), %rdi
movsd %xmm0, 0x670(%rdi)
movl $0x3, %esi
callq 0x12ca0
movq -0x48(%rbp), %rdi
movb $0x0, 0x639(%rdi)
callq 0xa83f0
movb $0x1, 0x33d627(%rip)    # 0x3e24e1
movb $0x1, -0x1(%rbp)
jmp 0xa4f35
jmp 0xa4f2b
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0xa95b0
movsd 0x1c151(%rip), %xmm1    # 0xc1028
addsd %xmm1, %xmm0
movsd 0x1c14d(%rip), %xmm1    # 0xc1030
movsd %xmm1, -0x40(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x116b0
movq -0x48(%rbp), %rdi
movsd %xmm0, 0x670(%rdi)
movl $0x3, %esi
callq 0x12ca0
movq -0x48(%rbp), %rdi
movb $0x0, 0x639(%rdi)
callq 0xa83f0
movb $0x0, 0x33d5c3(%rip)    # 0x3e24e1
movb $0x1, 0x33d5bb(%rip)    # 0x3e24e0
movb $0x1, -0x1(%rbp)
jmp 0xa4f35
jmp 0xa4f2d
jmp 0xa4f2f
jmp 0xa4f31
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x60, %rsp
popq %rbp
retq