Example #1
0
    public void RemoveOverlaysOfName(Vector3Int cellPosition, LayerType layerType,
                                     string overlayName, bool onlyIfCleanable = false, TileType tileType = TileType.Effects)
    {
        cellPosition.z = 0;

        var overlayPos = metaTileMap.GetOverlayPos(cellPosition, layerType, overlayName);

        if (overlayPos == null)
        {
            return;
        }

        cellPosition = overlayPos.Value;

        if (onlyIfCleanable)
        {
            //only remove it if it's a cleanable tile
            var tile = metaTileMap.GetTile(cellPosition, layerType) as OverlayTile;
            //it's not an overlay tile or it's not cleanable so don't remove it
            if (tile == null || !tile.IsCleanable)
            {
                return;
            }
        }

        InternalRemoveTile(cellPosition, layerType, false);

        RemoveTileMessage.Send(networkIdentity.netId, cellPosition, layerType, false);

        AddToChangeList(cellPosition, layerType);
    }