Skip to content

Game.Prefabs.SubAreaNode

Assembly: Assembly-CSharp (game runtime assembly, likely where mod code resides)
Namespace: Game.Prefabs

Type: struct

Base: Unity.Entities.IBufferElementData

Summary:
A lightweight buffer element used by Unity ECS to represent a node inside a sub-area. Each element stores a 3D position (float3) and an integer index referencing the parent mesh. The struct is annotated with InternalBufferCapacity(4) to suggest a small inline capacity for the dynamic buffer, optimizing memory/layout for buffers that typically contain few items.


Fields

  • public Unity.Mathematics.float3 m_Position
    Holds the node position in 3D space (Unity.Mathematics.float3). Use this for spatial calculations, snapping, or path/sample points inside the sub-area.

  • public int m_ParentMesh
    Integer index or identifier pointing to the parent mesh this node belongs to. Convention for valid/invalid values (e.g., -1) should be documented where indices are managed.

Properties

  • This struct defines no C# properties. It exposes two public fields (m_Position, m_ParentMesh) for direct access.

Constructors

  • public SubAreaNode(float3 position, int parentMesh)
    Constructs a new SubAreaNode and initializes m_Position and m_ParentMesh. Use this when adding elements to a DynamicBuffer or when creating node instances in code.

Methods

  • This type declares no methods. It's a plain data container (IBufferElementData) intended for storage in ECS dynamic buffers.

Usage Example

// Example: adding nodes to a DynamicBuffer<SubAreaNode> on an entity
using Unity.Entities;
using Unity.Mathematics;
using Game.Prefabs;

public void AddSampleNodes(EntityManager em, Entity entity)
{
    // Ensure the buffer exists on the entity
    var buffer = em.GetBuffer<SubAreaNode>(entity);

    // Add nodes (positions in local/world space as appropriate)
    buffer.Add(new SubAreaNode(new float3(0f, 0f, 0f), parentMesh: 0));
    buffer.Add(new SubAreaNode(new float3(1f, 0f, 0f), parentMesh: 0));
    buffer.Add(new SubAreaNode(new float3(0f, 0f, 1f), parentMesh: 1));
}

Additional notes: - Because SubAreaNode implements IBufferElementData and is blittable, it is suited for high-performance ECS usage and can be processed in jobs. - The InternalBufferCapacity(4) attribute suggests that small buffers (up to 4 elements) may avoid heap allocations — still test performance under your expected usage patterns.