Exemple #1
0
    /// <summary>
    /// Returns if there are changes to the map or not.
    /// </summary>
    private bool CheckForMapChanges()
    {
        // Check if bot sees new obstacles
        HashSet <Vector2Int> coordinatesInSight = m_environment.GetIlluminatedCoordinates(Start);

        bool change = false;

        foreach (Vector2Int coordinates in coordinatesInSight)
        {
            // What the bot knows of the node
            Node knownNode = Map.GetNode(coordinates.x, coordinates.y);
            // What the node actually is
            Tile actualNodeContent = m_environment.GetNode(coordinates);
            // If the obstacle was not previously known or the obstacle has been removed
            if (knownNode.Content != actualNodeContent)
            {
                change            = true;
                knownNode.Content = actualNodeContent;
                foreach (Vector2Int surroundingCoordinates in Map.GetSurroundingOpenSpaces(coordinates))
                {
                    UpdateVertex(surroundingCoordinates);
                }
            }
        }

        ComputeShortestPath();
        return(change);
    }