diff --git a/ClassicalSharp/2D/Screens/FpsScreen.cs b/ClassicalSharp/2D/Screens/FpsScreen.cs index abf5b15c7..2572f5584 100644 --- a/ClassicalSharp/2D/Screens/FpsScreen.cs +++ b/ClassicalSharp/2D/Screens/FpsScreen.cs @@ -123,6 +123,7 @@ namespace ClassicalSharp.Gui { posFont.Dispose(); fpsText.Dispose(); api.DeleteTexture( ref posTex ); + hackStates.Dispose(); game.Events.ChatFontChanged -= ChatFontChanged; } diff --git a/ClassicalSharp/Entities/EntityList.cs b/ClassicalSharp/Entities/EntityList.cs index 7d0ac0bc9..2f0963e33 100644 --- a/ClassicalSharp/Entities/EntityList.cs +++ b/ClassicalSharp/Entities/EntityList.cs @@ -120,6 +120,8 @@ namespace ClassicalSharp.Entities { } game.Events.ChatFontChanged -= ChatFontChanged; game.Events.TextureChanged -= TextureChanged; + if( ShadowComponent.shadowTex > 0 ) + game.Graphics.DeleteTexture( ref ShadowComponent.shadowTex ); } public byte GetClosetPlayer( Player src ) { diff --git a/ClassicalSharp/Game/Game.cs b/ClassicalSharp/Game/Game.cs index bc6fe5ea7..b922b211b 100644 --- a/ClassicalSharp/Game/Game.cs +++ b/ClassicalSharp/Game/Game.cs @@ -67,7 +67,7 @@ namespace ClassicalSharp { ETags.Load(); InputHandler = new InputHandler( this ); defaultIb = Graphics.MakeDefaultIb(); - ParticleManager = new ParticleManager( this ); + ParticleManager = AddComponent( new ParticleManager() ); LoadOptions(); LoadGuiOptions(); Chat = AddComponent( new Chat() ); @@ -516,14 +516,11 @@ namespace ClassicalSharp { public void Dispose() { MapRenderer.Dispose(); - MapBordersRenderer.Dispose(); - EnvRenderer.Dispose(); SetNewScreen( null ); fpsScreen.Dispose(); TerrainAtlas.Dispose(); TerrainAtlas1D.Dispose(); ModelCache.Dispose(); - ParticleManager.Dispose(); Players.Dispose(); WorldEvents.OnNewMap -= OnNewMapCore; WorldEvents.OnNewMapLoaded -= OnNewMapLoadedCore; @@ -533,13 +530,14 @@ namespace ClassicalSharp { if( activeScreen != null ) activeScreen.Dispose(); - Graphics.DeleteIb( defaultIb ); - Graphics.Dispose(); + Graphics.DeleteIb( defaultIb ); Drawer2D.DisposeInstance(); Graphics.DeleteTexture( ref CloudsTex ); Graphics.DeleteTexture( ref GuiTex ); Graphics.DeleteTexture( ref GuiClassicTex ); Graphics.DeleteTexture( ref IconsTex ); + Graphics.Dispose(); + foreach( WarningScreen screen in WarningOverlays ) screen.Dispose(); diff --git a/ClassicalSharp/Particles/ParticleManager.cs b/ClassicalSharp/Particles/ParticleManager.cs index 2ebf03d9b..0bd08ba72 100644 --- a/ClassicalSharp/Particles/ParticleManager.cs +++ b/ClassicalSharp/Particles/ParticleManager.cs @@ -4,7 +4,7 @@ using ClassicalSharp.GraphicsAPI; namespace ClassicalSharp.Particles { - public partial class ParticleManager : IDisposable { + public partial class ParticleManager : IGameComponent { public int ParticlesTexId; TerrainParticle[] terrainParticles = new TerrainParticle[maxParticles]; @@ -15,13 +15,18 @@ namespace ClassicalSharp.Particles { Game game; Random rnd = new Random(); int vb; - const int maxParticles = 600; - - public ParticleManager( Game game ) { - this.game = game; - vb = game.Graphics.CreateDynamicVb( VertexFormat.P3fT2fC4b, maxParticles * 4 ); - game.Events.TerrainAtlasChanged += TerrainAtlasChanged; + const int maxParticles = 600; + + public void Init( Game game ) { + this.game = game; + vb = game.Graphics.CreateDynamicVb( VertexFormat.P3fT2fC4b, maxParticles * 4 ); + game.Events.TerrainAtlasChanged += TerrainAtlasChanged; } + + public void Ready( Game game ) { } + public void Reset( Game game ) { rainCount = 0; terrainCount = 0; } + public void OnNewMap( Game game ) { rainCount = 0; terrainCount = 0; } + public void OnNewMapLoaded( Game game ) { } void TerrainAtlasChanged( object sender, EventArgs e ) { terrain1DCount = new int[game.TerrainAtlas1D.TexIds.Length];