Game.Prefabs.Bridge
Assembly:
Assembly-CSharp
Namespace:
Game.Prefabs
Type:
class
Base:
ComponentBase
Summary:
Bridge is a prefab component used by net-type prefabs (e.g., RoadPrefab, TrackPrefab, PathwayPrefab) to provide bridge-specific configuration for generated net segments. It holds placement and rendering parameters (segment length, hanging/sag, elevation over water), build options (curving, minimal length), water-flow behavior, build style, and an optional list of fixed segments. The component participates in prefab→entity conversion by adding appropriate ECS components (BridgeData and, if needed, FixedNetElement / Fixed) to the prefab/archetype.
Fields
-
public float m_SegmentLength = 100f
Default segment length used when placing bridge segments. Controls how long each generated bridge segment should be. -
public float m_Hanging
Controls how much the bridge hangs or sags. Typical use is to influence visual curve/sag of the bridge deck between supports. -
public float m_ElevationOnWater = 10f
Default elevation (clearance) applied when the bridge is placed over water. Useful to ensure sufficient distance from the water surface. -
public bool m_CanCurve
If true, the bridge can be laid on curved alignment; otherwise bridge segments are placed as straight sections. -
public bool m_AllowMinimalLength
When true, allows building very short bridge pieces (minimal lengths) when required by placement constraints. -
public BridgeWaterFlow m_WaterFlow
Enum value describing how water flow interacts with the bridge (e.g., blocks flow, allows flow). Controls behavior/visuals around water. -
public BridgeBuildStyle m_BuildStyle
Enum indicating a build style for the bridge (visual/structural style chosen during placement). -
public FixedNetSegmentInfo[] m_FixedSegments
Optional array describing fixed segments. When present (non-null && length > 0), the prefab conversion adds FixedNetElement (and Fixed on archetype when appropriate) so some segments are treated as fixed/anchored rather than fully dynamic.
Properties
- No public properties are defined on this component. All configuration is exposed via public fields.
Constructors
public Bridge()
Default constructor (implicit). The class uses public instance fields with Unity serialization; initialization uses field defaults declared above.
Methods
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds the ECS components that should be attached to the prefab entity at conversion time.- Always adds BridgeData (via ComponentType.ReadWrite
()). -
If m_FixedSegments is not null and contains elements, adds FixedNetElement (ComponentType.ReadWrite
()) so the prefab includes data for fixed segments. -
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Called when assembling an entity archetype. If m_FixedSegments is provided and the archetype already contains Edge() (ComponentType.ReadWrite()), this method adds the Fixed component (ComponentType.ReadWrite ()) so that appropriate entities get the Fixed tag in the archetype.
Usage Example
// Typical usage during prefab setup/conversion:
var bridge = new Bridge();
bridge.m_SegmentLength = 120f;
bridge.m_CanCurve = true;
bridge.m_ElevationOnWater = 12f;
bridge.m_FixedSegments = new FixedNetSegmentInfo[] { /* fill as needed */ };
var components = new HashSet<ComponentType>();
bridge.GetPrefabComponents(components);
// components now contains ComponentType.ReadWrite<BridgeData>()
// and, if m_FixedSegments was non-empty, ComponentType.ReadWrite<FixedNetElement>()
// During archetype creation the system calls GetArchetypeComponents,
// which will add ComponentType.ReadWrite<Fixed>() if FixedNetSegmentInfo[] exists
// and the archetype already includes Edge.
Notes: - This component is intended to be used on prefabs derived from net prefabs (roads, tracks, pathways). It does not perform runtime logic by itself; it only supplies configuration data that other systems read (via BridgeData, FixedNetElement, Fixed etc.) when instantiating and simulating bridge segments. - Enums/types referenced (BridgeWaterFlow, BridgeBuildStyle, BridgeData, FixedNetElement, Fixed, Edge, FixedNetSegmentInfo) are part of the game's modding API/ECS components and determine downstream behavior—consult their docs/source for details on how they affect rendering, physics, and simulation.