mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-19 04:26:52 -04:00
Make ParticleManager an IGameComponent, remember to release native textures.
This commit is contained in:
parent
03fab9182e
commit
21e8a34b36
@ -123,6 +123,7 @@ namespace ClassicalSharp.Gui {
|
||||
posFont.Dispose();
|
||||
fpsText.Dispose();
|
||||
api.DeleteTexture( ref posTex );
|
||||
hackStates.Dispose();
|
||||
game.Events.ChatFontChanged -= ChatFontChanged;
|
||||
}
|
||||
|
||||
|
@ -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 ) {
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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];
|
||||
|
Loading…
x
Reference in New Issue
Block a user