(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
@@ -172,7 +172,7 @@ namespace Barotrauma
switch (subElement.Name.ToString())
{
case "sprite":
sp.sprite = new Sprite(subElement);
sp.sprite = new Sprite(subElement, lazyLoad: true);
if (subElement.Attribute("sourcerect") == null)
{
DebugConsole.ThrowError("Warning - sprite sourcerect not configured for structure \"" + sp.name + "\"!");
@@ -193,7 +193,7 @@ namespace Barotrauma
sp.sprite.EntityID = sp.identifier;
break;
case "backgroundsprite":
sp.BackgroundSprite = new Sprite(subElement);
sp.BackgroundSprite = new Sprite(subElement, lazyLoad: true);
if (subElement.GetAttributeBool("fliphorizontal", false))
sp.BackgroundSprite.effects = SpriteEffects.FlipHorizontally;