(03291eb8d) Use the sourcerect of a structure's default sprite for the background sprite if it doesn't define it's own sourcerect

This commit is contained in:
Joonas Rikkonen
2019-04-11 18:24:45 +03:00
parent 266d58ca08
commit b76aa1ff3a
2 changed files with 8 additions and 326 deletions
@@ -194,7 +194,14 @@ namespace Barotrauma
break;
case "backgroundsprite":
sp.BackgroundSprite = new Sprite(subElement, lazyLoad: true);
if (subElement.Attribute("sourcerect") == null && sp.sprite != null)
{
sp.BackgroundSprite.SourceRect = sp.sprite.SourceRect;
sp.BackgroundSprite.size = sp.sprite.size;
sp.BackgroundSprite.size.X *= sp.sprite.SourceRect.Width;
sp.BackgroundSprite.size.Y *= sp.sprite.SourceRect.Height;
sp.BackgroundSprite.RelativeOrigin = subElement.GetAttributeVector2("origin", new Vector2(0.5f, 0.5f));
}
if (subElement.GetAttributeBool("fliphorizontal", false))
sp.BackgroundSprite.effects = SpriteEffects.FlipHorizontally;
if (subElement.GetAttributeBool("flipvertical", false))