(c445db0f5) Lazy load item & structure sprites (loaded automatically when switching to the sub editor or instantiating an item/structure, so should not cause any mid-game freezes).

This commit is contained in:
Joonas Rikkonen
2019-04-04 11:09:32 +03:00
parent 66fa81bd3d
commit 1966bcb4ab
22 changed files with 133 additions and 584 deletions
@@ -26,6 +26,10 @@ namespace Barotrauma.Items.Components
private float blinkTimer;
private bool itemLoaded;
private float blinkTimer;
public PhysicsBody ParentBody;
[Editable(MinValueFloat = 0.0f, MaxValueFloat = 2048.0f), Serialize(100.0f, true)]
@@ -1613,8 +1613,6 @@ namespace Barotrauma
GameMain.NetworkMember != null && (GameMain.NetworkMember.IsServer || Character.Controlled == dropper))
{
parentInventory.CreateNetworkEvent();
//send frequent updates after the item has been dropped
PositionUpdateInterval = 0.0f;
}
}
@@ -480,7 +480,7 @@ namespace Barotrauma
canSpriteFlipX = subElement.GetAttributeBool("canflipx", true);
canSpriteFlipY = subElement.GetAttributeBool("canflipy", true);
sprite = new Sprite(subElement, spriteFolder);
sprite = new Sprite(subElement, spriteFolder, lazyLoad: true);
if (subElement.Attribute("sourcerect") == null)
{
DebugConsole.ThrowError("Warning - sprite sourcerect not configured for item \"" + Name + "\"!");
@@ -505,7 +505,7 @@ namespace Barotrauma
{
iconFolder = Path.GetDirectoryName(filePath);
}
InventoryIcon = new Sprite(subElement, iconFolder);
InventoryIcon = new Sprite(subElement, iconFolder, lazyLoad: true);
break;
case "brokensprite":
string brokenSpriteFolder = "";
@@ -515,7 +515,7 @@ namespace Barotrauma
}
var brokenSprite = new BrokenItemSprite(
new Sprite(subElement, brokenSpriteFolder),
new Sprite(subElement, brokenSpriteFolder, lazyLoad: true),
subElement.GetAttributeFloat("maxcondition", 0.0f),
subElement.GetAttributeBool("fadein", false));
@@ -541,7 +541,7 @@ namespace Barotrauma
}
else
{
decorativeSprite = new DecorativeSprite(subElement, decorativeSpriteFolder);
decorativeSprite = new DecorativeSprite(subElement, decorativeSpriteFolder, lazyLoad: true);
DecorativeSprites.Add(decorativeSprite);
groupID = decorativeSprite.RandomGroupID;
}
@@ -558,7 +558,7 @@ namespace Barotrauma
{
containedSpriteFolder = Path.GetDirectoryName(filePath);
}
var containedSprite = new ContainedItemSprite(subElement, containedSpriteFolder);
var containedSprite = new ContainedItemSprite(subElement, containedSpriteFolder, lazyLoad: true);
if (containedSprite.Sprite != null)
{
ContainedSprites.Add(containedSprite);