Game.Routes.Position
Assembly: Assembly-CSharp.dll
Namespace: Game.Routes
Type: struct
Base: IComponentData, IQueryTypeParameter, ISerializable
Summary:
A lightweight ECS component that stores a 3D position (float3) for an entity. Implements Colossal.Serialization.Entities.ISerializable so the position can be written to and read from the game serialization streams, and implements IQueryTypeParameter so it can be used in Unity.Entities queries or as a parameter type in relevant APIs.
Fields
public Unity.Mathematics.float3 m_Position
Holds the world-space position. Uses Unity.Mathematics.float3 for compact, SIMD-friendly storage and math operations.
Properties
- This struct defines no properties. Use the public field m_Position to read or write the value.
Constructors
public Position(float3 position)
Initializes a new Position component with the provided float3 coordinates.
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the m_Position to the provided writer. Used by the game's serialization system to save the component state. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads the m_Position from the provided reader. Used by the game's serialization system to restore the component state.
Usage Example
using Unity.Entities;
using Unity.Mathematics;
using Game.Routes;
// Create a Position value
var pos = new Position(new float3(10f, 0f, 25f));
// Add to an entity via EntityManager
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
var e = entityManager.CreateEntity(typeof(Position));
entityManager.SetComponentData(e, pos);
// Inside a custom serializer context (conceptual)
public void SavePosition<TWriter>(TWriter writer, Position position) where TWriter : IWriter
{
position.Serialize(writer);
}
// And when loading:
public Position LoadPosition<TReader>(TReader reader) where TReader : IReader
{
var p = new Position();
p.Deserialize(reader);
return p;
}