Game.Net.LandValue
Assembly: Assembly-CSharp (game's main assembly)
Namespace: Game.Net
Type: struct
Base: IComponentData, IQueryTypeParameter, ISerializable
Summary:
LandValue is a small ECS component used to store a numeric land value and an associated weight. It implements IComponentData so it can be attached to entities, IQueryTypeParameter for querying, and ISerializable to support custom binary serialization for save/load or network transfer. The serializer writes and reads the two floats in a fixed order: m_LandValue first, then m_Weight.
Fields
-
public float m_LandValue
Stores the land value (float). This is the primary value represented by the component — e.g., used by game systems that compute or propagate land values. -
public float m_Weight
A weight multiplier or importance value associated with the land value (float). Typically used when combining or averaging multiple land-value contributions.
Properties
- None. The struct exposes only public fields and serialization methods.
Constructors
- Default struct constructor (implicit)
There are no custom constructors defined. The default constructor will zero-initialize both m_LandValue and m_Weight.
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the component data to a binary writer. The implementation writes m_LandValue first, then m_Weight. Any reader must read in the same order. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads component data from a binary reader. Reads into m_LandValue then m_Weight (matching the Serialize order). Uses ref locals to place values directly into the struct fields.
Usage Example
// Create and initialize
var lv = new Game.Net.LandValue {
m_LandValue = 42.0f,
m_Weight = 1.5f
};
// Add to an entity (EntityManager example)
entityManager.AddComponentData(someEntity, lv);
// Serialize to a writer (writer must implement IWriter)
lv.Serialize(writer);
// Deserialize from a reader
var readLv = new Game.Net.LandValue();
readLv.Deserialize(reader);
// Note: Serialize and Deserialize must be used with matching writer/reader types
// and the same field order (m_LandValue then m_Weight).
{{Additional notes: - Keep serialization order stable across versions to avoid compatibility issues. - As an IComponentData struct, LandValue is blittable and inexpensive to store in ECS archetypes. - Because fields are public, mod code can read/write them directly when manipulating ECS components. }}