Game.Net.ValidationHelpers
Assembly: Assembly-CSharp
Namespace: Game.Net
Type: static class
Base: System.Object
Summary:
ValidationHelpers provides a large set of geometry- and composition-aware validation utilities used by the game's net (road/rail) placement and editing systems. It performs intersection tests between edges, nodes, segments, objects and areas, checks collisions against object and net geometry, validates lane connectivity/curviness and placeable/surface rules (water/terrain), and enqueues ErrorData for the ValidationSystem. These helpers are central to ensuring nets do not overlap invalidly with other nets, objects or protected areas and to generate appropriate errors/warnings during placement, modification, upgrade and deletion operations.
Fields
None (static helper class)
ValidationHelpers is a static utility class — it does not define top-level instance fields. Most state is passed into methods or held temporarily in nested iterator structs.
Properties
None
This static utility class exposes only methods (and nested iterator structs) — no properties.
Constructors
None
ValidationHelpers is a static class and therefore has no public constructors.
Methods
-
public static void ValidateEdge(Entity entity, Temp temp, Owner owner, Fixed _fixed, Edge edge, EdgeGeometry edgeGeometry, StartNodeGeometry startNodeGeometry, EndNodeGeometry endNodeGeometry, Composition composition, PrefabRef prefabRef, bool editorMode, ValidationSystem.EntityData data, NativeList<ValidationSystem.BoundsData> edgeList, NativeQuadTree<Entity, QuadTreeBoundsXZ> objectSearchTree, NativeQuadTree<Entity, QuadTreeBoundsXZ> netSearchTree, NativeQuadTree<AreaSearchItem, QuadTreeBoundsXZ> areaSearchTree, WaterSurfaceData waterSurfaceData, TerrainHeightData terrainHeightData, NativeQueue<ErrorData>.ParallelWriter errorQueue, NativeList<ConnectedNode> tempNodes)
Performs full validation for a net edge: checks overlapping nets, objects, areas, surface/water placement rules, geometry/shape correctness, length and slope constraints, and enqueues any errors/warnings detected. This is the main entry point used by the net validation pipeline. -
public static void ValidateLane(Entity entity, Owner owner, Lane lane, TrackLane trackLane, Curve curve, EdgeLane edgeLane, PrefabRef prefabRef, ValidationSystem.EntityData data, NativeQueue<ErrorData>.ParallelWriter errorQueue)
Validates a single lane's connectivity and curviness constraints (e.g., tight curves on tracks), emitting warnings or errors if necessary. -
private static bool IsInternal(Entity topLevelEntity, Entity node, DynamicBuffer<ConnectedEdge> connectedEdges, ValidationSystem.EntityData data)
Checks whether all connected edges to a node belong internally to the same top-level entity (used to avoid validating geometry for internal connections). -
private static bool CheckSurface(WaterSurfaceData waterSurfaceData, TerrainHeightData terrainHeightData, PlaceableNetData placeableNetData, NetCompositionData compositionData, Segment segment, ref Bounds3 errorBounds)
Samples the net segment over water/terrain to determine invalid placements (e.g., in water where not permitted, or too far out of water for floating placement). Collects offending positions in errorBounds. -
private static Entity GetNetNode(Entity entity, ValidationSystem.EntityData data)
Returns the "original" node Entity for a potentially temporary node (used when temporary edits are present). -
private static Entity GetOwner(Entity entity, ValidationSystem.EntityData data, out Entity assetStamp, out Entity edge)
Follows Owner components upwards and returns the top-level owner entity for a given entity; outputs any found assetStamp or owner edge along the way. -
private static bool FindConnectedLane(Entity owner, Entity ignore, PathNode node, ValidationSystem.EntityData data)
Searches for a connected lane matching a node, optionally searching via connected edges (used for connectivity checks). -
private static bool FindConnectedLane(Entity owner, PathNode node, ValidationSystem.EntityData data)
Finds connected lane directly on a given owner entity. -
private static bool IsIgnored(Entity edge, Entity node, ValidationSystem.EntityData data, TrackTypes trackTypes, bool isSource, bool isTarget)
Helper used by lane validation to decide whether certain track types/connections can be ignored for connectivity checks. -
private static bool CheckGeometryShape(EdgeGeometry geometry, ref Bounds3 errorBounds)
private static bool CheckGeometryShape(EdgeNodeGeometry geometry, ref Bounds3 errorBounds)
-
private static bool CheckSegmentShape(Segment segment, ref Bounds3 errorBounds)
Validate geometry shape for edges/nodes/segments. Detects self-intersections or invalid segment winding that indicate invalid prefab geometry. -
Intersect overloads (many):
public static bool Intersect(Edge edge1, Entity node2, EdgeGeometry edgeGeometry1, float3 offset1, Box3 box2, Bounds3 bounds2, NetCompositionData prefabCompositionData1, DynamicBuffer<NetCompositionArea> areas1, ref Bounds3 intersection)
public static bool Intersect(Edge edge1, Entity node2, EdgeGeometry edgeGeometry1, float2 offset1, Quad2 quad2, Bounds2 bounds2, NetCompositionData prefabCompositionData1, DynamicBuffer<NetCompositionArea> areas1, ref Bounds2 intersection)
public static bool Intersect(Entity node1, Entity node2, EdgeNodeGeometry nodeGeometry1, float3 offset1, Box3 box2, Bounds3 bounds2, NetCompositionData prefabCompositionData1, DynamicBuffer<NetCompositionArea> areas1, ref Bounds3 intersection)
public static bool Intersect(Entity node1, Entity node2, EdgeNodeGeometry nodeGeometry1, float2 offset1, Quad2 quad2, Bounds2 bounds2, NetCompositionData prefabCompositionData1, DynamicBuffer<NetCompositionArea> areas1, ref Bounds2 intersection)
public static bool Intersect(Segment segment1, float2 segmentSide1, float3 offset1, Cylinder3 cylinder2, Bounds3 bounds2, NetCompositionData prefabCompositionData1, DynamicBuffer<NetCompositionArea> areas1, ref Bounds3 intersection)
public static bool Intersect(Segment segment1, float2 segmentSide1, float2 offset1, Circle2 circle2, Bounds2 bounds2, NetCompositionData prefabCompositionData1, DynamicBuffer<NetCompositionArea> areas1, ref Bounds2 intersection)
public static bool Intersect(Edge edge1, Edge edge2, EdgeGeometry edgeGeometry1, EdgeGeometry edgeGeometry2, NetCompositionData prefabCompositionData1, NetCompositionData prefabCompositionData2, ref Bounds3 intersection)
public static bool Intersect(Edge edge1, Edge edge2, EdgeGeometry edgeGeometry1, EdgeGeometry edgeGeometry2, NetCompositionData prefabCompositionData1, NetCompositionData prefabCompositionData2, ref Bounds2 intersection)
public static bool Intersect(Edge edge1, Edge originalEdge1, NativeArray<ConnectedNode> nodes1, NativeArray<ConnectedNode> originalNodes1, Entity node2, EdgeGeometry edgeGeometry1, EdgeNodeGeometry nodeGeometry2, NetCompositionData prefabCompositionData1, NetCompositionData prefabCompositionData2, ref Bounds3 intersection)
-
(and many more variants covering combinations of Edge, Segment, Node Geometry, Triangle2/3, Line segments, Box/Cylinder/Circle, 2D/3D bounds)
These overloads implement the core geometric intersection tests used by ValidateEdge/Object/Area iterators. They are highly optimized, sampling segments with piecewise approximations, taking into account prefab composition data (width/height ranges, buildable areas) and NetCompositionArea masks. -
public static Bounds3 SetHeightRange(Bounds3 bounds, Bounds1 heightRange)
Adjusts the vertical component of a bounds by applying a prefab height offset range. -
public static bool QuadCylinderIntersect(Quad3 quad1, Cylinder3 cylinder2, out Bounds3 intersection1, out Bounds3 intersection2)
Performs intersection tests between a 3D quadrilateral (quad) and a cylinder (used by segment-cylinder collision routines). Returns intersection bounds (floor and ceiling intersections). -
public static bool TriangleCylinderIntersect(Triangle3 triangle1, Cylinder3 cylinder2, out Bounds3 intersection1, out Bounds3 intersection2)
Same as above but for a triangle vs cylinder. -
public static bool QuadIntersect(Quad3 quad1, Quad3 quad2, out Bounds3 intersection1, out Bounds3 intersection2)
public static bool QuadTriangleIntersect(Quad3 quad1, Triangle3 triangle2, out Bounds3 intersection1, out Bounds3 intersection2)
General poly vs poly intersection helpers with output intersection bounds.
Notes about nested iterator structs:
- There are three internal iterator structs used by ValidateEdge to traverse spatial quadtrees:
- NetIterator : used to iterate other nets (edges) in spatial index; contains logic to check net-edge to net-edge overlaps and to enqueue ErrorData.
- ObjectIterator : used to iterate world objects (props/trees/stamps); checks object vs net collisions (3D and 2D collision modes) and enqueues errors.
- AreaIterator : used to iterate area tiles/areas; checks area geometry (protected areas, map tiles, physical area collisions) against the net geometry.
Each iterator carries local copies/references to edge/node geometry, collision masks, composition data, Data (ValidationSystem.EntityData) and a NativeQueue
Usage Example
// Example usage in a mod or custom validation system integration.
// This demonstrates calling the primary ValidateEdge helper. In practice you pass
// the full ValidationSystem.EntityData and the relevant quadtrees/queues used by the game.
using Unity.Collections;
using Unity.Entities;
using Game.Net;
// ... (obtain or construct the following from the game's validation context)
Entity edgeEntity = /* edge entity */;
Temp temp = /* temp component for this edge */;
Owner owner = /* owner component for this edge */;
Fixed fixedElem = /* fixed element info */;
Edge edge = /* edge data */;
EdgeGeometry edgeGeometry = /* edge geometry */;
StartNodeGeometry startNodeGeometry = /* start node geometry */;
EndNodeGeometry endNodeGeometry = /* end node geometry */;
Composition composition = /* composition data */;
PrefabRef prefabRef = /* prefab reference */;
bool editorMode = false;
ValidationSystem.EntityData data = /* validation data */;
NativeList<ValidationSystem.BoundsData> edgeList = new NativeList<ValidationSystem.BoundsData>(Allocator.Temp);
NativeQuadTree<Entity, QuadTreeBoundsXZ> objectSearchTree = /* object quadtree */;
NativeQuadTree<Entity, QuadTreeBoundsXZ> netSearchTree = /* net quadtree */;
NativeQuadTree<AreaSearchItem, QuadTreeBoundsXZ> areaSearchTree = /* area quadtree */;
WaterSurfaceData waterSurfaceData = /* water surface */;
TerrainHeightData terrainHeightData = /* terrain heights */;
NativeQueue<ErrorData>.ParallelWriter errorQueue = /* error queue */;
NativeList<ConnectedNode> tempNodes = new NativeList<ConnectedNode>(Allocator.Temp);
// Run the validation for the edge
ValidationHelpers.ValidateEdge(
edgeEntity,
temp,
owner,
fixedElem,
edge,
edgeGeometry,
startNodeGeometry,
endNodeGeometry,
composition,
prefabRef,
editorMode,
data,
edgeList,
objectSearchTree,
netSearchTree,
areaSearchTree,
waterSurfaceData,
terrainHeightData,
errorQueue,
tempNodes
);
// Inspect errors from errorQueue later in the validation pass
If you plan to call these helpers from a mod, use the same data structures (Entity, component types, NativeQuadTrees, and ValidationSystem.EntityData) the game uses — these helpers are tightly coupled to the game's validation pipeline and rely on its data layout and conventions.