(5a377a8ee) Unstable v0.9.1000.0
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user