> For the complete documentation index, see [llms.txt](https://mindcodeinteractive.gitbook.io/easy-build-system/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mindcodeinteractive.gitbook.io/easy-build-system/reference/building-area.md).

# Building Area

Defines an area in the scene where custom building rules are applied to [Building Parts](/easy-build-system/reference/building-part.md).\
Any building action within its bounds is evaluated against configurable [Building Rules](/easy-build-system/reference/building-area/building-rule.md).

***

### How Area Detection Works

When a building action is attempted, the system checks if the part is inside any registered area:

1. The [Building Manager](/easy-build-system/reference/building-manager.md) iterates through all registered [Building Area](/easy-build-system/reference/building-area.md) instances.
2. For each area, it checks if the part’s bounds are contained (fully or partially).
3. If the part overlaps multiple areas, the one with the **highest priority** is selected.
4. The selected area's [Building Rules](/easy-build-system/reference/building-area/building-rule.md) are validated in order. If any rule fails, the action is blocked.
5. If no area contains the part, the action is allowed by default.

When no areas exist in the scene, building is allowed everywhere.\
As soon as you add one or more areas, the system uses them to validate all building actions.

***

### Scripting Examples

Access parts inside an area:

```csharp
List<BuildingPart> parts = area.RegisteredParts;
```

Check if a part is inside an area:

```csharp
BuildingArea area = FindObjectOfType<BuildingArea>();
bool isInside = area.ContainsPart(myBuildingPart);
```

Get the relevant area for a part (highest priority):

```csharp
BuildingArea area = BuildingManager.Instance.GetAreaForPart(myBuildingPart);
if (area != null)
{
    Debug.Log("Part is in area: " + area.AreaType);
}
```

Manually validate rules:

```csharp
ConditionResult result = area.ValidateRules(myPart, BuildingMode.Placement);
if (!result.IsValid)
{
    Debug.Log("Rule failed: " + result.Reason);
}
```

Listen for area registration events:

```csharp
EventPublisher.Subscribe<BuildingAreaEvent.RegisteredEventArgs>(e =>
{
    Debug.Log("Area registered: " + e.Area.AreaType);
});

EventPublisher.Subscribe<BuildingAreaEvent.UnregisteredEventArgs>(e =>
{
    Debug.Log("Area unregistered: " + e.Area.AreaType);
});
```

***

### Debug Visualization

The Building Area draws gizmos in the Scene view to show the zone's shape and size.\
A yellow wireframe sphere or cube shows the bounds, with a semi-transparent fill for volume.

Open the **Debug Settings** section on the component to access debug options.\
Displays the component’s unique ID, registration state, and current part count in the area.

Use **Debug Draw Flags** to control where gizmos render: Scene View, Game View, or both.


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://mindcodeinteractive.gitbook.io/easy-build-system/reference/building-area.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
