Ss14 transform system core

From space-sunrise/sunrise-station · View interactive version

Ss14 transform system core is an AI agent skill from the GitHub repository space-sunrise/sunrise-station. An in-depth practical guide to TransformSystem in Space Station 14: coordinate model (EntityCoordinates/MapCoordinates), parent-grid-map hierarchy, safe movement, anchor/unbind and client/server patterns. Use for teleports, entity transfers, containers, anchoring and spatial optimizations.

How to use this skill

Skill file

TransformSystem: Core

This skill covers exactly the architecture and working techniques of TransformSystem :)

For the full API catalog, see the separate skill SS14 Transform System API.

Mental model

Transform to SS14 = space tree:

  1. ParentUid: immediate parent in the hierarchy.
  2. GridUid: the grid on which the entity is located (or null).
  3. MapUid / MapID: the card where the entity is located.
  4. EntityCoordinates: local coordinates relative to ParentUid.
  5. MapCoordinates: world coordinates inside the map.

Key idea:

Moving pattern

Basic flow when moving through SetCoordinates(...):

  1. If necessary, remove the anchor (Unanchor), if the movement allows it.
  2. Update the local position/rotation and, when changing the parent, recalculate the map/grid membership.
  3. Raise motion events (MoveEvent, EntParentChangedMessage) and update spatial subsystems.
  4. Perform post-step traversal so that the entity ends up on the correct grid/map parent.

Practical consequence:

Quick API selection

  1. Need to shift in local space without changing parent?
  1. Need to be placed at a world point/angle?
  1. Do you need to transfer between parent-space (container/entity/grid/map)?
  1. Should I “put it next to it” taking into account the containers?
  1. Do you need to correctly compare the distance between different parent-spaces?

Patterns

Anti-patterns

Code examples

Example 1: safe dash with parent-space normalization

// 1) Transfer the entity to the target EntityCoordinates (from the ability).
_transform.SetCoordinates(user, xform, args.Target);

// 2) Normalize parent to the actual grid/map at the target point.
_transform.AttachToGridOrMap(user, xform);

Example 2: “implanting” a projectile using SetParent

// We stop physics and make the projectile static.
_physics.SetLinearVelocity(projectile, Vector2.Zero, body: body);
_physics.SetBodyType(projectile, BodyType.Static, body: body);

// Re-attach the projectile to the target.
_transform.SetParent(projectile, projectileXform, target);

// We apply local offset after the parent-change.
_transform.SetLocalPosition(
    projectile,
    projectileXform.LocalPosition + rotation.RotateVec(embedOffset),
    projectileXform);

Example 3: overlay rendering using world+inv matrix

var (_, _, worldMatrix, invWorldMatrix) =
    _transform.GetWorldPositionRotationMatrixWithInv(gridXform, xforms);

// We translate the camera bounds into local grid coordinates.
var localBounds = invWorldMatrix.TransformBox(worldBounds).Enlarged(grid.TileSize * 2);

// We draw in the local space of the grid.
drawHandle.SetTransform(worldMatrix);

Example 4: anchoring/unanchoring using system methods only

if (!xform.Anchored)
    _transform.AnchorEntity(uid, xform);

// ...game logic...

if (xform.Anchored)
    _transform.Unanchor(uid, xform);

Example 5: pop-up direction via mover-coordinates

// MoverCoordinates gives operational coordinates in grid/map terms.
var moverCoords = _transform.GetMoverCoordinates(observer);

// Based on them, we select the side of the signature.
var horizontalDir = moverCoords.X <= popupOrigin.X ? 1f : -1f;

Server and client usage guidelines

Mini-checklist before changes

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.