Client LuaCsForBarotrauma
DecalPrefab.cs
1 using Microsoft.Xna.Framework;
2 using System;
3 using System.Collections.Generic;
4 using System.Xml.Linq;
5 
6 namespace Barotrauma
7 {
9  {
10  public string Name => Identifier.Value;
11 
12  public override void Dispose()
13  {
14  foreach (Sprite spr in Sprites)
15  {
16  spr.Remove();
17  }
18  Sprites.Clear();
19  }
20 
21  public readonly List<Sprite> Sprites;
22 
23  public readonly Color Color;
24 
25  public readonly float LifeTime;
26  public readonly float FadeOutTime;
27  public readonly float FadeInTime;
28 
29  public DecalPrefab(ContentXElement element, DecalsFile file) : base(file, new Identifier(element.Name.LocalName))
30  {
31  Sprites = new List<Sprite>();
32 
33  foreach (var subElement in element.Elements())
34  {
35  if (subElement.Name.ToString().Equals("sprite", StringComparison.OrdinalIgnoreCase))
36  {
37  Sprites.Add(new Sprite(subElement));
38  }
39  }
40 
41  Color = element.GetAttributeColor("color", Color.White);
42 
43  LifeTime = element.GetAttributeFloat("lifetime", 10.0f);
44  FadeOutTime = Math.Min(LifeTime, element.GetAttributeFloat("fadeouttime", 1.0f));
45  FadeInTime = Math.Min(LifeTime - FadeOutTime, element.GetAttributeFloat("fadeintime", 0.0f));
46  }
47  }
48 }
DecalPrefab(ContentXElement element, DecalsFile file)
Definition: DecalPrefab.cs:29
readonly float FadeInTime
Definition: DecalPrefab.cs:27
override void Dispose()
Definition: DecalPrefab.cs:12
readonly Color Color
Definition: DecalPrefab.cs:23
readonly float FadeOutTime
Definition: DecalPrefab.cs:26
readonly List< Sprite > Sprites
Definition: DecalPrefab.cs:21
readonly float LifeTime
Definition: DecalPrefab.cs:25
readonly Identifier Identifier
Definition: Prefab.cs:34
Prefab that has a property serves as a deterministic hash of a prefab's identifier....