50 lines
1.2 KiB
C#
50 lines
1.2 KiB
C#
using Cryville.EEW.Core.Map;
|
|
using System;
|
|
using System.IO;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
|
|
namespace Cryville.EEW.Unity.Map {
|
|
sealed class MapTileBitmapHolder : Core.Map.MapTileBitmapHolder {
|
|
readonly MapTileBitmapHolderBehaviour _behaviour;
|
|
readonly Uri _uri;
|
|
|
|
public MapTileBitmapHolder(MapTileIndex index, GameObject gameObject, Uri uri) : base(index) {
|
|
_behaviour = gameObject.GetComponent<MapTileBitmapHolderBehaviour>();
|
|
_behaviour.Index = index;
|
|
_uri = uri;
|
|
}
|
|
|
|
protected override void Dispose(bool disposing) {
|
|
base.Dispose(disposing);
|
|
if (disposing) {
|
|
if (_behaviour) _behaviour.Destroy();
|
|
}
|
|
}
|
|
|
|
protected override Uri GetUri() => _uri;
|
|
|
|
protected override Task LoadBitmap(FileInfo file, CancellationToken cancellationToken) {
|
|
_behaviour.Load(file);
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
public void Bind(MapTile tile) {
|
|
_behaviour.Bind(tile);
|
|
}
|
|
|
|
public void Unbind(MapTile tile) {
|
|
_behaviour.Unbind(tile);
|
|
}
|
|
|
|
public void AddChild(MapTileBitmapHolder bitmapHolder) {
|
|
_behaviour.AddChild(bitmapHolder._behaviour);
|
|
}
|
|
|
|
public void RemoveChild(MapTileBitmapHolder bitmapHolder) {
|
|
_behaviour.RemoveChild(bitmapHolder._behaviour);
|
|
}
|
|
}
|
|
}
|