Game.Prefabs.NetCompositionObject
Assembly:
Assembly-CSharp
Namespace:
Game.Prefabs
Type:
struct
Base:
Unity.Entities.IBufferElementData
Summary:
NetCompositionObject is a dynamic buffer element used by the net (road/rail) composition system. Each element describes one sub-object (prefab) that can be spawned along or relative to a net segment. The element contains a prefab Entity reference plus placement parameters such as position, offset, rotation, spacing and probability. The struct is marked with [InternalBufferCapacity(0)], meaning it is used as a variable-length DynamicBuffer on an entity.
Fields
-
public Entity m_Prefab
Reference to the prefab Entity to be instantiated/used for this composition entry. This is typically an entity that represents an asset or sub-object to place along the net. -
public float2 m_Position
2D position information used by the composition system. Often encodes position along the segment and lateral offset in composition-local space (e.g., param along the curve and side offset). Interpretation depends on the composition code that consumes this buffer. -
public float3 m_Offset
Additional 3D offset applied to the prefab placement in local space (x, y, z). Used to fine-tune vertical or lateral placement beyond m_Position. -
public quaternion m_Rotation
Rotation to apply to the instantiated prefab. Typically applied on top of any curve-alignment or default orientation. -
public SubObjectFlags m_Flags
Flags controlling behaviour for this sub-object (alignment, mirroring, disabling, etc.). The exact semantics depend on the SubObjectFlags enum used by the game’s composition code. -
public CompositionFlags.General m_SpacingIgnore
Composition-level flags that affect spacing behavior (for example, whether spacing constraints should be ignored under certain conditions). Details follow the CompositionFlags.General enum used in the project. -
public float2 m_UseCurveRotation
A two-component value used by the composition logic to decide whether and how much to follow the segment curve rotation. Often used as thresholds or ranges; the composition consumer determines the exact meaning (e.g., min/max or probability bounds). -
public float2 m_CurveOffsetRange
Range (min, max) for offset when aligning the object to the segment’s curve — used to randomize or constrain the offset applied along the curve. -
public int m_Probability
Weight or probability value used to influence random selection when multiple composition objects are available. Higher values increase the chance this object will be chosen. -
public float m_Spacing
Spacing distance along the net between consecutive placements of this object. The composition system uses this to space repeated instances. -
public float m_AvoidSpacing
A spacing radius used to avoid placing objects too close to certain features or other instances (e.g., to create exclusion zones). -
public float m_MinLength
Minimum segment length required for this object to be eligible for placement. If the segment is shorter than this value, the object will not be placed.
Properties
This type does not declare any C# properties. It is a plain buffer element struct with public fields.
Constructors
public NetCompositionObject()
No explicit constructors are declared in the source. The default parameterless struct constructor (zero-initialized fields) provided by C# is used. Populate fields manually after creating an instance before adding it to a DynamicBuffer.
Methods
This type does not declare any methods. It is a data-only structure intended to be stored in a DynamicBuffer
Usage Example
// Example: adding composition entries to an entity that stores a DynamicBuffer<NetCompositionObject>
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
var entity = /* get or create an entity representing a net prefab configuration */;
// Ensure the entity has the buffer
if (!entityManager.HasBuffer<NetCompositionObject>(entity))
{
entityManager.AddBuffer<NetCompositionObject>(entity);
}
var buffer = entityManager.GetBuffer<NetCompositionObject>(entity);
// Create and populate an element
NetCompositionObject entry = new NetCompositionObject
{
m_Prefab = prefabEntity, // an Entity reference to the prefab asset
m_Position = new float2(0.5f, 0f), // halfway along the segment
m_Offset = new float3(0f, 0.0f, 0f),
m_Rotation = quaternion.identity,
m_Flags = SubObjectFlags.None, // example enum value
m_SpacingIgnore = CompositionFlags.General.None,
m_UseCurveRotation = new float2(1f, 1f),
m_CurveOffsetRange = new float2(-0.5f, 0.5f),
m_Probability = 100,
m_Spacing = 5f,
m_AvoidSpacing = 2f,
m_MinLength = 10f
};
// Add to buffer
buffer.Add(entry);
// Multiple entries can be added to define different sub-objects for the same net prefab.
Notes - Interpretation of some fields (m_Position, m_UseCurveRotation, SubObjectFlags, CompositionFlags.General, etc.) depends on the composition/placement code that consumes this buffer. Consult the caller or composition system for exact semantics. - This struct is intended for use within Unity's ECS (Entities package) as buffer element data; operate on it using EntityManager/System APIs or in burst-compatible jobs where appropriate.