Game.Prefabs.NetCompositionPiece
Assembly:
Assembly-CSharp (game runtime assembly; exact DLL may be Assembly-CSharp.dll depending on build)
Namespace: Game.Prefabs
Type:
struct (IBufferElementData)
Base:
Unity.Entities.IBufferElementData
Summary:
Represents a single piece entry in a net composition buffer used by the game's entity-component-system to describe the parts that make up a network (roads, rails, etc.). Each element holds a reference to the piece entity and metadata such as offset, size, flags and the section index. The struct is marked with InternalBufferCapacity(0), meaning the dynamic buffer has no inline preallocated capacity and will allocate storage externally when used.
Fields
-
public Entity m_Piece
Entity reference to the piece/prefab instance used for this composition entry. This is the ECS Entity that represents the visual/functional piece. -
public float3 m_Offset
Local offset (position) for the piece relative to the parent or section origin. Uses Unity.Mathematics.float3. -
public float3 m_Size
Size (extents or bounding dimensions) of the piece. Used for layout, culling, or placement calculations. -
public NetSectionFlags m_SectionFlags
Flags describing section-level properties affecting this piece (e.g., direction, special behavior). This is an enum defined elsewhere in the codebase — consult its definition to interpret individual flag bits. -
public NetPieceFlags m_PieceFlags
Flags that apply specifically to the piece (for example special rendering or collision overrides). Also an enum defined elsewhere; check its definition for available flags. -
public int m_SectionIndex
Index of the section this piece belongs to. Used to group pieces into sections when constructing or iterating the net composition.
Properties
- None. This is a simple POD struct used as a dynamic buffer element; all data is stored in public fields.
Constructors
- None defined explicitly. Uses the default value-type constructor. Create and assign fields directly before adding to buffers.
Methods
- None. No methods are defined on this buffer element type.
Usage Example
// Example: add pieces to a DynamicBuffer<NetCompositionPiece> on an entity.
using Unity.Entities;
using Unity.Mathematics;
public void AddPieceToEntity(EntityManager em, Entity targetEntity, Entity pieceEntity)
{
var buffer = em.GetBuffer<NetCompositionPiece>(targetEntity);
NetCompositionPiece entry = default;
entry.m_Piece = pieceEntity;
entry.m_Offset = new float3(0f, 0f, 0f);
entry.m_Size = new float3(1f, 1f, 1f);
entry.m_SectionFlags = /* set appropriate NetSectionFlags value */;
entry.m_PieceFlags = /* set appropriate NetPieceFlags value */;
entry.m_SectionIndex = 0;
buffer.Add(entry);
}
Notes and tips:
- Because the struct implements IBufferElementData, it's intended to be used via DynamicBuffer