(5a377a8ee) Unstable v0.9.1000.0

This commit is contained in:
Juan Pablo Arce
2020-05-13 12:55:42 -03:00
parent b143329701
commit a1ca41aa5d
426 changed files with 14384 additions and 5708 deletions
@@ -1,21 +1,38 @@
using System.Collections.Generic;
using System.Xml.Linq;
using System.Linq;
using System;
namespace Barotrauma
{
partial class ConditionalSprite
{
public readonly List<PropertyConditional> conditionals = new List<PropertyConditional>();
public bool IsActive => Target != null && conditionals.All(c => c.Matches(Target));
public bool IsActive
{
get
{
if (Target == null) { return false; }
return Comparison == PropertyConditional.Comparison.And ? conditionals.All(c => c.Matches(Target)) : conditionals.Any(c => c.Matches(Target));
}
}
public readonly PropertyConditional.Comparison Comparison;
public readonly bool Exclusive;
public ISerializableEntity Target { get; private set; }
public Sprite Sprite { get; private set; }
public DeformableSprite DeformableSprite { get; private set; }
public Sprite ActiveSprite => Sprite ?? DeformableSprite.Sprite;
public ConditionalSprite(XElement element, ISerializableEntity target, string path = "", string file = "", bool lazyLoad = false)
public ConditionalSprite(XElement element, ISerializableEntity target, string file = "", bool lazyLoad = false)
{
Target = target;
Exclusive = element.GetAttributeBool("exclusive", Exclusive);
string comparison = element.GetAttributeString("comparison", null);
if (comparison != null)
{
Enum.TryParse(comparison, ignoreCase: true, out Comparison);
}
foreach (XElement subElement in element.Elements())
{
switch (subElement.Name.ToString().ToLowerInvariant())
@@ -30,10 +47,10 @@ namespace Barotrauma
}
break;
case "sprite":
Sprite = new Sprite(subElement, path, file, lazyLoad: lazyLoad);
Sprite = new Sprite(subElement, file: file, lazyLoad: lazyLoad);
break;
case "deformablesprite":
DeformableSprite = new DeformableSprite(subElement, filePath: path, lazyLoad: lazyLoad);
DeformableSprite = new DeformableSprite(subElement, filePath: file, lazyLoad: lazyLoad);
break;
}
}
@@ -18,12 +18,12 @@ namespace Barotrauma
public Sprite Sprite { get; private set; }
public DeformableSprite(XElement element, int? subdivisionsX = null, int? subdivisionsY = null, string filePath = "", bool lazyLoad = false)
public DeformableSprite(XElement element, int? subdivisionsX = null, int? subdivisionsY = null, string filePath = "", bool lazyLoad = false, bool invert = false)
{
Sprite = new Sprite(element, file: filePath, lazyLoad: lazyLoad);
InitProjSpecific(element, subdivisionsX, subdivisionsY, lazyLoad);
InitProjSpecific(element, subdivisionsX, subdivisionsY, lazyLoad, invert);
}
partial void InitProjSpecific(XElement element, int? subdivisionsX, int? subdivisionsY, bool lazyLoad = false);
partial void InitProjSpecific(XElement element, int? subdivisionsX, int? subdivisionsY, bool lazyLoad, bool invert);
}
}
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Xml.Linq;
using System.Linq;
using Barotrauma.Extensions;
using System.IO;
using Barotrauma.IO;
using System;
using SpriteParams = Barotrauma.RagdollParams.SpriteParams;
#if CLIENT
@@ -47,7 +47,11 @@ namespace Barotrauma
//the offset used when drawing the sprite
protected Vector2 offset;
private bool lazyLoad;
public bool LazyLoad
{
get;
private set;
}
protected Vector2 origin;
@@ -108,6 +112,8 @@ namespace Barotrauma
public string FullPath { get; private set; }
public bool Compress { get; private set; }
public override string ToString()
{
return FilePath + ": " + sourceRect;
@@ -135,7 +141,7 @@ namespace Barotrauma
public Sprite(XElement element, string path = "", string file = "", bool lazyLoad = false)
{
if (element == null) { return; }
this.lazyLoad = lazyLoad;
this.LazyLoad = lazyLoad;
SourceElement = element;
if (!ParseTexturePath(path, file)) { return; }
Name = SourceElement.GetAttributeString("name", null);
@@ -145,6 +151,7 @@ namespace Barotrauma
{
sourceVector = overrideElement.GetAttributeVector4("sourcerect", Vector4.Zero);
}
Compress = SourceElement.GetAttributeBool("compress", true);
bool shouldReturn = false;
if (!lazyLoad)
{