Simple refactoring

This commit is contained in:
Pawel Welsberg 2018-03-12 20:03:22 +00:00
parent 0c0072025c
commit c596e2df70
2 changed files with 13 additions and 7 deletions

View File

@ -95,9 +95,7 @@ namespace ClassicalSharp {
public static void Reset(Game game) {
Init();
// TODO: Make this part of TerrainAtlas2D maybe?
using (FastBitmap fastBmp = new FastBitmap(game.TerrainAtlas.AtlasBitmap, true, true))
RecalculateSpriteBB(fastBmp);
game.TerrainAtlas.UpdateState();
}
public static void Init() {

View File

@ -22,10 +22,16 @@ namespace ClassicalSharp {
public void UpdateState(Bitmap bmp) {
AtlasBitmap = bmp;
TileSize = bmp.Width / TilesPerRow;
using (FastBitmap fastBmp = new FastBitmap(bmp, true, true))
BlockInfo.RecalculateSpriteBB(fastBmp);
UpdateState();
}
/// <summary> Updates the underlying atlas bitmap </summary>
public void UpdateState()
{
using (FastBitmap fastBmp = new FastBitmap(AtlasBitmap, true, true))
BlockInfo.RecalculateSpriteBB(fastBmp);
}
/// <summary> Creates a new texture that contains the tile at the specified index. </summary>
public int LoadTextureElement(int index) {
int size = TileSize;
@ -38,7 +44,9 @@ namespace ClassicalSharp {
return game.Graphics.CreateTexture(dst, false, game.Graphics.Mipmaps);
}
}
/// <summary> Disposes of the underlying atlas bitmap and texture. </summary>
public void Dispose() {
if (AtlasBitmap != null)