Skip to content

Game.Common.PointOfInterest

Assembly: Assembly-CSharp
Namespace: Game.Common

Type: struct

Base: IComponentData, IQueryTypeParameter, ISerializable

Summary:
Represents a simple ECS component for a Point of Interest (POI) in the game world. Contains a world-space position and a validity flag. Implements ISerializable so it can be written to and read from the game's serialization system (used for saving/loading or streaming). As an IComponentData value type it is intended to be attached to entities and queried in DOTS systems.


Fields

  • public Unity.Mathematics.float3 m_Position
    This is the POI's position in world space (Unity.Mathematics.float3). Default is (0,0,0). Used by systems that need to locate or render the point of interest.

  • public System.Boolean m_IsValid
    Flag that indicates whether the POI is valid/active. Default is false. Systems can use this to ignore invalidated points without removing the component.

Properties

  • This type does not declare any C# properties. It exposes its data via public fields.

Constructors

  • public PointOfInterest()
    Implicit default value-type constructor (provided by C#). Initializes m_Position to float3.zero and m_IsValid to false. You can also construct and assign values directly: var poi = new PointOfInterest { m_Position = new float3(x,y,z), m_IsValid = true };

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the component data to a writer for persistence/streaming. The implementation writes m_Position followed by m_IsValid. The writer implementation must match the reading order used in Deserialize.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads the component data from a reader. The method reads values in the same order they were written (position then validity). After deserialization the struct fields are populated with the persisted values.

Usage Example

// Example: creating and adding the component to an entity
var poi = new PointOfInterest {
    m_Position = new float3(100f, 0f, 200f),
    m_IsValid = true
};

EntityManager entityManager = /* obtain EntityManager */;
Entity e = entityManager.CreateEntity();
entityManager.AddComponentData(e, poi);

// Example: reading in a System
public partial struct PoiSystem : ISystem
{
    public void OnUpdate(ref SystemState state)
    {
        var em = state.EntityManager;
        Entities.ForEach((ref PointOfInterest p) =>
        {
            if (!p.m_IsValid) return;
            // use p.m_Position...
        }).Schedule();
    }
}

// Example: serialization (pseudocode, actual writer depends on game API)
var writer = /* IWriter implementation from game serialization stack */;
poi.Serialize(writer);

// Corresponding deserialization:
var reader = /* IReader implementation */;
var loadedPoi = new PointOfInterest();
loadedPoi.Deserialize(reader);

Notes and recommendations: - The Serialize/Deserialize pair must be kept in the same order to ensure compatibility across save/load operations. - As a value type component, PointOfInterest is cheap to copy; prefer setting fields directly or via EntityManager.SetComponentData. - Default instances are invalid (m_IsValid == false). Explicitly set m_IsValid = true when you want the POI to be processed by systems.