Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions Intersect.Client.Core/MonoGame/Graphics/MonoRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -712,11 +712,6 @@ public override void End()
mFpsTimer = Timing.Global.MillisecondsUtc + 1000;
mGameWindow.Title = Strings.Main.GameName;
}

foreach (var texture in mAllTextures)
{
texture?.Update();
}
}

public override int GetFps()
Expand Down Expand Up @@ -913,12 +908,14 @@ public override GameTexture LoadTexture(string filename, string realFilename)
if (packFrame != null)
{
var tx = new MonoTexture(mGraphicsDevice, filename, packFrame);
tx.LoadTexture();
mAllTextures.Add(tx);

return tx;
}

var tex = new MonoTexture(mGraphicsDevice, filename, realFilename);
tex.LoadTexture();
mAllTextures.Add(tex);

return tex;
Expand Down
25 changes: 0 additions & 25 deletions Intersect.Client.Core/MonoGame/Graphics/MonoTexture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,12 @@ public partial class MonoTexture : GameTexture

private readonly GameTexturePackFrame? _packFrame;

private readonly bool _doNotFree;

private int _width = -1;

private Texture2D? _texture;

private int _height = -1;

private long _lastAccessTime;

private bool _loadError;

private MonoTexture(Texture2D texture2D, string assetName) : base(assetName)
Expand All @@ -45,7 +41,6 @@ private MonoTexture(Texture2D texture2D, string assetName) : base(assetName)
_realPath = string.Empty;
_name = assetName;
_texture = texture2D;
_doNotFree = true;
}

public MonoTexture(GraphicsDevice graphicsDevice, string filename, string realPath) : base(
Expand Down Expand Up @@ -160,17 +155,10 @@ public void LoadTexture()
}
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ResetAccessTime()
{
_lastAccessTime = Timing.Global.MillisecondsUtc + 15000;
}

public override int Width
{
get
{
ResetAccessTime();
if (_width != -1)
{
return _width;
Expand All @@ -194,7 +182,6 @@ public override int Height
{
get
{
ResetAccessTime();
if (_height != -1)
{
return _height;
Expand Down Expand Up @@ -222,8 +209,6 @@ public override int Height
return _packFrame.PackTexture.GetTexture();
}

ResetAccessTime();

if (_texture == null)
{
LoadTexture();
Expand Down Expand Up @@ -274,21 +259,11 @@ public override Color GetPixel(int x1, int y1)

public void Update()
{
if (_doNotFree)
{
return;
}

if (_texture == null)
{
return;
}

if (_lastAccessTime >= Timing.Global.MillisecondsUtc)
{
return;
}

_texture.Dispose();
_texture = null;
}
Expand Down
Loading