using OpenMetaverse;
using UnityEngine;
namespace Raindrop.Map.Model
{
///
/// A DS that represents a maptile in the scene.
/// The implementation assumes 1 sim per tile; 256*256 resolution per tile. Clearly, at further zoom levels we want to squeeze more sims into a single tile.
///
public class MapTile
{
// it seems that a tile from the http is ~ 17KB in JPEG format; making it kind of spammable at the highest zoom level of 4.
//private int size; //in sims.
private Texture2D texture;
private ulong gridHandle;
public bool isReady = false;
//private static Texture2D emptyTexture; //= new Texture2D(Texture2D.blackTexture);
public MapTile(int width, int height)
{
texture = new Texture2D(width, height); //todo: texture factory.
//destroyTex();
}
///
/// get the texture in the tile.
///
///
public Texture2D getTex()
{
return texture;
}
//clear the internal texture and location of the maptile.
public void destroyTex()
{
//texture = emptyTexture; //TODO : have not called Destroy(texture) to free memory.
//UnityEngine.Object.Destroy(texture);
gridHandle = 0;
}
///
/// Set the maptile's handle and texture
///
///
///
private void setTex(Texture2D tex, ulong handle)
{
setTex(tex);
setLoc(handle);
}
//set the internal texture of the maptile.
private void setTex(Texture2D tex)
{
texture = tex;
}
//set the location of sim that the maptile represents.
private void setLoc(ulong handle)
{
gridHandle = handle;
}
//set the location of sim that the maptile represents.
public ulong getLoc()
{
return gridHandle;
}
}
}