Class ModFileManifestModel
- Namespace
- LlamaLogic.Packages.Models.ModFileManifest
- Assembly
- LlamaLogic.Packages.dll
Represents a mod file manifest SnippetTuning resource (🔓)
public sealed class ModFileManifestModel : Model, IModel<ModFileManifestModel>, IModel, IXmlSerializable
- Inheritance
-
ModFileManifestModel
- Implements
- Inherited Members
Remarks
This model allows callers to easily create, read, and update a mod file manifest. These manifests are a format sponsored by the Llama Logic team to permit creators to specify the dependency requirements of their mods.
Use in Mod Package (.package
) files
When originally creating packages, place one and only one mod file manifest SnippetTuning resource in the package and use sufficiently unique values for its FullInstance and TuningName. If an external application encounters multiple SnippetTuning manifest resources in a package, it must assume that a manifest un-aware tool has merged multiple manifested packages and process each manifest accordingly.
Avoid using Group 0x00000000
as this is informally reserved for Maxis.
It would be a bizarre miracle if they started incorporating dependency information using a community format.
Regardless, let's not make them feel unwelcome and hold their spot for them.
Use in Script Mod Archive (.ts4script
) files
Because these files are just ZIP archives with a different extension and their contents are not flatly merged by the game as the contents of package files are, there is no risk of collision.
Also, since they need not contend with game resource management, they need not be in an arcane format like XML, so they are in YAML instead.
The static parsing methods of this type expect YAML representations of manifests and the ToString() method produces them.
Name your mod file manifest resource llamalogic.modfilemanifest.yml
and put it in the root of your .ts4script
archive.
Properties
ContactEmail
Gets/sets the email address which can be used to contact this mod's creator
[YamlMember(Order = 6, DefaultValuesHandling = DefaultValuesHandling.OmitNull)]
public string? ContactEmail { get; set; }
Property Value
ContactUrl
Gets/sets the URL which can be used to contact this mod's creator
[YamlMember(Order = 7, DefaultValuesHandling = DefaultValuesHandling.OmitNull)]
public Uri? ContactUrl { get; set; }
Property Value
Creators
Gets the names of the creators of the mod
[YamlMember(Order = 3, DefaultValuesHandling = DefaultValuesHandling.OmitEmptyCollections)]
public Collection<string> Creators { get; }
Property Value
Description
Gets/sets the description of the mod
[YamlMember(Order = 2, DefaultValuesHandling = DefaultValuesHandling.OmitNull)]
public string? Description { get; set; }
Property Value
ElectronicArtsPromoCode
Gets/sets the promo code it is suggested the player use during check out in the EA Store if purchasing a pack for use with this mod
[YamlMember(Order = 18, DefaultValuesHandling = DefaultValuesHandling.OmitNull)]
public string? ElectronicArtsPromoCode { get; set; }
Property Value
Exclusivities
Gets the globally unique names of the exclusivities of this mod, causing it to be incompatible with other mods which share one or more of them
[YamlMember(Order = 16, DefaultValuesHandling = DefaultValuesHandling.OmitEmptyCollections)]
public Collection<string> Exclusivities { get; }
Property Value
Features
Gets the names of the features unique to this mod which it offers to other mods as a dependency
[YamlMember(Order = 15, DefaultValuesHandling = DefaultValuesHandling.OmitEmptyCollections)]
public Collection<string> Features { get; }
Property Value
Hash
Gets/sets the hash of the mod file
[YamlMember(Order = 12, DefaultValuesHandling = DefaultValuesHandling.OmitEmptyCollections)]
public ImmutableArray<byte> Hash { get; set; }
Property Value
HashResourceKeys
Gets the resource keys for the resources included in the Hash
[YamlMember(Order = 13, DefaultValuesHandling = DefaultValuesHandling.OmitEmptyCollections)]
public HashSet<ResourceKey> HashResourceKeys { get; }
Property Value
IncompatiblePacks
Gets the list of pack codes identifying the packs incompatible with this mod (e.g. "EP01" for Get to Work)
[YamlMember(Order = 19, DefaultValuesHandling = DefaultValuesHandling.OmitEmptyCollections)]
public Collection<string> IncompatiblePacks { get; }
Property Value
MessageToTranslators
Gets/sets the message to translators by this mod's creator
[YamlMember(Order = 9, DefaultValuesHandling = DefaultValuesHandling.OmitNull)]
public string? MessageToTranslators { get; set; }
Property Value
Name
Gets/sets the name of the mod
[YamlMember(Order = 1, DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public required string Name { get; set; }
Property Value
RepurposedLanguages
Gets the list of languages repurposed by this mod
[YamlMember(Order = 11, DefaultValuesHandling = DefaultValuesHandling.OmitEmptyCollections)]
public Collection<ModFileManifestModelRepurposedLanguage> RepurposedLanguages { get; }
Property Value
RequiredMods
Gets the list of mods required by this mod
[YamlMember(Order = 20, DefaultValuesHandling = DefaultValuesHandling.OmitEmptyCollections)]
public Collection<ModFileManifestModelRequiredMod> RequiredMods { get; }
Property Value
RequiredPacks
Gets the list of pack codes identifying the packs required by this mod (e.g. "EP01" for Get to Work)
[YamlMember(Order = 17, DefaultValuesHandling = DefaultValuesHandling.OmitEmptyCollections)]
public Collection<string> RequiredPacks { get; }
Property Value
ResourceName
Gets the name of this resource if it has one
[YamlIgnore]
public override string? ResourceName { get; }
Property Value
SubsumedHashes
Gets the hashes of previous versions of this mod in for which I stand even though my hash is different
[YamlMember(Order = 14, DefaultValuesHandling = DefaultValuesHandling.OmitEmptyCollections)]
public HashSet<ImmutableArray<byte>> SubsumedHashes { get; }
Property Value
SupportedTypes
Gets a list of resource types that this model supports
public static ISet<ResourceType> SupportedTypes { get; }
Property Value
TranslationSubmissionUrl
Gets/sets the URL at which translators may submit translations to this mod's creator
[YamlMember(Order = 10, DefaultValuesHandling = DefaultValuesHandling.OmitNull)]
public Uri? TranslationSubmissionUrl { get; set; }
Property Value
Translators
Gets the list of translators who have contributed translations to this mod
[YamlMember(Order = 8, DefaultValuesHandling = DefaultValuesHandling.OmitEmptyCollections)]
public Collection<ModFileManifestModelTranslator> Translators { get; }
Property Value
TuningFullInstance
Gets the SnippetTuning decimal conversion of the FullInstance for the mod file manifest
[YamlMember(Order = -2, DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public ulong TuningFullInstance { get; set; }
Property Value
TuningName
Gets the SnippetTuning name for the mod file manifest
[YamlMember(Order = -1, DefaultValuesHandling = DefaultValuesHandling.OmitNull)]
public string? TuningName { get; set; }
Property Value
Url
Gets/sets the URL to which players can go to find more information about this mod
[YamlMember(Order = 5, DefaultValuesHandling = DefaultValuesHandling.OmitNull)]
public Uri? Url { get; set; }
Property Value
Version
Gets/sets the version of this mod
[YamlMember(Order = 4, DefaultValuesHandling = DefaultValuesHandling.OmitNull)]
public string? Version { get; set; }
Property Value
Methods
Decode(ReadOnlyMemory<byte>)
Decodes the resource in raw format to produce an operable model (🔄️🏃)
public static ModFileManifestModel Decode(ReadOnlyMemory<byte> data)
Parameters
data
ReadOnlyMemory<byte>
Returns
DeleteModFileManifest(ZipArchive)
Deletes all mod file manifest resources in the specified scriptMod
[Obsolete("This method will be removed in a future version. Call DeleteModFileManifests instead.")]
public static void DeleteModFileManifest(ZipArchive scriptMod)
Parameters
scriptMod
ZipArchive
DeleteModFileManifests(DataBasePackedFile)
Deletes all mod file manifest resources in the specified package
public static void DeleteModFileManifests(DataBasePackedFile package)
Parameters
package
DataBasePackedFile
DeleteModFileManifests(ZipArchive)
Deletes all mod file manifest resources in the specified scriptMod
public static void DeleteModFileManifests(ZipArchive scriptMod)
Parameters
scriptMod
ZipArchive
DeleteModFileManifestsAsync(DataBasePackedFile)
Deletes all mod file manifest resources in the specified package
, asynchronously
public static Task DeleteModFileManifestsAsync(DataBasePackedFile package)
Parameters
package
DataBasePackedFile
Returns
Encode()
Encodes the resource model into raw format (🔄️🏃)
public override ReadOnlyMemory<byte> Encode()
Returns
GetFileSha256Hash(string)
Gets the SHA 256 hash of the content of the file located at filePath
public static ImmutableArray<byte> GetFileSha256Hash(string filePath)
Parameters
filePath
string
Returns
GetFileSha256HashAsync(string, CancellationToken)
Gets the SHA 256 hash of the content of the file located at filePath
asynchronously
public static Task<ImmutableArray<byte>> GetFileSha256HashAsync(string filePath, CancellationToken cancellationToken = default)
Parameters
filePath
stringcancellationToken
CancellationToken
Returns
GetModFileHash(DataBasePackedFile, HashSet<ResourceKey>)
Gets the hash for the specified package
using the specified hashResourceKeys
public static ImmutableArray<byte> GetModFileHash(DataBasePackedFile package, HashSet<ResourceKey> hashResourceKeys)
Parameters
package
DataBasePackedFilehashResourceKeys
HashSet<ResourceKey>
Returns
GetModFileHash(ZipArchive)
Gets the hash for the specified scriptMod
public static ImmutableArray<byte> GetModFileHash(ZipArchive scriptMod)
Parameters
scriptMod
ZipArchive
Returns
GetModFileHashAsync(DataBasePackedFile, HashSet<ResourceKey>, CancellationToken)
Gets the hash for the specified package
using the specified hashResourceKeys
, asynchronously
public static Task<ImmutableArray<byte>> GetModFileHashAsync(DataBasePackedFile package, HashSet<ResourceKey> hashResourceKeys, CancellationToken cancellationToken = default)
Parameters
package
DataBasePackedFilehashResourceKeys
HashSet<ResourceKey>cancellationToken
CancellationToken
Returns
GetModFileManifest(DataBasePackedFile)
Gets the mod file manifest for the specified package
, if it has one
public static ModFileManifestModel? GetModFileManifest(DataBasePackedFile package)
Parameters
package
DataBasePackedFile
Returns
GetModFileManifest(ZipArchive)
Gets the mod file manifest for the specified scriptMod
, if it has one
public static ModFileManifestModel? GetModFileManifest(ZipArchive scriptMod)
Parameters
scriptMod
ZipArchive
Returns
GetModFileManifestAndKey(DataBasePackedFile)
Gets the mod file manifest for the specified package
and its ResourceKey, if the package
has one
public static (ResourceKey, ModFileManifestModel?) GetModFileManifestAndKey(DataBasePackedFile package)
Parameters
package
DataBasePackedFile
Returns
GetModFileManifestAndKeyAsync(DataBasePackedFile)
Gets the mod file manifest for the specified package
, asynchronously, if the package
has one
public static Task<(ResourceKey, ModFileManifestModel?)> GetModFileManifestAndKeyAsync(DataBasePackedFile package)
Parameters
package
DataBasePackedFile
Returns
GetModFileManifestAsync(DataBasePackedFile)
Gets the mod file manifest for the specified package
, asynchronously, if it has one
public static Task<ModFileManifestModel?> GetModFileManifestAsync(DataBasePackedFile package)
Parameters
package
DataBasePackedFile
Returns
GetModFileManifestAsync(ZipArchive)
Gets the mod file manifest for the specified scriptMod
, asynchronously, if it has one
public static Task<ModFileManifestModel?> GetModFileManifestAsync(ZipArchive scriptMod)
Parameters
scriptMod
ZipArchive
Returns
GetModFileManifests(DataBasePackedFile)
Gets the mod file manifests for the specified package
(for use by editors checking for packages which may have been merged by manifest unaware tooling)
public static IReadOnlyDictionary<ResourceKey, ModFileManifestModel> GetModFileManifests(DataBasePackedFile package)
Parameters
package
DataBasePackedFile
Returns
GetModFileManifestsAsync(DataBasePackedFile)
Gets the mod file manifests for the specified package
, asynchronously (for use by editors checking for packages which may have been merged by manifest unaware tooling)
public static Task<IReadOnlyDictionary<ResourceKey, ModFileManifestModel>> GetModFileManifestsAsync(DataBasePackedFile package)
Parameters
package
DataBasePackedFile
Returns
GetName(Stream)
Gets the name of a resource from its raw data, if it has one (🔄️💤)
public static string? GetName(Stream stream)
Parameters
stream
Stream
Returns
GetNameAsync(Stream, CancellationToken)
Gets the name of a resource from its raw data, if it has one, asynchronously (🔄️💤)
public static Task<string?> GetNameAsync(Stream stream, CancellationToken cancellationToken = default)
Parameters
stream
StreamcancellationToken
CancellationToken
Returns
Parse(string)
Parses a string into a ModFileManifestModel
public static ModFileManifestModel Parse(string s)
Parameters
s
stringThe string to parse
Returns
Exceptions
- FormatException
s
is not in the correct format
Parse(string, IFormatProvider?)
Parses a string into a ModFileManifestModel
public static ModFileManifestModel Parse(string s, IFormatProvider? provider)
Parameters
s
stringThe string to parse
provider
IFormatProviderAn object that provides culture-specific formatting information about
s
Returns
Exceptions
- FormatException
s
is not in the correct format
SetModFileManifest(DataBasePackedFile, ModFileManifestModel)
Set the specified manifest
for the specified package
public static void SetModFileManifest(DataBasePackedFile package, ModFileManifestModel manifest)
Parameters
package
DataBasePackedFilemanifest
ModFileManifestModel
SetModFileManifest(ZipArchive, ModFileManifestModel)
Set the specified manifest
for the specified scriptMod
public static void SetModFileManifest(ZipArchive scriptMod, ModFileManifestModel manifest)
Parameters
scriptMod
ZipArchivemanifest
ModFileManifestModel
SetModFileManifestAsync(DataBasePackedFile, ModFileManifestModel)
Set the specified manifest
for the specified package
, asynchronously
public static Task SetModFileManifestAsync(DataBasePackedFile package, ModFileManifestModel manifest)
Parameters
package
DataBasePackedFilemanifest
ModFileManifestModel
Returns
SetModFileManifestAsync(ZipArchive, ModFileManifestModel)
Set the specified manifest
for the specified scriptMod
, asynchronously
public static Task SetModFileManifestAsync(ZipArchive scriptMod, ModFileManifestModel manifest)
Parameters
scriptMod
ZipArchivemanifest
ModFileManifestModel
Returns
ToString()
Generates the YAML representation of the ModFileManifestModel
public override string ToString()
Returns
TryParse(string?, out ModFileManifestModel)
Tries to parse a string into a ModFileManifestModel
public static bool TryParse(string? s, out ModFileManifestModel result)
Parameters
s
stringThe string to parse
result
ModFileManifestModelWhen this method returns, contains the result of successfully parsing
s
or an undefined value on failure
Returns
TryParse(string?, IFormatProvider?, out ModFileManifestModel)
Tries to parse a string into a ResourceKey
public static bool TryParse(string? s, IFormatProvider? provider, out ModFileManifestModel result)
Parameters
s
stringThe string to parse
provider
IFormatProviderAn object that provides culture-specific formatting information about
s
result
ModFileManifestModelWhen this method returns, contains the result of successfully parsing
s
or an undefined value on failure