Splines
Spline pieces follow a path of points: fences, walls, roads, paths, rails, pipes, cables. Later the factory add-on uses the same pieces for belts.
Making a spline piece
- Set the piece’s Placement to Spline.
- Add the Spline trait (
FPulseBuildPieceTrait_Spline):
| Property | Meaning |
|---|---|
SegmentMesh, SegmentMeshTransform, SegmentForwardAxis | Mesh bent along every segment (road surface, fence boards, pipe). Its X axis runs along the spline (Z for an upright cylinder used as a pipe); the transform scales and offsets it across (Y = width, Z = height). |
TileMesh, TileSpacing | Mesh repeated along the spline (posts, lamps) |
PointMesh | Mesh at every point (corner posts) |
Width | Width and height for overlap checks and bounds |
MinSegmentLength, MaxSegmentLength | Shortest segment; longer segments are split |
MaxSlope, MaxTurnAngle | Steepest segment, sharpest turn between two segments |
MaxPoints | Most points of one piece (longer runs are new pieces) |
bFollowTerrain, GroundOffset | Points and segments follow the ground (traces); off: straight segments (bridges) |
AngleSnap | Snaps the direction of new segments (45 for grid-like layouts); 0 = free |
Shapers | Shape the points while the player places the piece, in order (see Shaping the points); empty: the points are where the player aims |
ConnectionTags, ConnectRadius | What the ends connect to (see below) and how close an end must be to snap |
bConnectToTakenEnds | Ends also connect where other splines already meet (switches of rails, branches of pipes); off by default |
bAllowSplitAndJoin | Players may split and join the piece (default on); off for pieces whose halves would lose what other systems keep for them (a belt with its items) |
bCheckRulesOnEdit | Setting the points of the placed piece checks them like placing it there (default on, see Editing); off: only the limits, the range and the permission to change it |
Spline segments are spline mesh components inside the cluster; the points are a saved state of the piece (FPulseBuildPieceState_Spline).
Placing a spline
With a spline piece selected, every Confirm sets the next point. The preview shows the spline so far and the next segment, red when a limit is broken. FinishSpline places the piece from the points set so far (at least two); RemoveLastSplinePoint takes a point back. When an end snaps to a connection the spline is placed by itself.
Shaping the points
Shapers (FPulseBuildSplineShaper, instanced structs in Shapers of the Spline trait) decide how the points follow the aim: on a grid, in angle steps, with fixed slopes, with a straight run out of a port. They run on the client for the preview, in their order, and keep no state:
ShapeAim(Context, InOutAim)moves the aim of the next point, afterAngleSnapand before the aim snaps to a connection. If the shaped aim is out of reach of the port the player aims at, the unshaped aim still snaps to it.AddPointsBeforeEnd(Context, End, OutPoints)adds points between the last point of the player and an end that snapped to a connection (corners, ramps, a run into the port). The placement keeps them inAddedPointsofFPulseBuildPlacementExtra_Spline;Confirmkeeps them with the end (Pulse::Build::Spline::AddConfirmedPoints), soFinishSplineplaces them too. IfFinishSplinedoes not place the piece, the added points and the end are taken back, soRemoveLastSplinePointremoves points of the player only.AddedPointsis for the client only: the server empties it in every placement it receives (PlacePiece), so no rule there reads corner points a client sent; the corners are part ofPoints.
In C++, add a shaper with its type named: TInstancedStruct<FPulseBuildSplineShaper>::Make<FMyShaper>(Shaper). Without the type, Make(Shaper) with a value that is not const (or a temporary) keeps only the empty base shaper.
The context (FPulseBuildSplineShapeContext) has the placement input, the trait, the points of the player, the connection of the end and the connection at the first point (StartConnection, a port the spline starts at).
Shapers only draw. The points they make are checked like every other points: the limits of the trait, and the rules on the client and again on the server. Without shapers the points are exactly what they were before shapers existed.
Octilinear splines with fixed slopes
The Octilinear shaper (FPulseBuildSplineShaper_Octilinear) draws belts, rails and roads on a grid. Every value is a property of the shaper on the piece, so each piece can have its own:
| Property | Default | Meaning |
|---|---|---|
AngleStep | 45 | Directions in the ground plane in steps of this (90: only along the grid); 0 = any direction |
Slopes | 0, 15, 30 | Allowed slopes of a segment in degrees, up and down; empty = any slope up to MaxSlope |
LeadLength | 100 cm | Straight run out of a port (first segment) and into a port (last segment) |
bSnapToGrid | on | The first point lies on a cell center, later segments are whole cells long (diagonals of square cells too) |
GridCellSize | 0 | Cell size in the ground plane; 0 uses GridCellSize of the Pulse Build settings |
- The aim snaps to the angle steps, to whole cells and to the allowed slope nearest to it. Steps that do not divide 360 count from 0 degrees.
- The first segment of a spline that starts at a port runs straight out of it, at least
LeadLengthlong; withbSnapToGridit ends on the nearest cell center along the run (on the grid when the port is). A port turned off the steps (a machine on a free rotation) is left in the step nearest to its direction. - Before a port (or another end) the spline turns in two segments of the angle steps, takes a height difference with a ramp of the gentlest allowed slope that fits on the way and runs
LeadLengthstraight into the port (in the step nearest to the port’s direction). A spline of one segment from a port to a port leaves the start port straight first. If no allowed slope reaches the height, no points are added and the spline is refused. - No segment gets shorter than
MinSegmentLengthof the trait: a corner with a shorter leg is left out (the rule then says why the route is refused), and a ramp ends on a point of the route or a whole segment away from them (the gentlest slope where that holds). A height difference of a few millimetres spreads over the whole way. - Turn
bFollowTerrainoff (points on the ground have any slope) and allow turns of the angle step inMaxTurnAngle.
Checking the shape
The Spline Shape rule (FPulseBuildRule_SplineShape) refuses points that are not of the shape: on the client for the preview and on the server, for placing, blueprints and edits of the points. Put it into the Rules of the piece next to the shaper. With bUseShaper (on) it takes AngleStep and Slopes from the first Octilinear shaper of the piece, so they are set once; without one it uses its own AngleStep and Slopes. Tolerance (0.5 degrees) is how far a direction or a slope may be off. Data validation warns about a piece with an Octilinear shaper and no Spline Shape rule (in its Rules, or in the default rules of the settings when bUseDefaultRules is on).
| Reason | Text |
|---|---|
Pulse.Result.Failure.Build.SplineAngle | This direction is not allowed. (message: “Segments run in steps of 45 degrees.”) |
Pulse.Result.Failure.Build.SplineSlope | This slope is not allowed. (message: “A slope of 20 degrees is not allowed here.”) |
The check is Pulse::Build::Spline::CheckShape(Points, AngleStep, Slopes, Tolerance) for rules of your own. Blueprints keep the shape when they are turned by a multiple of the angle step; other turns are refused.
Connections
Ends of spline pieces connect to:
- ends and inner points of other spline pieces with a matching type (road to road, pipe to pipe),
- sockets of other pieces whose type is in
ConnectionTags(a crossing piece, a pipe port on a machine).
Crossings and junctions are normal pieces with sockets of the spline’s type (the spline kit has a road crossing).
An end snaps to the nearest end at a place. Where two splines meet already, only one of them counts as connected and the other is in the way, so a third spline cannot start there. A piece with bConnectToTakenEnds (a rail switch, a pipe branch) connects to every spline end at the joint (Pulse::Build::Spline::FindEndsAt), on the client and when the server checks the placement. GetConnectedPieces then lists every spline end at that joint, for the plain splines there too, so a network graph has all edges. Once a joint has such a piece, a plain spline placed there later connects to every end there as well and is not in the way.
If two connections are equally near (within 1 cm, squared distance), Pulse::Build::Spline::FindConnection picks one in a fixed order, never by the order of the query: a socket before a spline end, then the lower piece id, then the socket name. Besides the nearest connection, every piece that is no spline and has a socket of a fitting type within 1 cm of an end counts as connected (in the placement, on the server and in GetConnectedPieces), e.g. a support two belts meet at: both belts list the support and, at a joint, each other.
Editing
| Request | What it does |
|---|---|
RequestSetSplinePoints(Id, Points) | Replaces the points (move, insert, delete points); costs and refunds follow the length |
RequestSplitSpline(Id, Location) | Splits a piece into two at a location |
RequestJoinSplines(FirstId, SecondId) | Joins two pieces that share an end |
RequestSetSplinePoints checks the new points like placing the piece there, before anything is paid: the limits, the connections found again, the default rules (No Overlap, a rule of the game) and the rules of the piece (for example Spline Shape), permissions and zones; the piece itself is left out. So an edit cannot make what placing would refuse. The catalog and the lock are not checked, as for moving: the piece is placed already, so pieces of a world seed, a save or a catalog that has shrunk since can be edited with bRequireCatalog on. The authority function Pulse::Build::Spline::SetSplinePoints (no catalog, permissions or zones) checks the limits and the rules as well, with the ground under the first point for surface rules and the owner of the piece; code that restores points it checked before passes EPulseBuildRuleCheck::Skip. A piece with bCheckRulesOnEdit off (Spline trait, Editing) is checked as before: the limits, the range and the permission to change it. Undo and redo restore the pieces as they were without the rules (overlaps, permissions, zones, claims and limits only), so an undo still works after a rule was added.
Moving a spline piece (RequestMove, the Move tool) is no edit: the server carries the stored points with the sent transform (turned around the first point, no scale) and ignores spline points in the placement of the request, so a move keeps length, shape and value. Only RequestSetSplinePoints changes the shape, and it pays or refunds the difference.
Splitting and joining (SplitSpline, JoinSplines and their requests) do not run the placement rules: they reuse segments that were checked when they were placed or edited. Joining checks the limits of the joined points (CheckLimits), splitting only cuts.
Pieces with bAllowSplitAndJoin off refuse splitting and joining (Pulse::Build::Spline::CanSplitAndJoin; the requests answer Not Allowed, SplitSpline and JoinSplines return an invalid id or false).
Costs
With bScaleWithLength in the Costs trait (default) the costs are per LengthUnit (default 100 cm) of length: a 3 m fence with a cost of 1 point costs 3 points. Editing pays or refunds the difference; removing refunds the part of the value set by RefundFraction.