// File: KellerMartins[P]PDS2-Pacman/source/game/enemies/pinky.cpp
// Function: Pinky::SetGoal(int&, int&, int, int, int, int)
void Pinky::SetGoal(int &goalX, int &goalY, int pacX, int pacY,int dirX, int dirY){
    if(_alive){
        if(!_scared){
           if(_scatter){
                goalX = LARGURA -2;
                goalY = 1;
                if(_timerScatter > 0){
                    _timerScatter -= 5*GetFrameTime();
                    
                }
            }
            else{
                //O goal esta duas posicoes na frente do pacman
                //direita
                if(dirX == 1 && dirY == 0){
                    goalX = pacX + 2;
                    goalY = pacY;
                }
                //esquerda
                else if(dirX == -1 && dirY == 0){
                    goalX = pacX - 2;
                    goalY = pacY;
                }
                //cima
                else if(dirX == 0 && dirY == -1){
                    goalX = pacX;
                    goalY = pacY - 2;
                }
                //baixo
                else if(dirX == 0 && dirY == 1){
                    goalX = pacX;
                    goalY = pacY + 2;
                }
            }
        }else{
            goalX = LARGURA - 2;
            goalY = 1;
        }
    }else{
        goalX = 10;
        goalY = 10;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
testb $0x1, 0x2d9(%rax)
je 0x1d794
leaq 0xcd80b(%rip), %rax     # 0xeae89
testb $0x1, (%rax)
jne 0x1d77e
movq -0x30(%rbp), %rax
testb $0x1, 0x2d8(%rax)
je 0x1d6ea
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rcx
movl $0x13, (%rcx)
movq -0x18(%rbp), %rcx
movl $0x1, (%rcx)
movss 0x2e8(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x1d6e5
callq 0x3b476
movq -0x30(%rbp), %rax
movss 0x2e8(%rax), %xmm1
movss 0x87fcf(%rip), %xmm2    # 0xa56a4
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x2e8(%rax)
jmp 0x1d77c
cmpl $0x1, -0x24(%rbp)
jne 0x1d70d
cmpl $0x0, 0x10(%rbp)
jne 0x1d70d
movl -0x1c(%rbp), %ecx
addl $0x2, %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movl -0x20(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
jmp 0x1d77a
cmpl $-0x1, -0x24(%rbp)
jne 0x1d730
cmpl $0x0, 0x10(%rbp)
jne 0x1d730
movl -0x1c(%rbp), %ecx
subl $0x2, %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movl -0x20(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
jmp 0x1d778
cmpl $0x0, -0x24(%rbp)
jne 0x1d753
cmpl $-0x1, 0x10(%rbp)
jne 0x1d753
movl -0x1c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movl -0x20(%rbp), %ecx
subl $0x2, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
jmp 0x1d776
cmpl $0x0, -0x24(%rbp)
jne 0x1d774
cmpl $0x1, 0x10(%rbp)
jne 0x1d774
movl -0x1c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movl -0x20(%rbp), %ecx
addl $0x2, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
jmp 0x1d776
jmp 0x1d778
jmp 0x1d77a
jmp 0x1d77c
jmp 0x1d792
movq -0x10(%rbp), %rax
movl $0x13, (%rax)
movq -0x18(%rbp), %rax
movl $0x1, (%rax)
jmp 0x1d7a8
movq -0x10(%rbp), %rax
movl $0xa, (%rax)
movq -0x18(%rbp), %rax
movl $0xa, (%rax)
addq $0x30, %rsp
popq %rbp
retq
nop