using Microsoft.Xna.Framework; using System; using System.Collections.Generic; using System.Xml.Linq; namespace Barotrauma.Particles { class DecalPrefab : IPrefab, IDisposable { public readonly string Name; public string OriginalName { get { return Name; } } private string _identifier; public string Identifier { get { if (_identifier == null) { _identifier = Name.ToLowerInvariant(); } return _identifier; } } public string FilePath { get; private set; } public ContentPackage ContentPackage { get; private set; } public void Dispose() { foreach (Sprite spr in Sprites) { spr.Remove(); } Sprites.Clear(); } public readonly List Sprites; public readonly Color Color; public readonly float LifeTime; public readonly float FadeOutTime; public readonly float FadeInTime; public DecalPrefab(XElement element, ContentFile file) { Name = element.Name.ToString(); FilePath = file.Path; ContentPackage = file.ContentPackage; Sprites = new List(); foreach (XElement subElement in element.Elements()) { if (subElement.Name.ToString().Equals("sprite", StringComparison.OrdinalIgnoreCase)) { Sprites.Add(new Sprite(subElement)); } } Color = new Color(element.GetAttributeVector4("color", Vector4.One)); LifeTime = element.GetAttributeFloat("lifetime", 10.0f); FadeOutTime = Math.Min(LifeTime, element.GetAttributeFloat("fadeouttime", 1.0f)); FadeInTime = Math.Min(LifeTime - FadeOutTime, element.GetAttributeFloat("fadeintime", 0.0f)); } } }