Table of Contents

Class CombinedTuningModel

Namespace
LlamaLogic.Packages.Models.CombinedTuning
Assembly
LlamaLogic.Packages.dll

Represents a CombinedTuning resource (🔓)

public sealed class CombinedTuningModel : Model, IModel<CombinedTuningModel>, IModel
Inheritance
CombinedTuningModel
Implements
Inherited Members

Remarks

Maxis ships the game's tuning merged into resources of this type, encoded either as a binary packed XML document (a DATA file) or as XML text. Decode(ReadOnlyMemory<byte>) accepts both and presents the merged document as Document. Encode() always produces XML text, written the way Maxis writes it. GetTunings() produces the individual tuning documents the merged document contains.

Constructors

CombinedTuningModel(XDocument)

Initializes a new CombinedTuningModel for the specified document

public CombinedTuningModel(XDocument document)

Parameters

document XDocument

The merged document, the root element of which is <combined>

Properties

Document

Gets the merged document, the root element of which is <combined>

public XDocument Document { get; }

Property Value

XDocument

ResourceName

Gets the name of this resource if it has one

public override string? ResourceName { get; }

Property Value

string

SupportedTypes

Gets a list of resource types that this model supports

public static ISet<ResourceType> SupportedTypes { get; }

Property Value

ISet<ResourceType>

Methods

Decode(ReadOnlyMemory<byte>)

Decodes the resource in raw format to produce an operable model (🔄️🏃)

public static CombinedTuningModel Decode(ReadOnlyMemory<byte> data)

Parameters

data ReadOnlyMemory<byte>

Returns

CombinedTuningModel

Exceptions

InvalidDataException

The data is neither a well-formed binary nor a well-formed XML combined tuning document

Encode()

Encodes the resource model into raw format (🔄️🏃)

public override ReadOnlyMemory<byte> Encode()

Returns

ReadOnlyMemory<byte>

Exceptions

InvalidOperationException

Document has no root element or contains a node that XML combined tuning cannot express

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

string

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 Stream
cancellationToken CancellationToken

Returns

Task<string>

GetTunings()

Gets the individual tuning documents in Document, in document order, with each reference to a shared node (<r x="…">) replaced by a copy of that node (💤)

public IEnumerable<CombinedTuningModelTuning> GetTunings()

Returns

IEnumerable<CombinedTuningModelTuning>

Remarks

The documents are produced as the sequence is enumerated, and are independent of Document and of each other. Modifying Document while enumerating has undefined results.

Exceptions

InvalidDataException

Document is not a well-formed merged document: it lacks the shared node group, a reference names a node that does not exist or contains itself, or a tuning document lacks a valid instance