Skip to content

Game.Prefabs.NetPieceObject

Assembly:
{{ Likely part of the game's main assembly (Game). The concrete compiled assembly name is not shown in the source file. }}

Namespace: Game.Prefabs

Type:
struct

Base:
IBufferElementData

Summary:
{{ NetPieceObject is a buffer element representing a single piece or sub-object used when spawning or placing network elements (roads, rails, props attached to a net, etc.). It contains prefab reference, spatial placement data, rules for spacing/rotation/curve offsets, and composition/section filters controlling when and where the piece may be used. The struct is intended to be stored in a DynamicBuffer on an entity (InternalBufferCapacity(0) indicates no inline storage capacity). }}


Fields

  • public Entity m_Prefab
    {{ Reference to the prefab Entity to instantiate for this net piece. This is typically an entity created from a GameObject prefab or a prebuilt entity archetype for the sub-object. }}

  • public float3 m_Position
    {{ Local placement position for the piece relative to the parent net section or anchor point (uses Unity.Mathematics.float3). }}

  • public float3 m_Offset
    {{ Additional positional offset applied to m_Position; often used to nudge the piece along or across the segment (local-space offset). }}

  • public float3 m_Spacing
    {{ Spacing vector used to control how this piece repeats or is placed along the net; components typically represent distances or separation parameters in local axes. }}

  • public float2 m_UseCurveRotation
    {{ Two-component float (float2) used to control or interpolate curve-based rotation behavior. The exact interpretation depends on the game logic (e.g., start/end weights or a min/max threshold for applying curve rotation). }}

  • public float m_MinLength
    {{ Minimum length of the net section for which this piece is considered valid. If the section is shorter than m_MinLength, the piece will normally be skipped. }}

  • public int m_Probability
    {{ Probability (often as an integer or percentage-like weight) that this piece will be placed when other conditions are satisfied. Higher values increase the chance of spawning. }}

  • public float2 m_CurveOffsetRange
    {{ A two-component range (min, max) used to randomize or constrain offset along a curve. Values affect lateral/longitudinal offset when placing the piece on curved net sections. }}

  • public quaternion m_Rotation
    {{ Rotation to apply to the piece (Unity.Mathematics.quaternion). Represents local orientation relative to the net section or parent. }}

  • public CompositionFlags m_CompositionAll
    {{ Composition filter: all flags in this mask must be present on the composition/context for the piece to be allowed. CompositionFlags is a game-specific enum/bitmask describing composition categories. }}

  • public CompositionFlags m_CompositionAny
    {{ Composition filter: at least one flag in this mask must be present for the piece to be allowed. }}

  • public CompositionFlags m_CompositionNone
    {{ Composition filter: none of the flags in this mask must be present. If any are present the piece is disallowed. }}

  • public NetSectionFlags m_SectionAll
    {{ Net section filter: all flags in this mask must be present on the current net section for the piece to be allowed. NetSectionFlags is a game-specific enum/bitmask describing section properties (e.g., elevated, tunnel, lane types). }}

  • public NetSectionFlags m_SectionAny
    {{ Net section filter: at least one flag in this mask must be present on the section for the piece to be allowed. }}

  • public NetSectionFlags m_SectionNone
    {{ Net section filter: none of the flags in this mask must be present; if any are present the piece is disallowed. }}

  • public SubObjectFlags m_Flags
    {{ Miscellaneous flags controlling piece behavior (SubObjectFlags is a game-specific enum/bitmask). Flags can indicate special handling like mirrored placement, collision behavior, LOD constraints, or other piece-specific options. }}

Properties

{{ This struct has no C# properties; it exposes only public fields. It is a pure data container intended for use in ECS DynamicBuffer. }}

Constructors

  • public NetPieceObject()
    {{ The struct uses the implicit parameterless constructor provided by C#. Initialize individual fields when creating instances. Commonly created inline with object initializer syntax when adding to a DynamicBuffer. }}

Methods

  • None
    {{ NetPieceObject is a POD (plain-old-data) buffer element with no methods. All behavior is implemented by systems that read the buffer. }}

Usage Example

// Example: add a buffer to an entity and append a NetPieceObject element.
// Assumes using Unity.Entities, Unity.Mathematics and an EntityManager or SystemBase context.

var e = entityManager.CreateEntity();
var buffer = entityManager.AddBuffer<Game.Prefabs.NetPieceObject>(e);

// Create and add a piece
buffer.Add(new Game.Prefabs.NetPieceObject {
    m_Prefab = prefabEntity,
    m_Position = new float3(0f, 0f, 0f),
    m_Offset = new float3(0f, 0f, 0f),
    m_Spacing = new float3(1f, 0f, 1f),
    m_UseCurveRotation = new float2(1f, 0f),
    m_MinLength = 2f,
    m_Probability = 100,
    m_CurveOffsetRange = new float2(-0.5f, 0.5f),
    m_Rotation = quaternion.identity,
    m_CompositionAll = CompositionFlags.None,
    m_CompositionAny = CompositionFlags.None,
    m_CompositionNone = CompositionFlags.None,
    m_SectionAll = NetSectionFlags.None,
    m_SectionAny = NetSectionFlags.None,
    m_SectionNone = NetSectionFlags.None,
    m_Flags = SubObjectFlags.None
});

{{ Notes: - InternalBufferCapacity(0) on the struct attribute means the DynamicBuffer will not reserve inline storage in the entity; the buffer is fully heap-backed. - CompositionFlags, NetSectionFlags and SubObjectFlags are game-specific enums/bitmasks; refer to their definitions for exact meanings and available values. - Systems responsible for placing net pieces will evaluate these fields (filters, spacing, probability, rotation, curve offsets) to decide how and when to instantiate the referenced prefab entities. }}