Barotrauma Client Doc
Barotrauma.ContentPackage Class Reference
Inheritance diagram for Barotrauma.ContentPackage:
Barotrauma.CorePackage Barotrauma.RegularPackage

Public Types

enum class  LoadResult { Success , Failure }
 

Public Member Functions

readonly record struct LoadError (string Message, Exception? Exception)
 
async Task< bool > IsUpToDate ()
 
bool HashMismatches (string expectedHash)
 
IEnumerable< T > GetFiles< T > ()
 
IEnumerable< ContentFileGetFiles (Type type)
 
bool NameMatches (Identifier name)
 
bool NameMatches (string name)
 
Md5Hash CalculateHash (bool logging=false, string? name=null, string? modVersion=null)
 
void LoadFilesOfType< T > ()
 
void UnloadFilesOfType< T > ()
 
LoadResult LoadContent ()
 
IEnumerable< ContentPackageManager.LoadProgress > LoadContentEnumerable ()
 
void UnloadContent ()
 
void ReloadSubsAndItemAssemblies ()
 
void LogErrors ()
 

Static Public Member Functions

static Result< ContentPackage, Exception > TryLoad (string path)
 
static bool PathAllowedAsLocalModFile (string path)
 

Public Attributes

readonly string Name
 
readonly ImmutableArray< string > AltNames
 
readonly string Path
 
readonly Option< ContentPackageIdUgcId
 
readonly Version GameVersion
 
readonly string ModVersion
 
readonly Option< SerializableDateTimeInstallTime
 

Static Public Attributes

static readonly Version MinimumHashCompatibleVersion = new Version(1, 1, 0, 0)
 
const string LocalModsDir = "LocalMods"
 
static readonly string WorkshopModsDir
 
const string FileListFileName = "filelist.xml"
 
const string DefaultModVersion = "1.0.0"
 

Protected Member Functions

 ContentPackage (XDocument doc, string path)
 
void AssertCondition (bool condition, string errorMsg)
 

Properties

string Dir [get]
 
Md5Hash Hash [get]
 
ImmutableArray< ContentFileFiles [get]
 
ImmutableArray< LoadErrorFatalLoadErrors [get]
 Errors that occurred when loading this content package. Currently, all errors are considered fatal and the game will refuse to load a content package that has any errors. More...
 
Option< ContentPackageManager.LoadProgress.Error > EnableError [get]
 An error that occurred when trying to enable this mod. This field doesn't directly affect whether or not this mod can be enabled, but if it's been set to anything other than Option.None then the game has already refused to enable it at least once. More...
 
bool HasAnyErrors [get]
 
int Index [get]
 
bool HasMultiplayerSyncedContent [get]
 Does the content package include some content that needs to match between all players in multiplayer. More...
 

Detailed Description

Definition at line 15 of file ContentPackage.cs.

Member Enumeration Documentation

◆ LoadResult

Enumerator
Success 
Failure 

Definition at line 243 of file ContentPackage.cs.

Constructor & Destructor Documentation

◆ ContentPackage()

Barotrauma.ContentPackage.ContentPackage ( XDocument  doc,
string  path 
)
protected

Definition at line 87 of file ContentPackage.cs.

Member Function Documentation

◆ AssertCondition()

void Barotrauma.ContentPackage.AssertCondition ( bool  condition,
string  errorMsg 
)
protected

Definition at line 225 of file ContentPackage.cs.

◆ CalculateHash()

Md5Hash Barotrauma.ContentPackage.CalculateHash ( bool  logging = false,
string?  name = null,
string?  modVersion = null 
)

Definition at line 181 of file ContentPackage.cs.

◆ GetFiles()

IEnumerable<ContentFile> Barotrauma.ContentPackage.GetFiles ( Type  type)

◆ GetFiles< T >()

IEnumerable<T> Barotrauma.ContentPackage.GetFiles< T > ( )
Type Constraints
T :ContentFile 
T :Files.OfType<T>() 

◆ HashMismatches()

bool Barotrauma.ContentPackage.HashMismatches ( string  expectedHash)

◆ IsUpToDate()

async Task<bool> Barotrauma.ContentPackage.IsUpToDate ( )

Definition at line 69 of file ContentPackage.cs.

◆ LoadContent()

LoadResult Barotrauma.ContentPackage.LoadContent ( )

Definition at line 249 of file ContentPackage.cs.

◆ LoadContentEnumerable()

IEnumerable<ContentPackageManager.LoadProgress> Barotrauma.ContentPackage.LoadContentEnumerable ( )

Definition at line 258 of file ContentPackage.cs.

◆ LoadError()

readonly record struct Barotrauma.ContentPackage.LoadError ( string  Message,
Exception?  Exception 
)

Definition at line 17 of file ContentPackage.cs.

◆ LoadFilesOfType< T >()

void Barotrauma.ContentPackage.LoadFilesOfType< T > ( )
Type Constraints
T :ContentFile 

Definition at line 233 of file ContentPackage.cs.

