(d9829ac) v0.9.4.0
This commit is contained in:
@@ -9,8 +9,9 @@ namespace Barotrauma
|
||||
{
|
||||
public partial class Sprite
|
||||
{
|
||||
protected Texture2D texture;
|
||||
private bool cannotBeLoaded;
|
||||
|
||||
protected Texture2D texture;
|
||||
public Texture2D Texture
|
||||
{
|
||||
get
|
||||
@@ -56,7 +57,7 @@ namespace Barotrauma
|
||||
|
||||
public void EnsureLazyLoaded()
|
||||
{
|
||||
if (!lazyLoad || texture != null) { return; }
|
||||
if (!lazyLoad || texture != null || cannotBeLoaded) { return; }
|
||||
|
||||
Vector4 sourceVector = Vector4.Zero;
|
||||
bool temp2 = false;
|
||||
@@ -74,6 +75,10 @@ namespace Barotrauma
|
||||
if (s == this) { continue; }
|
||||
if (s.FullPath == FullPath && s.texture != null) { s.texture = texture; }
|
||||
}
|
||||
if (texture == null)
|
||||
{
|
||||
cannotBeLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void ReloadTexture(bool updateAllSprites = false) => ReloadTexture(updateAllSprites ? LoadedSprites.Where(s => s.Texture == texture) : new Sprite[] { this });
|
||||
@@ -93,10 +98,8 @@ namespace Barotrauma
|
||||
sourceRect = new Rectangle(0, 0, texture.Width, texture.Height);
|
||||
}
|
||||
|
||||
|
||||
public static Texture2D LoadTexture(string file, bool preMultiplyAlpha = true)
|
||||
{
|
||||
|
||||
if (string.IsNullOrWhiteSpace(file))
|
||||
{
|
||||
Texture2D t = null;
|
||||
@@ -109,7 +112,7 @@ namespace Barotrauma
|
||||
file = Path.GetFullPath(file);
|
||||
foreach (Sprite s in list)
|
||||
{
|
||||
if (s.FullPath == file && s.texture != null) { return s.texture; }
|
||||
if (s.FullPath == file && s.texture != null && !s.texture.IsDisposed) { return s.texture; }
|
||||
}
|
||||
|
||||
if (File.Exists(file))
|
||||
|
||||
Reference in New Issue
Block a user