Skip to content

Game.Prefabs.BuildingTerraformData

Assembly:
Namespace: Game.Prefabs

Type: struct

Base: IComponentData, IQueryTypeParameter, ISerializable

Summary:
Represents per-building terrain modification parameters used by the game to describe how terrain should be flattened/smoothed around a building. Contains flat-plane corner vectors (X/Z directions), smoothing coefficients, an optional height offset and flags that control whether the terrain can be raised or lowered. The struct is serializable via the Colossal.Serialization ISerializable pattern and is used as an ECS component (IComponentData / IQueryTypeParameter) within the game's DOTS-based systems.


Fields

  • public Unity.Mathematics.float3 m_FlatX0
    Vector describing the first X-aligned flat-plane corner/axis for flattening.

  • public Unity.Mathematics.float3 m_FlatZ0
    Vector describing the first Z-aligned flat-plane corner/axis for flattening.

  • public Unity.Mathematics.float3 m_FlatX1
    Vector describing the second X-aligned flat-plane corner/axis for flattening.

  • public Unity.Mathematics.float3 m_FlatZ1
    Vector describing the second Z-aligned flat-plane corner/axis for flattening.

  • public Unity.Mathematics.float4 m_Smooth
    Smoothing coefficients/parameters used when blending terrain near the building (float4, semantics depend on the terrain system).

  • public System.Single m_HeightOffset
    Optional vertical offset applied to the flattened plane. Only read from serialized data when the serialization version supports pillarTerrainModification (see Deserialize).

  • public System.Boolean m_DontRaise
    When true, terrain raising is disallowed for this building. Only read when the serialization version supports pillarTerrainModification.

  • public System.Boolean m_DontLower
    When true, terrain lowering is disallowed for this building. Only read when the serialization version supports pillarTerrainModification.

Properties

  • This type does not declare any C# properties. It exposes public fields and implements serialization methods.

Constructors

  • public BuildingTerraformData()
    Default (implicit) struct constructor. As a value type, all fields default to zero-equivalent values: float3/float4 are zero vectors, m_HeightOffset = 0, and boolean flags = false. Typically instances are populated manually or via deserialization.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Serializes this instance into the provided writer. Fields are written in this order: m_FlatX0, m_FlatZ0, m_FlatX1, m_FlatZ1, m_Smooth, m_HeightOffset, m_DontRaise, m_DontLower. The writer receives copies of the field values. This method follows the game's ISerializable pattern.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Deserializes values from the provided reader into this instance. Values are read into the corresponding fields using ref locals for performance. The first five fields (m_FlatX0, m_FlatZ0, m_FlatX1, m_FlatZ1, m_Smooth) are always read. The last three (m_HeightOffset, m_DontRaise, m_DontLower) are only read when reader.context.version >= Version.pillarTerrainModification; otherwise they remain at their default values. This version check ensures backward compatibility with older serialized data.

Usage Example

using Unity.Mathematics;
using Colossal.Serialization.Entities;

// create and populate
var terraform = new Game.Prefabs.BuildingTerraformData
{
    m_FlatX0 = new float3(1f, 0f, 0f),
    m_FlatZ0 = new float3(0f, 0f, 1f),
    m_FlatX1 = new float3(-1f, 0f, 0f),
    m_FlatZ1 = new float3(0f, 0f, -1f),
    m_Smooth = new float4(0.5f, 0.5f, 0.5f, 0.5f),
    m_HeightOffset = 0.25f,
    m_DontRaise = false,
    m_DontLower = false
};

// serialize
// Assuming `writer` implements IWriter (provided by the game's serialization system)
terraform.Serialize(writer);

// deserialize
// Assuming `reader` implements IReader and has an appropriate context/version
var loaded = new Game.Prefabs.BuildingTerraformData();
loaded.Deserialize(reader);

// Note: If reader.context.version < Version.pillarTerrainModification,
// m_HeightOffset, m_DontRaise and m_DontLower will remain at their default values.