public void PlayerUpdate()
 {
     if (movingFrame)
     {
         movingFrame = false;
         return;
     }
     if (!transform.position.Equals(targetPos))
     {
         transform.position = targetPos;
         isMoving           = false;
         currentTilePos     = new Vector3Int((int)Math.Floor(transform.position.x), (int)Math.Floor(transform.position.y), 0);
     }
     moveInput.x = (int)Input.GetAxisRaw("Horizontal");
     moveInput.y = (int)Input.GetAxisRaw("Vertical");
     if (moveInput.x == 0 ^ moveInput.y == 0)
     {
         lookTilePos = new Vector3Int(currentTilePos.x + moveInput.x, currentTilePos.y + moveInput.y, 0);
         if (collisionMonitor.TileIsEmpty(lookTilePos))
         {
             isMoving    = true;
             targetPos   = new Vector3(lookTilePos.x + 0.5f, lookTilePos.y + 0.5f, 0);
             movingFrame = true;
         }
     }
 }
    void NonPlayerUpdate()
    {
        int distanceToPlayer = Math.Abs(currentTilePos.x - playerMovement.currentTilePos.x) + Math.Abs(currentTilePos.y - playerMovement.currentTilePos.y);

        if (wakeCountdown > 0)
        {
            if (fogTilemap.GetTile(currentTilePos) == null)
            {
                wakeCountdown--;
            }
            else if (distanceToPlayer == 1)
            {
                wakeCountdown = 0;
            }
            return;
        }
        if ((fogTilemap.GetTile(currentTilePos) == null && !playerVision.isBlinking) || enemyManager.playerIsCaught)
        {
            return;
        }
        if (moveCountdown > 0)
        {
            moveCountdown--;
            return;
        }
        if (distanceToPlayer == 1)
        {
            enemyManager.onPlayerCaught.Invoke();
            return;
        }
        if (distanceToPlayer > detectionRange)
        {
            return;
        }
        List <Vector3Int> bestMoves = pathfinding.GetBestMovesTowardPlayer(currentTilePos, out pathLengthToPlayer);

        if (pathLengthToPlayer > detectionRange)
        {
            return;
        }
        foreach (Vector3Int moveDirection in bestMoves)
        {
            lookTilePos = currentTilePos + moveDirection;
            if ((fogTilemap.GetTile(lookTilePos) == null && !playerVision.isBlinking) || !collisionMonitor.TileIsEmpty(lookTilePos))
            {
                continue;
            }
            currentTilePos     = lookTilePos;
            transform.position = new Vector3(currentTilePos.x + 0.5f, currentTilePos.y + 0.5f, 0);
            collisionMonitor.UpdateEnemyPosition(gameObject, currentTilePos);
            moveCountdown += moveDelay;
            break;
        }
    }