Table of Contents

Class SimDataGenerator

Namespace
LlamaLogic.TuningDescriptions
Assembly
LlamaLogic.TuningDescriptions.dll

Generates SimData resources from tuning the way Maxis' build does, using the tuning descriptions of the game version for which they are generated (🔒)

public sealed class SimDataGenerator
Inheritance
SimDataGenerator
Inherited Members

Remarks

Which tunables become columns, the columns' types, and the values written for tuning that omits a tunable all come from Descriptions.

Some of what Maxis' build knows is not in tuning descriptions, so the generator learns it:

  • AddTuning(XDocument) and AddTuning(CombinedTuningModel) learn the entries of dynamic enumerations (such as tags defined by module tuning) and the instances of tuning that is referenced by name
  • AddLayouts(SimDataModel) learns the column order of schemas the game reads with a layout of its own (such as Client_* and Renderer.* schemas), whose columns are otherwise ordered by name

Maxis' build also converts some resource keys: a PNGImage key in tuning is written to SimData as a DSTImage key, and an AudioConfigurationReference key as an AudioConfiguration key in group 0x001407EC. The generator does the same unless RemoveResourceKeyConversion(ResourceType, uint) says otherwise, and AddResourceKeyConversion(ResourceType, uint, ResourceType, uint) adds conversions.

For the game's own SimData, the game's combined tuning and SimData are the sources of what the generator needs to learn.

Constructors

SimDataGenerator(TuningDescriptionSet)

Initializes a new SimDataGenerator

public SimDataGenerator(TuningDescriptionSet descriptions)

Parameters

descriptions TuningDescriptionSet

The tuning descriptions of the game version for which SimData will be generated

Properties

Descriptions

Gets the tuning descriptions of the game version for which SimData is generated

public TuningDescriptionSet Descriptions { get; }

Property Value

TuningDescriptionSet

Methods

AddLayouts(SimDataModel)

Learns the column order of each schema in the specified simData whose columns are not ordered by name

public void AddLayouts(SimDataModel simData)

Parameters

simData SimDataModel

Remarks

When generating an object of a schema with the same name and the same columns, the generator orders the columns as they are ordered in simData.

AddResourceKeyConversion(ResourceType, uint, ResourceType, uint)

Learns that resource keys of the specified fromType and fromGroup in tuning are written to SimData with the specified toType and toGroup

public void AddResourceKeyConversion(ResourceType fromType, uint fromGroup, ResourceType toType, uint toGroup)

Parameters

fromType ResourceType
fromGroup uint
toType ResourceType
toGroup uint

AddTuning(CombinedTuningModel)

Learns the entries of dynamic enumerations and the names of instances from each tuning in the specified combinedTuning

public void AddTuning(CombinedTuningModel combinedTuning)

Parameters

combinedTuning CombinedTuningModel

AddTuning(XDocument)

Learns the entries of dynamic enumerations the specified tuning defines (if it is module tuning) and the name of its instance

public void AddTuning(XDocument tuning)

Parameters

tuning XDocument

Remarks

An instance or enumeration value that is not a decimal number (such as one a modding tool wrote in hexadecimal) is not learned.

Generate(XDocument)

Generates the SimData for the specified tuning

public SimDataModel Generate(XDocument tuning)

Parameters

tuning XDocument

Instance tuning (an I element) or module tuning (an M element)

Returns

SimDataModel

The SimData, with one instance for instance tuning or one instance for each class of module tuning that has exported tunables

Remarks

The Pack of the SimData is 0, the base game's; set it for SimData that belongs to a pack.

Exceptions

SimDataGenerationException

tuning cannot be generated with Descriptions and what the generator has learned

IsWrittenToSimData(TuningDescriptionInstance, IReadOnlyList<TunableDescription>)

Gets whether the tunable at the end of the specified path in instance tuning of the specified instance class is written to the SimData Generate(XDocument) generates, so that changing it changes the SimData

public bool IsWrittenToSimData(TuningDescriptionInstance instance, IReadOnlyList<TunableDescription> path)

Parameters

instance TuningDescriptionInstance

The class of the instance tuning

path IReadOnlyList<TunableDescription>

The descriptions from one of the class's effective members (see GetEffectiveMembers()) down to the tunable: after a list, its item; after a variant, the option; after a tuple, the member

Returns

bool

Remarks

The same rules decide this as decide what Generate(XDocument) writes, including those that export a whole class (its export_modes has client_binary), a member through the class that declares it, and every member of a tuple none of whose members is exported. A path that ends at a variant's option stands for choosing that option, which changes the variant's hash, so it is written whenever the variant is, even when the option's own tunables are not.

RemoveResourceKeyConversion(ResourceType, uint)

Stops converting resource keys of the specified fromType and fromGroup in tuning, so that they are written to SimData as they are

public void RemoveResourceKeyConversion(ResourceType fromType, uint fromGroup)

Parameters

fromType ResourceType
fromGroup uint