Client LuaCsForBarotrauma
NPCConversationsFile.cs
1 using System.Xml.Linq;
2 
3 namespace Barotrauma
4 {
5  [NotSyncedInMultiplayer]
7  {
8  public NPCConversationsFile(ContentPackage contentPackage, ContentPath path) : base(contentPackage, path) { }
9 
10  public override void LoadFile()
11  {
12  XDocument doc = XMLExtensions.TryLoadXml(Path);
13  if (doc == null) { return; }
14  var mainElement = doc.Root.FromPackage(ContentPackage);
15  bool allowOverriding = doc.Root.IsOverride();
16  if (allowOverriding)
17  {
18  mainElement = mainElement.FirstElement();
19  }
20 
21  var npcConversationCollection = new NPCConversationCollection(this, mainElement);
22  if (!NPCConversationCollection.Collections.ContainsKey(npcConversationCollection.Language))
23  {
24  NPCConversationCollection.Collections.Add(npcConversationCollection.Language, new PrefabCollection<NPCConversationCollection>());
25  }
26  NPCConversationCollection.Collections[npcConversationCollection.Language].Add(npcConversationCollection, allowOverriding);
27  }
28 
29  public override void UnloadFile()
30  {
31  foreach (var collection in NPCConversationCollection.Collections.Values)
32  {
33  collection.RemoveByFile(this);
34  }
35  }
36 
37  public override void Sort()
38  {
39  foreach (var collection in NPCConversationCollection.Collections.Values)
40  {
41  collection.SortAll();
42  }
43  }
44  }
45 }
Base class for content file types, which are loaded from filelist.xml via reflection....
Definition: ContentFile.cs:23
static readonly Dictionary< LanguageIdentifier, PrefabCollection< NPCConversationCollection > > Collections
NPCConversationsFile(ContentPackage contentPackage, ContentPath path)