Class WorldLotObjectsModel
- Namespace
- LlamaLogic.Architecture
- Assembly
- LlamaLogic.Architecture.dll
Represents a WorldLotObjects resource: the objects of a lot template in a world file, as a LotObjectList protobuf message in protobuf text format (🔓)
public sealed class WorldLotObjectsModel : Model, IModel<WorldLotObjectsModel>, IModel
- Inheritance
-
WorldLotObjectsModel
- Implements
- Inherited Members
Remarks
The game names the resource after the lot template it belongs to; see GetKey(uint). Its WorldLotArchitecture counterpart holds the lot template's architecture.
Maxis writes the text with fields in field-number order, two-space indentation, CRLF line endings and floats in .NET Framework's round-trip format; Encode() writes the same, so it reproduces every resource Maxis wrote byte for byte. Decode(ReadOnlyMemory<byte>) also reads text written otherwise (community tools add commas, reorder fields or write hexadecimal integers), and Encode() returns the decoded bytes unchanged as long as LotObjects is unchanged.
Constructors
WorldLotObjectsModel()
Initializes a new instance of the WorldLotObjectsModel class with no objects
public WorldLotObjectsModel()
Properties
LotObjects
Gets/sets the lot template's objects
public LotObjectList LotObjects { get; set; }
Property Value
- LotObjectList
ResourceName
Gets the name of this resource if it has one
public override string? ResourceName { get; }
Property Value
SupportedTypes
Gets a list of resource types that this model supports
public static ISet<ResourceType> SupportedTypes { get; }
Property Value
Methods
Decode(ReadOnlyMemory<byte>)
Decodes the resource in raw format to produce an operable model (🔄️🏃)
public static WorldLotObjectsModel Decode(ReadOnlyMemory<byte> data)
Parameters
dataReadOnlyMemory<byte>
Returns
Exceptions
- InvalidDataException
The data is not protobuf text format of a
LotObjectListmessage
Encode()
Encodes the resource model into raw format (🔄️🏃)
public override ReadOnlyMemory<byte> Encode()
Returns
GetKey(uint)
Gets the key of the WorldLotObjects resource of the lot template with the specified lotTemplateId
public static ResourceKey GetKey(uint lotTemplateId)
Parameters
lotTemplateIduint
Returns
Remarks
The instance is that of the lot template's WorldLotArchitecture resource (see GetLotTemplateInstance(uint)), and the type is the FNV-1 32-bit hash of the extension lottemp.
GetName(Stream)
Gets the name of a resource from its raw data, if it has one (🔄️💤)
public static string? GetName(Stream stream)
Parameters
streamStream
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
streamStreamcancellationTokenCancellationToken