Table of Contents

Class MapTileManager

Namespace
WitShells.MapView
public class MapTileManager : MonoSingleton<MapTileManager>, IDisposable
Inheritance
MapTileManager
Implements
Inherited Members

Fields

OnTileFetched

public UnityEvent<Vector2Int, Tile> OnTileFetched

Field Value

UnityEvent<Vector2Int, Tile>

OnTilesFetched

public UnityEvent<List<Tile>> OnTilesFetched

Field Value

UnityEvent<List<Tile>>

canCacheTiles

public bool canCacheTiles

Field Value

bool

Properties

ActiveDownloader

public DownloaderTiles ActiveDownloader { get; }

Property Value

DownloaderTiles

DbConnection

public SQLiteConnection DbConnection { get; }

Property Value

SQLiteConnection

DirectoryPath

public string DirectoryPath { get; }

Property Value

string

FilePath

public string FilePath { get; }

Property Value

string

HasValidFile

public bool HasValidFile { get; }

Property Value

bool

canFetchOnline

public bool canFetchOnline { get; }

Property Value

bool

Methods

CancelFetch(string)

public void CancelFetch(string threadId)

Parameters

threadId string

CancelRegionDownload()

Cancels the currently running region download, if any.

public void CancelRegionDownload()

CreateDatabase(out SQLiteConnection)

public bool CreateDatabase(out SQLiteConnection connection)

Parameters

connection SQLiteConnection

Returns

bool

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

FetchTile(Vector2Int, int, bool, UnityAction<Tile>, out string)

public void FetchTile(Vector2Int coordinate, int zoomLevel, bool showLabels, UnityAction<Tile> onComplete, out string threadId)

Parameters

coordinate Vector2Int
zoomLevel int
showLabels bool
onComplete UnityAction<Tile>
threadId string

GetCenterTile(int)

public Tile GetCenterTile(int zoomLevel)

Parameters

zoomLevel int

Returns

Tile

GetCenterTileAsync(int, UnityAction<Tile>, UnityAction<Exception>)

Asynchronous version of GetCenterTile - runs the query on the ThreadManager and returns on main thread.

public void GetCenterTileAsync(int zoomLevel, UnityAction<Tile> onComplete, UnityAction<Exception> onError = null)

Parameters

zoomLevel int
onComplete UnityAction<Tile>
onError UnityAction<Exception>

GetRegionCoverage(MapFile, UnityAction<float>, UnityAction<Exception>)

Asynchronously checks what fraction of region's tiles are already stored in the offline DB. Returns 0.0 (nothing downloaded) to 1.0 (region fully available).

public void GetRegionCoverage(MapFile region, UnityAction<float> onResult, UnityAction<Exception> onError = null)

Parameters

region MapFile
onResult UnityAction<float>
onError UnityAction<Exception>

GetTile(int, int, int, SQLiteConnection)

public static Tile GetTile(int x, int y, int zoomLevel, SQLiteConnection connection)

Parameters

x int
y int
zoomLevel int
connection SQLiteConnection

Returns

Tile

GetTile(Vector2Int, int)

public Tile GetTile(Vector2Int coordinate, int zoomLevel)

Parameters

coordinate Vector2Int
zoomLevel int

Returns

Tile

GetTileAsync(Vector2Int, int, UnityAction<Tile>, UnityAction<Exception>)

Asynchronous version of GetTile - runs the query on a background thread and returns the result on the main thread.

public void GetTileAsync(Vector2Int coordinate, int zoomLevel, UnityAction<Tile> onComplete, UnityAction<Exception> onError = null)

Parameters

coordinate Vector2Int
zoomLevel int
onComplete UnityAction<Tile>
onError UnityAction<Exception>

HasCachedTile(Vector2Int, out Tile, bool)

public bool HasCachedTile(Vector2Int coordinate, out Tile tile, bool withLabels)

Parameters

coordinate Vector2Int
tile Tile
withLabels bool

Returns

bool

IsRegionAvailable(string, Action<bool>, UnityAction<Exception>)

Looks up regionName in Regions then checks availability. Calls onResult with false if the name is not in the catalog.

public void IsRegionAvailable(string regionName, Action<bool> onResult, UnityAction<Exception> onError = null)

Parameters

regionName string
onResult Action<bool>
onError UnityAction<Exception>

IsRegionAvailable(MapFile, Action<bool>, UnityAction<Exception>)

Asynchronously checks whether region is fully available offline. Calls onResult with true if coverage is 100%, false otherwise.

public void IsRegionAvailable(MapFile region, Action<bool> onResult, UnityAction<Exception> onError = null)

Parameters

region MapFile
onResult Action<bool>
onError UnityAction<Exception>

OnDestroy()

Unity lifecycle: clears the static instance reference when this object is destroyed.

protected override void OnDestroy()

RevealDatabaseInFileExplorer()

public void RevealDatabaseInFileExplorer()

StartRegionDownload(MapFile, Action<float>, Action, Action)

Starts downloading all tiles for region into the unified offline DB. Only missing tiles are fetched — already-downloaded tiles are skipped automatically.

public void StartRegionDownload(MapFile region, Action<float> onProgress = null, Action onComplete = null, Action onCancelled = null)

Parameters

region MapFile

Region bounds and zoom range to download.

onProgress Action<float>

Called every frame with 0–1 progress while downloading.

onComplete Action

Called once when all tiles have been saved.

onCancelled Action

Called if the download is cancelled via CancelRegionDownload().

StartStreamFetch(List<Vector2Int>, int, bool)

public void StartStreamFetch(List<Vector2Int> enqueuedTiles, int zoomLevel, bool showLabels)

Parameters

enqueuedTiles List<Vector2Int>
zoomLevel int
showLabels bool