// File: KellerMartins[P]PDS2-Pacman/source/game/enemies/inky.cpp
// Function: Inky::SetGoal(int&, int&, int, int, int, int)
void Inky::SetGoal(int &goalX, int &goalY, int pacX, int pacY,int dirX, int dirY){
    if(_alive){
        if(!_scared){
           if(_scatter){
                goalX = 1;
                goalY = ALTURA - 2;
                if(_timerScatter > 0){
                    _timerScatter -= 5*GetFrameTime();
                }
            }
            else{
                //O goal esta uma posicao na frente do pacman
                //direita
                if(dirX == 1 && dirY == 0){
                    goalX = pacX + 3;
                    goalY = pacY;
                }
                //esquerda
                else if(dirX == -1 && dirY == 0){
                    goalX = pacX - 3;
                    goalY = pacY;
                }
                //cima
                else if(dirX == 0 && dirY == -1){
                    goalX = pacX;
                    goalY = pacY - 3;
                }
                //baixo
                else if(dirX == 0 && dirY == 1){
                    goalX = pacX;
                    goalY = pacY + 3;
                }
                
            }
        }else{
            goalX = 1;
            goalY = ALTURA - 2;
        }
    }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 0x1d584
leaq 0xcda1b(%rip), %rax     # 0xeae89
testb $0x1, (%rax)
jne 0x1d56e
movq -0x30(%rbp), %rax
testb $0x1, 0x2d8(%rax)
je 0x1d4da
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rcx
movl $0x1, (%rcx)
movq -0x18(%rbp), %rcx
movl $0x19, (%rcx)
movss 0x2e8(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x1d4d5
callq 0x3b476
movq -0x30(%rbp), %rax
movss 0x2e8(%rax), %xmm1
movss 0x881df(%rip), %xmm2    # 0xa56a4
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x2e8(%rax)
jmp 0x1d56c
cmpl $0x1, -0x24(%rbp)
jne 0x1d4fd
cmpl $0x0, 0x10(%rbp)
jne 0x1d4fd
movl -0x1c(%rbp), %ecx
addl $0x3, %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movl -0x20(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
jmp 0x1d56a
cmpl $-0x1, -0x24(%rbp)
jne 0x1d520
cmpl $0x0, 0x10(%rbp)
jne 0x1d520
movl -0x1c(%rbp), %ecx
subl $0x3, %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movl -0x20(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
jmp 0x1d568
cmpl $0x0, -0x24(%rbp)
jne 0x1d543
cmpl $-0x1, 0x10(%rbp)
jne 0x1d543
movl -0x1c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movl -0x20(%rbp), %ecx
subl $0x3, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
jmp 0x1d566
cmpl $0x0, -0x24(%rbp)
jne 0x1d564
cmpl $0x1, 0x10(%rbp)
jne 0x1d564
movl -0x1c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movl -0x20(%rbp), %ecx
addl $0x3, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
jmp 0x1d566
jmp 0x1d568
jmp 0x1d56a
jmp 0x1d56c
jmp 0x1d582
movq -0x10(%rbp), %rax
movl $0x1, (%rax)
movq -0x18(%rbp), %rax
movl $0x19, (%rax)
jmp 0x1d598
movq -0x10(%rbp), %rax
movl $0xa, (%rax)
movq -0x18(%rbp), %rax
movl $0xa, (%rax)
addq $0x30, %rsp
popq %rbp
retq
nop