Game.Prefabs.AdditionalBuildingTerraformElement
Assembly: Assembly-CSharp.dll
Namespace: Game.Prefabs
Type: struct (public)
Base: Implements Unity.Entities.IBufferElementData, Colossal.Serialization.Entities.ISerializable
Summary:
Represents a single terraform modification entry used by additional building prefabs. Stored as a buffer element so multiple terraform entries can be attached to an entity (DynamicBuffer
Fields
-
public Bounds2 m_Area
Holds the rectangular area for the terraform operation. Bounds2 comes from Colossal.Mathematics and exposes float2 min and float2 max that are serialized in that order. -
public float m_HeightOffset
Height offset to apply to the terrain inside the area. -
public bool m_Circular
If true, the terraform operation should be treated as circular (radius-based) rather than strictly rectangular. -
public bool m_DontRaise
If true, the terraform operation should not raise terrain (only lower or no change where appropriate). -
public bool m_DontLower
If true, the terraform operation should not lower terrain (only raise or no change where appropriate). Note: this field is conditionally read during deserialization depending on the reader version (see Deserialize).
Properties
- None (no properties declared on this struct).
Constructors
public AdditionalBuildingTerraformElement()
Default value-type constructor. All fields will be default-initialized (m_Area with default min/max, numeric fields to 0, booleans to false). Typically values are set explicitly before use or when added to an entity's DynamicBuffer.
Methods
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Serializes the element in this order:- m_Area.min (float2)
- m_Area.max (float2)
- m_HeightOffset (float)
- m_Circular (bool)
- m_DontRaise (bool)
- m_DontLower (bool)
The writer is a generic IWriter provided by the game's serialization system.
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads values back in the same order, but reads m_DontLower only if reader.context.version >= Version.pillarTerrainModification. This conditional read allows compatibility with older serialized data that doesn't include m_DontLower. Fields read:- m_Area.min (float2) — stored by reference then read into
- m_Area.max (float2)
- m_HeightOffset (float)
- m_Circular (bool)
- m_DontRaise (bool)
- m_DontLower (bool) — only when reader.context.version >= Version.pillarTerrainModification
Note: Serialize unconditionally writes m_DontLower; ensure the writer/serialization pipeline uses matching versioning rules to maintain compatibility with older readers.
Usage Example
// Add terraform entries to an entity's buffer (requires Unity.Entities and that entity has a DynamicBuffer<AdditionalBuildingTerraformElement>).
Entity entity = ...;
var buffer = EntityManager.GetBuffer<AdditionalBuildingTerraformElement>(entity);
AdditionalBuildingTerraformElement elem = new AdditionalBuildingTerraformElement
{
m_Area = new Colossal.Mathematics.Bounds2 { min = new Unity.Mathematics.float2(0f, 0f), max = new Unity.Mathematics.float2(10f, 10f) },
m_HeightOffset = 2.5f,
m_Circular = false,
m_DontRaise = false,
m_DontLower = true
};
buffer.Add(elem);
// Serialization happens via the game's IWriter/IReader pipeline; the struct implements Serialize/Deserialize for that purpose.
// When creating custom saved data, be mindful of Version.pillarTerrainModification: Deserialize only reads m_DontLower for compatible versions.