SharpNav.TiledNavMesh.TryGetTileAndPolyByRef C# (CSharp) Method

TryGetTileAndPolyByRef() public method

Retrieve the tile and poly based off of a polygon reference
public TryGetTileAndPolyByRef ( NavPolyId reference, NavTile &tile, NavPoly &poly ) : bool
reference NavPolyId Polygon reference
tile NavTile Resulting tile
poly SharpNav.Pathfinding.NavPoly Resulting poly
return bool
        public bool TryGetTileAndPolyByRef(NavPolyId reference, out NavTile tile, out NavPoly poly)
        {
            tile = null;
            poly = null;

            if (reference == NavPolyId.Null)
                return false;

            //Get tile and poly indices
            int salt, polyIndex, tileIndex;
            idManager.Decode(ref reference, out polyIndex, out tileIndex, out salt);

            //Make sure indices are valid
            if (tileIndex >= maxTiles)
                return false;

            if (tileList[tileIndex].Salt != salt)
                return false;

            if (polyIndex >= tileList[tileIndex].PolyCount)
                return false;

            //Retrieve tile and poly
            tile = tileList[tileIndex];
            poly = tileList[tileIndex].Polys[polyIndex];
            return true;
        }