Skip to content

Game.Net.CutRange

Assembly: Game
Namespace: Game.Net

Type: struct

Base: System.ValueType (implements Unity.Entities.IBufferElementData, Colossal.Serialization.Entities.ISerializable)

Summary: CutRange is an ECS buffer element type used to represent a numeric range (min/max) for "cut" operations in networked game systems. Internally it stores a Bounds1 (from Colossal.Mathematics) named m_CurveDelta and provides serialization support through the ISerializable interface so the min/max values can be written to/read from a writer/reader for network or persistence purposes. The type is annotated with [InternalBufferCapacity(1)], making it suitable as a dynamic buffer element with a small internal storage optimization.


Fields

  • public Colossal.Mathematics.Bounds1 m_CurveDelta Holds the range values. Bounds1 exposes float fields min and max which represent the lower and upper bounds of the cut range.

  • (Attribute) [InternalBufferCapacity(1)] Specifies the internal capacity hint for the ECS dynamic buffer that holds CutRange elements (optimizes for small buffer sizes).

Properties

  • None (no explicit properties defined)

Constructors

  • Implicit default constructor (value type) As a struct, CutRange has the implicit parameterless constructor which zero-initializes m_CurveDelta (min = 0, max = 0) unless an explicit constructor is provided elsewhere.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter Writes the range to the provided writer. Implementation writes m_CurveDelta.min followed by m_CurveDelta.max as float values. Intended for network/persistence serialization.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader Reads the range from the provided reader. Implementation reads two float values into m_CurveDelta.min and m_CurveDelta.max respectively. Uses ref locals to write directly into the Bounds1 fields.

Notes: - TWriter and TReader are generic writer/reader types constrained to Colossal.Serialization.Entities.IWriter / IReader (or compatible interfaces). The exact writer/reader implementations depend on the serialization system used by the game/mod. - Ordering matters: Serialize writes min then max, so Deserialize expects the same order.

Usage Example

// Example: add a CutRange to an entity's dynamic buffer and set values
var buffer = entityManager.GetBuffer<Game.Net.CutRange>(entity);
Game.Net.CutRange range = new Game.Net.CutRange
{
    m_CurveDelta = new Colossal.Mathematics.Bounds1 { min = -5.0f, max = 3.5f }
};
buffer.Add(range);

// Example: manual serialization (pseudo-usage — actual writer depends on game's serialization API)
var writer = /* obtain IWriter implementation */;
range.Serialize(writer);

// Example: manual deserialization (pseudo-usage — actual reader depends on game's serialization API)
var reader = /* obtain IReader implementation */;
Game.Net.CutRange readRange = new Game.Net.CutRange();
readRange.Deserialize(reader);

{{ Notes for modders: - CutRange is lightweight and intended to be used as a buffer element (dynamic buffer) so multiple ranges can be attached to an entity if needed. - Because it implements ISerializable, it integrates with the game's serialization routines — ensure the writer/reader used matches the expected binary layout (min then max as floats). - The Colossal.Mathematics.Bounds1 type is a simple min/max float container used across the game's math utilities. }}