Game.Net.Elevation
Assembly: Game
Namespace: Game.Net
Type: struct
Base: IComponentData, IQueryTypeParameter, ISerializable
Summary: Represents an ECS component that stores a 2D elevation value using Unity.Mathematics.float2. This struct is a plain, blittable component usable in Unity's DOTS/ECS and supports custom binary serialization via the ISerializable interface (used by the game's networking/serialization systems).
Fields
public Unity.Mathematics.float2 m_Elevation
Stores the elevation as a float2. The two float channels can represent any pair of elevation-related values (for example X/Y coordinates, min/max heights, or other 2-component elevation data) depending on how the game or mod uses the component. Being a value type and part of IComponentData, it is stored in entity chunks.
Properties
- None This struct exposes its data via a public field rather than properties.
Constructors
public Elevation(Unity.Mathematics.float2 elevation)
Creates a new Elevation component with the provided float2 value and assigns it to m_Elevation.
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : Colossal.Serialization.Entities.IWriter
Writes the m_Elevation field to the provided writer. Used by the game's serialization pipeline to persist or transmit the component state. -
public void Deserialize<TReader>(TReader reader) where TReader : Colossal.Serialization.Entities.IReader
Reads the m_Elevation field from the provided reader. Used by the game's deserialization pipeline to restore the component state.
Usage Example
using Unity.Mathematics;
using Unity.Entities;
// Create and assign the component to an entity
var elevationValue = new float2(12.5f, 34.0f);
var elevationComponent = new Game.Net.Elevation(elevationValue);
entityManager.AddComponentData(someEntity, elevationComponent);
// Read/update the component inside a SystemBase
public partial class ElevationSystem : SystemBase
{
protected override void OnUpdate()
{
Entities.ForEach((ref Game.Net.Elevation elev) =>
{
// read
float2 val = elev.m_Elevation;
// modify (example)
val.x += 0.1f;
elev.m_Elevation = val;
}).ScheduleParallel();
}
}
// Serialization/deserialization are handled by the game's IWriter/IReader infrastructure.
// The component implements ISerializable via Serialize/Deserialize methods above.
Additional notes: - Because this type implements IComponentData it is intended for storage in ECS entity chunks and should remain small and blittable for performance. - The meaning of the two components of float2 is context-dependent; consult calling code to determine whether they represent coordinates, heights, or another pair of values.