The Slidewalk system, taken from 2400AD is implemented by using several components in Tiled, and hooking them up in C2.
The Slidewalk is comprised of several objects which are the children of an ObjectGroup; the ObjectGroup, in effect, is a single Slidewalk entity.
Components of a Slidewalk
What identifies an existence of Slidewalk is not the ObjectGroup, but the individual Objects which must be named starting with the prefix
sw. Each Object component of the Slidewalk contains the name of the Slidewalk it belongs to. The name of the Slidewalk is the name of the ObjectGroup.
A Slidewalk must always have a path. A path is a Tiled polyline. It must be named
swpath. The path will later define the waypoints of the Slidewalk. The
swpath Object must also contain an attribute called
speed. This is the speed value of this Slidewalk.
A Slidewalk must have at least one entry-only point. This point is defined by using an Object (parented under the Slidewalk in question). It must be named
A Slidewalk must have at least one end-only point. This point must be named
A Slidewalk may optionally have an exit point. This exit point may also be a potential entry point. Every point, whether it is an entry, exit, or end point, must begin with
sw. Then use the keyword
in to indicate this is an entry point, and the keyword
out to indicate it is an exit point; these keywords may be used in the same point, such as
The exit and the end points must also contain a custom property called
exitdir. This is a GridMove direction that specifies which direction the player will move towards when deciding the exit, in order to get off the movement effect of the Slidewalk.
In C2 the first step is to get the
swpathObject to mark the waypoints of the MTiles. In the same procedure, they are marked with the name of the Slidewalk they belong to. The waypoint sequence index is internally based on how Tiled writes it, which is sequential anyway, so the C2 loop iterator does this conveniently.
As the MTiles are being tagged as waypoints, they are being added into the InstGroup with a group named after the Slidewalk’s name, which uniquely identifies these series of MTiles for SLG and GridMove. They are added in the order they are looped, so the sequence is still preserved at this point.
MTiles are then further marked with their entry/exit/end values, as well as the custom properties as inputted in Tiled.
When the player moves on top of the Slidewalk, the On GridMove reach target trigger will check whether the player is on an entry point. If it is, a function called CreatePathFromIG is called whereby it takes the Slidewalk InstGroup waypoints and transfers those waypoints to the player’s own InstGroup moving path. CreatePathFromIG does something more, though: it considers the possibility of multiple entry points; it finds the MTile that the player has entered from, and starts retrieving MTile waypoints from that point until the end.