Esempio n. 1
0
        public Texture2D GetLotThumbnail(string shardName, uint lotId)
        {
            //might reintroduce the cache at some point, though with the thumbnails behind cloudflare it's likely not an issue for now.
            var shard    = LoginRegulator.Shards.GetByName(shardName);
            var shardKey = CacheKey.For("shards", shard.Id);
            var thumbKey = CacheKey.Combine(shardKey, "lot_thumbs", lotId);

            if (Cache.ContainsKey(thumbKey))
            {
                try {
                    var thumbData = Cache.Get <byte[]>(thumbKey).Result;
                    var thumb     = ImageLoader.FromStream(GameFacade.GraphicsDevice, new MemoryStream(thumbData));
                    return(thumb);
                }catch (Exception ex)
                {
                    //Handles cases where the cache file got corrupted
                    var thumb = TextureUtils.TextureFromFile(GameFacade.GraphicsDevice, GameFacade.GameFilePath("userdata/houses/defaulthouse.bmp"));
                    TextureUtils.ManualTextureMask(ref thumb, new uint[] { 0xFF000000 });
                    return(thumb);
                }
            }
            else
            {
                var thumb = TextureUtils.TextureFromFile(GameFacade.GraphicsDevice, GameFacade.GameFilePath("userdata/houses/defaulthouse.bmp"));
                TextureUtils.ManualTextureMask(ref thumb, new uint[] { 0xFF000000 });
                return(thumb);
            }
        }