Example #1
0
        /// <summary>
        /// Get the bitmap of a block
        /// </summary>
        /// <param name="Id">The Id of the block</param>
        /// <param name="x">The X</param>
        /// <param name="y">The Y</param>
        /// <param name="temp"></param>
        /// <returns></returns>
        public System.Drawing.Bitmap GetBlockBitmap(int Id, int x, int y, bool temp = false)
        {
            if (temp)
            {
                return((System.Drawing.Bitmap)Resources.AllBlocks.GetImage.BitPic.Clone(new System.Drawing.Rectangle(Id * 16, 0, 16, 16), Resources.AllBlocks.GetImage.BitPic.PixelFormat));
            }
            else
            {
                if (!EEBlockBitmaps.ContainsKey(Id))
                {
                    try
                    {
                        EEBlockBitmaps.Store(Id, (System.Drawing.Bitmap)Resources.AllBlocks.GetImage.BitPic.Clone(new System.Drawing.Rectangle(Id * 16, 0, 16, 16), Resources.AllBlocks.GetImage.BitPic.PixelFormat));
                    }
                    catch (OutOfMemoryException e)
                    {
                        Chat.Add("* SYSTEM > ERROR: OUT OF MEMORY. DISABLING ALL MODS, AND RESTARTING. ( " + e.Message + " )");
                        Mod.ModLoader.StopMods(this);
                        EEBlockBitmaps.Clean();

                        EEBlockBitmaps.Store(0, (System.Drawing.Bitmap)Resources.AllBlocks.GetImage.BitPic.Clone(new System.Drawing.Rectangle(0 * 16, 0, 16, 16), Resources.AllBlocks.GetImage.BitPic.PixelFormat));

                        return((System.Drawing.Bitmap)(EEBlockBitmaps.Get(0)));
                    }
                }
                return((System.Drawing.Bitmap)(EEBlockBitmaps.Get(Id)));
            }
        }
Example #2
0
 /// <summary>
 /// Clean the cache
 /// </summary>
 public void CleanCache()
 {
     CacheGetTexture.Clean();
     EEBlocks.Clean();
     EEBlockBitmaps.Clean();
     RectangleCache.Clean();
     Chat.Clear();
 }