/// <summary> /// Tries to add a tile to the collection. /// Fails when the priority of the tile is lower than the already present one. /// </summary> /// <param name="inCoordinate">Coordinate to add or change area index for.</param> /// <param name="inAreaIndex">Index of the area to add to the coordinate.</param> public void TryAddTile(Vector2Int inCoordinate, int inAreaIndex) { if (!NavTileAreaManager.IsAreaIndexValid(inAreaIndex)) { return; } if (Tiles.ContainsKey(inCoordinate)) { NavTileArea area = NavTileManager.Instance.AreaManager.GetAreaByID(inAreaIndex); TileData presentData = Tiles[inCoordinate]; if (presentData.Area.Priority <= area.Priority) { // Override if priority is higher presentData.AreaIndex = inAreaIndex; } } else { Tiles[inCoordinate] = new TileData(inAreaIndex); UpdateBounds(inCoordinate); } }
/// <summary> /// Overrides a tile regardless of priority. /// </summary> /// <param name="inCoordinate">Coordinate to override area index for.</param> /// <param name="inAreaIndex">Area index to override with, -1 will remove any present tile area.</param> public void OverrideTile(Vector2Int inCoordinate, int inAreaIndex) { if (inAreaIndex == -1) { RemoveTile(inCoordinate); return; } if (!NavTileAreaManager.IsAreaIndexValid(inAreaIndex)) { return; } if (Tiles.ContainsKey(inCoordinate)) { Tiles[inCoordinate].AreaIndex = inAreaIndex; } else { Tiles[inCoordinate] = new TileData(inAreaIndex); } }