Game.Prefabs.BuildableNetPiece
Assembly:
Namespace: Game.Prefabs
Type: class
Base: ComponentBase
Summary:
Represents buildable network (net) piece prefab data used by the game's prefab system. Holds placement and snapping information for a net piece, including world positions, widths, and whether placement on bridges is allowed. The class also participates in prefab-to-entity conversion by declaring required ECS components via GetPrefabComponents. The ComponentMenu attribute registers this prefab under the "Net/" menu and associates it with NetPiecePrefab.
Fields
-
public Unity.Mathematics.float3 m_Position
World-space position offset for the net piece. Used when placing the piece in the scene or when constructing prefab geometry. -
public System.Single m_Width
The nominal width of the net piece. Used to determine visual or collision width when building or snapping. -
public Unity.Mathematics.float3 m_SnapPosition
Position used for snapping logic (e.g., alignment to network nodes or other pieces). -
public System.Single m_SnapWidth
Width value used by snapping logic (may differ from m_Width to control connection thresholds). -
public System.Boolean m_AllowOnBridge
Flag indicating whether this net piece is allowed to be placed on bridge segments.
Properties
- This class declares no properties.
Constructors
public BuildableNetPiece()
Default parameterless constructor (implicit). Instances are typically created by the prefab system; fields are expected to be filled by the editor/prefab importer or via code when constructing a prefab.
Methods
-
public override void GetPrefabComponents(System.Collections.Generic.HashSet<Unity.Entities.ComponentType> components)
Adds required ECS component types that should be present on entities created from this prefab. Implementation adds ComponentType.ReadWrite() to the provided set, indicating that entities based on this prefab require a NetPieceArea component. -
public override void GetArchetypeComponents(System.Collections.Generic.HashSet<Unity.Entities.ComponentType> components)
Intended to add components used for archetype creation. This override is empty in this class, so it does not add any archetype components.
Usage Example
// Example: creating and initializing the prefab-like object in code
var piece = new Game.Prefabs.BuildableNetPiece();
piece.m_Position = new Unity.Mathematics.float3(0f, 0f, 0f);
piece.m_Width = 3.0f;
piece.m_SnapPosition = new Unity.Mathematics.float3(0f, 0f, 0f);
piece.m_SnapWidth = 2.8f;
piece.m_AllowOnBridge = true;
// Example: the prefab system calls GetPrefabComponents to determine required ECS components
var components = new HashSet<Unity.Entities.ComponentType>();
piece.GetPrefabComponents(components);
// components now contains ComponentType.ReadWrite<NetPieceArea>()