> For the complete documentation index, see [llms.txt](https://aukke-production.gitbook.io/aukkebuildingsystemdocs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://aukke-production.gitbook.io/aukkebuildingsystemdocs/runtime-systems.md). Agents can also search and read this documentation through its [MCP server](https://aukke-production.gitbook.io/aukkebuildingsystemdocs/~gitbook/mcp).

# Runtime Systems

## The Hologram

`ABuildingHologram` mirrors whatever `PieceClass` you give it: mesh, offset, snap radius, occupancy and clearance settings, all pulled from that class's defaults, so the preview is exactly what gets built. It traces every frame (or on whatever interval `PlacementUpdateInterval` sets), out to `TraceDistance`, checks for a snap point, checks it isn't blocked, and reports back through `IsPlacementValid()`.

Swap `ValidMaterial` / `InvalidMaterial` for feedback. Subclass it freely for extra polish, particles, sound, UI.

If you're building your own placement UI, or just want to know what the hologram is about to attach to, four getters expose the current match:

* `GetMatchedParentPiece()`
* `GetMatchedParentPieceID()`
* `IsMatchedParentInstance()`
* `GetMatchedSnapPointIndex()`

Exactly one of `GetMatchedParentPiece()` and `GetMatchedParentPieceID()` is meaningful at a time. `IsMatchedParentInstance()` tells you which.

## The Component You Attach to a Pawn

`UBuildingComponent` drives everything above from your own input bindings. It makes no assumption about Enhanced Input or anything else, it never touches your input system, you call it.

| Function                                                       | Does                                                                       |
| -------------------------------------------------------------- | -------------------------------------------------------------------------- |
| `EnterBuildMode()` / `ExitBuildMode()`                         | Spawns or destroys the hologram                                            |
| `SetCurrentPieceClass(Class)`                                  | Switches what's being previewed                                            |
| `TryConfirmPlacement()`                                        | Spawns the real piece, if valid and `CanConfirmPlacement` agrees           |
| `EnterDemolishMode()` / `ExitDemolishMode()`                   | Starts or stops targeting for demolition                                   |
| `TryDemolishPiece()`                                           | Destroys the target, bypassing health, if `CanDemolishPiece` agrees        |
| `SetBuildingMode(EBuildingMode)`                               | One switch for all of the above                                            |
| `IsInBuildMode()` / `IsInDemolishMode()` / `GetBuildingMode()` | Query which mode is currently active, handy for showing or hiding build UI |

`PlacementUpdateInterval` controls how often the hologram re-traces while active (0 means every frame), and `DemolishTraceDistance` is the equivalent range limit for targeting something to demolish. `CurrentDemolishTarget` / `CurrentDemolishTargetID` hold whatever's currently targeted, read-only, useful for drawing a crosshair label.

Three delegates are worth hooking into for feedback:

* `OnPiecePlaced` after a successful `TryConfirmPlacement` (Actor or ID, exactly one is valid)
* `OnPieceDemolished` right before `TryDemolishPiece` destroys something
* `OnDemolishTargetChanged` whenever the targeted piece changes while in demolish mode, the natural place to toggle a highlight on the old and new target

For an instance-based target, that highlight goes through `UBuildingChunkSubsystem::SetPieceInstanceCustomDataValue`; see [Chunking](#chunking) below for the custom data setup that makes that work.

## The Registry

`UBuildingRegistrySubsystem` exists automatically, one per world, nothing to configure. It's the one place that always knows about a piece, Actor or not.

Querying it directly is one call:

```cpp
FBuildingPieceData Data;
if (Registry->GetPieceData(SomePieceID, Data))
{
    // Data.CurrentHealth, Data.PieceType, Data.Transform, whatever you need
}
```

`HasPiece(PieceID)` and `GetAllRegisteredPieceIDs()` round out the read side. `RegisterPiece` / `UnregisterPiece` and `DestroyInstancePiece`—the single entry point for fully removing an instance-based piece, snap point and ISM instance included—exist mostly for the plugin's own placement and save code. You'll rarely need to call them yourself.

Three delegates are worth binding to:

* **`OnPieceRegistered`** / **`OnPieceUnregistered`** fire around entry and removal.
* **`OnAnyPieceDestroyed`** fires no matter what destroyed a piece or which representation it was. This is the reliable one for anything reacting to destruction game-wide, more so than the component's own demolish event (player-driven only) or a per-Actor destroyed event (Actor-backed only).

## Chunking

The world splits into a grid of chunks, 5000 units per cell by default, tunable, each holding one ISM component per distinct mesh used inside it. Chunks appear only as pieces get placed in them; nothing is pre-built for an assumed map size.

You never touch a chunk directly. `UBuildingChunkSubsystem` resolves the right one for every operation:

* `AddPieceInstance`
* `RemovePieceInstance`
* `UpdatePieceInstanceTransform`
* `SetPieceInstanceCustomDataValue`

It includes moving an instance across a cell boundary transparently. `SetPieceInstanceCustomDataValue` is how you drive a highlight on an instance-based piece: use a "Per Instance Custom Data" material node reading the value you set.

{% hint style="info" %}
Set `NumInstanceCustomDataFloats` before anything gets placed. It won't retroactively apply to components that already exist.
{% endhint %}

## Collision Channels

Everything above traces against `Visibility` by default.

| Property                  | On                      |
| ------------------------- | ----------------------- |
| `TraceChannel`            | `ABuildingHologram`     |
| `DemolishTraceChannel`    | `UBuildingComponent`    |
| `InteractionTraceChannel` | `UInteractionComponent` |

{% hint style="warning" %}
If your project already leans on `Visibility` for camera collision or AI sight lines, point these three at a dedicated trace channel instead (**Project Settings > Collision**), so building queries never interfere with anything else.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://aukke-production.gitbook.io/aukkebuildingsystemdocs/runtime-systems.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
