Ejemplo n.º 1
0
        public static void ExtractDefault(Game game)
        {
            TexturePack extractor = new TexturePack();

            extractor.Extract(game.DefaultTexturePack, game);
            game.World.TextureUrl = null;
        }
Ejemplo n.º 2
0
 public static void ExtractCurrent(Game game, string url)
 {
     if (url == null)
     {
         ExtractDefault(game);
     }
     else if (url.Contains(".zip"))
     {
         TexturePack.ExtractCachedTexturePack(game, url);
     }
     else
     {
         TexturePack.ExtractCachedTerrainPng(game, url);
     }
 }
Ejemplo n.º 3
0
 static void ExtractCachedTexturePack(Game game, string url)
 {
     using (Stream data = TextureCache.GetStream(url)) {
         if (data == null)                   // e.g. 404 errors
         {
             if (game.World.TextureUrl != null)
             {
                 ExtractDefault(game);
             }
         }
         else if (url != game.World.TextureUrl)
         {
             game.World.TextureUrl = url;
             TexturePack extractor = new TexturePack();
             extractor.Extract(data, game);
         }
     }
 }
Ejemplo n.º 4
0
        internal static void ExtractTexturePack(Game game, Request item)
        {
            if (item.Data == null)
            {
                return;
            }
            game.World.TextureUrl = item.Url;
            byte[] data = (byte[])item.Data;

            TextureCache.Add(item.Url, data);
            TextureCache.AddETag(item.Url, item.ETag, game.ETags);
            TextureCache.AdddLastModified(item.Url, item.LastModified, game.LastModified);

            TexturePack extractor = new TexturePack();

            using (Stream ms = new MemoryStream(data)) {
                extractor.Extract(ms, game);
            }
        }