<commit_before>﻿using UnityEngine;
using Pathfinding;

public interface IPathfinder
{
    void ScanMap();
    Vector3 GetNearest(Vector3 targetPos);
}

public class Pathfinder : IPathfinder
{
    public Vector3 GetNearest(Vector3 targetPos)
    {
        return AstarPath.active.GetNearest(targetPos, new NNConstraint() { walkable = true}).clampedPosition;
    }

    public void ScanMap()
    {
        AstarPath.active.Scan ();
    }
}<commit_msg>safely handle missing astarpath<commit_after>﻿using UnityEngine;
using Pathfinding;

public interface IPathfinder
{
    void ScanMap();
    Vector3 GetNearest(Vector3 targetPos);
}

public class Pathfinder : IPathfinder
{
    public Vector3 GetNearest(Vector3 targetPos)
    {
        if(AstarPath.active)
        {
            return AstarPath.active.GetNearest(targetPos, new NNConstraint() { walkable = true}).clampedPosition;
        }

        return targetPos;
    }

    public void ScanMap()
    {
        if(AstarPath.active)
        {
            AstarPath.active.Scan ();
        }
    }
}
{'fraction_non_alphanumeric': 0.0905624404194471, 'fraction_numerical': 0.0076263107721639654, 'mean_word_length': 2.8461538461538463, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1970890', 'n_tokens_mistral': 325, 'n_tokens_neox': 314, 'n_words': 67}