Client LuaCsForBarotrauma
CompletedTutorials.cs
1 #nullable enable
2 using System.Collections.Generic;
3 using System.Xml.Linq;
4 
5 namespace Barotrauma
6 {
7  public class CompletedTutorials
8  {
9  private readonly HashSet<Identifier> identifiers = new HashSet<Identifier>();
10 
11  private CompletedTutorials() { }
12 
13  private CompletedTutorials(XElement element)
14  {
15  foreach (XElement subElement in element.Elements())
16  {
17  identifiers.Add(subElement.GetAttributeIdentifier("name", Identifier.Empty));
18  }
19  }
20 
21  public static void Init(XElement? element)
22  {
23  if (element is null) { return; }
24 
25  Instance = new CompletedTutorials(element);
26  }
27 
28  public void SaveTo(XElement element)
29  {
30  foreach (var id in identifiers)
31  {
32  element.Add(new XElement("Tutorial", new XAttribute("name", id.Value)));
33  }
34  }
35 
36  public bool Contains(Identifier identifier) => identifiers.Contains(identifier);
37 
38  public void Add(Identifier identifier) => identifiers.Add(identifier);
39 
40  public void Remove(Identifier identifier) => identifiers.Remove(identifier);
41 
42  public static CompletedTutorials Instance { get; private set; } = new CompletedTutorials();
43  }
44 }
static CompletedTutorials Instance
void Add(Identifier identifier)
static void Init(XElement? element)
void SaveTo(XElement element)
bool Contains(Identifier identifier)
void Remove(Identifier identifier)