Client LuaCsForBarotrauma
SoundsFile.cs
1 using System;
2 using System.Collections.Immutable;
3 using System.Reflection;
4 using System.Xml.Linq;
5 
6 namespace Barotrauma
7 {
8  [RequiredByCorePackage]
9 #if CLIENT
10  sealed class SoundsFile : GenericPrefabFile<SoundPrefab>
11  {
12  public SoundsFile(ContentPackage contentPackage, ContentPath path) : base(contentPackage, path) { }
13 
15 
16  protected override SoundPrefab CreatePrefab(ContentXElement element)
17  {
18  var elemName = element.NameAsIdentifier();
19  if (SoundPrefab.TagToDerivedPrefab.ContainsKey(elemName))
20  {
21  return Activator.CreateInstance(SoundPrefab.TagToDerivedPrefab[elemName], new object[] { element, this }) as SoundPrefab;
22  }
23  return new SoundPrefab(element, this);
24  }
25 
26  protected override bool MatchesPlural(Identifier identifier) => identifier == "sounds";
27 
28  protected override bool MatchesSingular(Identifier identifier) => !MatchesPlural(identifier);
29 
30  public override Md5Hash CalculateHash() => Md5Hash.Blank;
31  }
32 #else
33  sealed class SoundsFile : OtherFile
34  {
35  public SoundsFile(ContentPackage contentPackage, ContentPath path) : base(contentPackage, path) { }
36  }
37 #endif
38 }
Identifier NameAsIdentifier()
static readonly Md5Hash Blank
Definition: Md5Hash.cs:14
static readonly PrefabCollection< SoundPrefab > Prefabs
Definition: SoundPrefab.cs:88
static readonly ImmutableDictionary< Identifier, Type > TagToDerivedPrefab
Definition: SoundPrefab.cs:84
override PrefabCollection< SoundPrefab > Prefabs
Definition: SoundsFile.cs:14
SoundsFile(ContentPackage contentPackage, ContentPath path)
Definition: SoundsFile.cs:12
override Md5Hash CalculateHash()
override SoundPrefab CreatePrefab(ContentXElement element)
Definition: SoundsFile.cs:16
override bool MatchesSingular(Identifier identifier)
override bool MatchesPlural(Identifier identifier)