◆ LogErrors()

void Barotrauma.ContentPackage.LogErrors ( )

Definition at line 385 of file ContentPackage.cs.

◆ NameMatches() [1/2]

bool Barotrauma.ContentPackage.NameMatches ( Identifier  name)

◆ NameMatches() [2/2]

bool Barotrauma.ContentPackage.NameMatches ( string  name)

◆ PathAllowedAsLocalModFile()

static bool Barotrauma.ContentPackage.PathAllowedAsLocalModFile ( string  path)
static

Definition at line 366 of file ContentPackage.cs.

◆ ReloadSubsAndItemAssemblies()

void Barotrauma.ContentPackage.ReloadSubsAndItemAssemblies ( )

Definition at line 334 of file ContentPackage.cs.

◆ TryLoad()

static Result<ContentPackage, Exception> Barotrauma.ContentPackage.TryLoad ( string  path)
static

Definition at line 163 of file ContentPackage.cs.

◆ UnloadContent()

void Barotrauma.ContentPackage.UnloadContent ( )

Definition at line 329 of file ContentPackage.cs.

◆ UnloadFilesOfType< T >()

void Barotrauma.ContentPackage.UnloadFilesOfType< T > ( )
Type Constraints
T :ContentFile 

Definition at line 238 of file ContentPackage.cs.

Member Data Documentation

◆ AltNames

readonly ImmutableArray<string> Barotrauma.ContentPackage.AltNames

Definition at line 38 of file ContentPackage.cs.

◆ DefaultModVersion

const string Barotrauma.ContentPackage.DefaultModVersion = "1.0.0"
static

Definition at line 35 of file ContentPackage.cs.

◆ FileListFileName

const string Barotrauma.ContentPackage.FileListFileName = "filelist.xml"
static

Definition at line 34 of file ContentPackage.cs.

◆ GameVersion

readonly Version Barotrauma.ContentPackage.GameVersion

Definition at line 43 of file ContentPackage.cs.

◆ InstallTime

readonly Option<SerializableDateTime> Barotrauma.ContentPackage.InstallTime

Definition at line 46 of file ContentPackage.cs.

◆ LocalModsDir

const string Barotrauma.ContentPackage.LocalModsDir = "LocalMods"
static

Definition at line 28 of file ContentPackage.cs.

◆ MinimumHashCompatibleVersion

readonly Version Barotrauma.ContentPackage.MinimumHashCompatibleVersion = new Version(1, 1, 0, 0)
static

Definition at line 26 of file ContentPackage.cs.

◆ ModVersion

readonly string Barotrauma.ContentPackage.ModVersion

Definition at line 44 of file ContentPackage.cs.

◆ Name

readonly string Barotrauma.ContentPackage.Name

Definition at line 37 of file ContentPackage.cs.

◆ Path

readonly string Barotrauma.ContentPackage.Path

Definition at line 39 of file ContentPackage.cs.

◆ UgcId

readonly Option<ContentPackageId> Barotrauma.ContentPackage.UgcId

Definition at line 41 of file ContentPackage.cs.

◆ WorkshopModsDir

readonly string Barotrauma.ContentPackage.WorkshopModsDir
static
Initial value:
= Barotrauma.IO.Path.Combine(
SaveUtil.DefaultSaveFolder,
"WorkshopMods",
"Installed")

Definition at line 29 of file ContentPackage.cs.

Property Documentation

◆ Dir

string Barotrauma.ContentPackage.Dir
get

Definition at line 40 of file ContentPackage.cs.

◆ EnableError

Option<ContentPackageManager.LoadProgress.Error> Barotrauma.ContentPackage.EnableError
get

An error that occurred when trying to enable this mod. This field doesn't directly affect whether or not this mod can be enabled, but if it's been set to anything other than Option.None then the game has already refused to enable it at least once.

Definition at line 64 of file ContentPackage.cs.

◆ FatalLoadErrors

ImmutableArray<LoadError> Barotrauma.ContentPackage.FatalLoadErrors
get

Errors that occurred when loading this content package. Currently, all errors are considered fatal and the game will refuse to load a content package that has any errors.

Definition at line 55 of file ContentPackage.cs.

◆ Files

ImmutableArray<ContentFile> Barotrauma.ContentPackage.Files
get

Definition at line 48 of file ContentPackage.cs.

◆ HasAnyErrors

bool Barotrauma.ContentPackage.HasAnyErrors
get

Definition at line 67 of file ContentPackage.cs.

◆ Hash

Md5Hash Barotrauma.ContentPackage.Hash
get

Definition at line 45 of file ContentPackage.cs.

◆ HasMultiplayerSyncedContent

bool Barotrauma.ContentPackage.HasMultiplayerSyncedContent
get

Does the content package include some content that needs to match between all players in multiplayer.

Definition at line 85 of file ContentPackage.cs.

◆ Index

int Barotrauma.ContentPackage.Index
get

Definition at line 80 of file ContentPackage.cs.