Client LuaCsForBarotrauma
SubmarineFile.cs
1 using System;
2 using System.Security.Cryptography;
3 
4 namespace Barotrauma
5 {
6  public abstract class BaseSubFile : ContentFile
7  {
8  protected BaseSubFile(ContentPackage contentPackage, ContentPath path) : base(contentPackage, path)
9  {
10  using var md5 = MD5.Create();
11  #warning TODO: this doesn't account for collisions, this should probably be using the PrefabCollection class like everything else
12  UintIdentifier = ToolBoxCore.StringToUInt32Hash(Barotrauma.IO.Path.GetFileNameWithoutExtension(path.Value), md5);
13  }
14 
15  public readonly UInt32 UintIdentifier;
16 
17  public override void LoadFile()
18  {
19  SubmarineInfo.RefreshSavedSub(Path.Value);
20  }
21 
22  public override void UnloadFile()
23  {
24  SubmarineInfo.RemoveSavedSub(Path.Value);
25  }
26 
27  public override void Sort()
28  {
29  //Overrides for subs don't exist! Should we change this?
30  }
31 
32  // Use byte-perfect hash because this is compressed, trimming whitespace is incorrect and needlessly slow here
33  public override Md5Hash CalculateHash()
34  => Md5Hash.CalculateForFile(Path.FullPath, Md5Hash.StringHashOptions.BytePerfect);
35  }
36 
38  public class SubmarineFile : BaseSubFile
39  {
40  public SubmarineFile(ContentPackage contentPackage, ContentPath path) : base(contentPackage, path) { }
41  }
42 }
BaseSubFile(ContentPackage contentPackage, ContentPath path)
Definition: SubmarineFile.cs:8
readonly UInt32 UintIdentifier
override void LoadFile()
override void Sort()
override void UnloadFile()
override Md5Hash CalculateHash()
Base class for content file types, which are loaded from filelist.xml via reflection....
Definition: ContentFile.cs:23
string???????????? Value
Definition: ContentPath.cs:27
static Md5Hash CalculateForFile(string path, StringHashOptions options)
Definition: Md5Hash.cs:114
SubmarineFile(ContentPackage contentPackage, ContentPath path)