Skip to content

Game.EdgeMapping

Assembly: Assembly-CSharp
Namespace: Game.Net

Type: struct

Base: IComponentData, IQueryTypeParameter, IEmptySerializable

Summary:
EdgeMapping is a simple ECS component used by the game's networking/edge systems to associate an "edge" with two parent entities and two 2D curve offsets. It stores the two parent Entity handles (typically references to nodes/segments or other owner entities) and two float2 values representing curve deltas/control-point offsets used when reconstructing or adjusting the edge's curve in 2D space. This struct is blittable and marked for Colossal's serialization via IEmptySerializable, and it can be used directly in Entities queries because it implements IQueryTypeParameter.


Fields

  • public Entity m_Parent1
    Stores the first parent entity for this edge mapping. This typically refers to one endpoint/owner (for example a node or segment entity). Default is Entity.Null. Ensure the referenced Entity exists in the same World.

  • public Entity m_Parent2
    Stores the second parent entity for this edge mapping. This typically refers to the other endpoint/owner. Default is Entity.Null. Used together with m_Parent1 to identify the two-side relationship for the edge.

  • public float2 m_CurveDelta1
    A 2D offset (float2) representing the curve/control-point delta associated with the first parent. Interpreted in the game's horizontal plane (X,Z or local 2D coordinate space depending on context). Used when reconstructing the edge's curve or tweaking curvature relative to the parent.

  • public float2 m_CurveDelta2
    A 2D offset (float2) representing the curve/control-point delta associated with the second parent. Same interpretation as m_CurveDelta1 but for the second side of the edge.

Properties

  • This type has no properties. It exposes only public fields.

Constructors

  • public EdgeMapping()
    No explicit constructors are defined in source — the struct uses the default parameterless constructor. Fields initialize to their default values (Entity.Null for Entity fields, float2(0,0) for float2 fields).

Methods

  • This type defines no methods. It is a pure data container component.

Usage Example

// Example inside a System or other initialization code
using Unity.Entities;
using Unity.Mathematics;
using Game.Net;

public partial class ExampleSystem : SystemBase
{
    protected override void OnCreate()
    {
        base.OnCreate();
    }

    protected override void OnUpdate()
    {
        var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;

        // Example: create an entity and attach an EdgeMapping
        Entity edgeEntity = entityManager.CreateEntity();
        Entity parentA = /* obtain or create first parent entity */;
        Entity parentB = /* obtain or create second parent entity */;

        var mapping = new EdgeMapping
        {
            m_Parent1 = parentA,
            m_Parent2 = parentB,
            m_CurveDelta1 = new float2(0.5f, 0.0f),
            m_CurveDelta2 = new float2(-0.3f, 0.0f)
        };

        entityManager.AddComponentData(edgeEntity, mapping);

        // Later, read or update:
        if (entityManager.HasComponent<EdgeMapping>(edgeEntity))
        {
            var read = entityManager.GetComponentData<EdgeMapping>(edgeEntity);
            // use read.m_Parent1, read.m_CurveDelta1, etc.
        }
    }
}

Notes: - Ensure parent Entities referenced by m_Parent1/m_Parent2 belong to the same World; Entity handles are not valid across Worlds. - The float2 offsets are 2D deltas; interpret them according to the surrounding code/context (world XZ plane vs. local 2D space). - Because EdgeMapping implements IEmptySerializable and is blittable, it is suitable for high-performance ECS usage and Colossal serialization.