(d9829ac) v0.9.4.0

This commit is contained in:
Regalis
2019-10-24 18:05:42 +02:00
parent 9aa12bcac2
commit b39922a074
319 changed files with 12516 additions and 6815 deletions
@@ -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))