<!--
{
  "availability" : [
    "visionOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "TabletopKit",
  "identifier" : "/documentation/TabletopKit/TableSetup",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "TabletopKit"
    ],
    "preciseIdentifier" : "s:11TabletopKit10TableSetupV"
  },
  "title" : "TableSetup"
}
-->

# TableSetup

An object that represents the arrangement of seats, equipment, and counters around the game table.

```
struct TableSetup
```

## Overview

To create a `TableSetup` object, pass an object that conforms to the [`Tabletop`](/documentation/TabletopKit/Tabletop) or [`EntityTabletop`](/documentation/TabletopKit/EntityTabletop) protocol to the [`init(tabletop:)`](/documentation/TabletopKit/TableSetup/init(tabletop:)-4cfut) initializer. For example, implement a `Table` structure that conforms to the `EntityTabletop` protocol and pass an instance of it to the initializer.

```swift
let table = Table()
root = createRootEntity(table: table.entity)
var setup = TableSetup(tabletop: table)
```

Set the protocol properties, such as `shape`, `entity`, and `id` properties for the `EntityTabletop` protocol, in the initializer.

```swift
struct Table: EntityTabletop {
    var shape: TabletopShape
    var entity: Entity
    var id: EquipmentIdentifier
    
    init() {
        self.entity = try! Entity.load(named: "table/table", in: contentBundle)
        self.shape = .round(entity: entity)
        self.id = .table
    }
}
```

Then add seats, equipment, and counters to the `TableSetup` object.

To represent seats, create structures that conform to a seat protocol. To render seats using RealityKit, conform to the [`EntityTableSeat`](/documentation/TabletopKit/EntityTableSeat) protocol and use the [`add(seat:)`](/documentation/TabletopKit/TableSetup/add(seat:)-4alrc) or a similar method to add seats. Otherwise, conform to the [`TableSeat`](/documentation/TabletopKit/TableSeat) protocol and use the [`add(seat:)`](/documentation/TabletopKit/TableSetup/add(seat:)-a9qw) or a similar method to add seats.

```swift
setup.add(seat: Seat(index: 0, position: .init(x: 0, z: -0.5)))
setup.add(seat: Seat(index: 1, position: .init(x: 0, z: +0.5)))
```

To represent equipment, create structures that conform to an equipment protocol. To render equipment using RealityKit, conform to the [`EntityEquipment`](/documentation/TabletopKit/EntityEquipment) protocol and use the [`add(equipment:)`](/documentation/TabletopKit/TableSetup/add(equipment:)-24tv6) or a similar method to add equipment. Otherwise, conform to the [`Equipment`](/documentation/TabletopKit/Equipment) protocol and use the [`add(equipment:)`](/documentation/TabletopKit/TableSetup/add(equipment:)-29pef) or a similar method to add equipment.

```swift
setup.add(equipment: Piece(position: .init(x: 0, z: 0.1)))
setup.add(equipment: Card(index: 0, faceUp: true, position: .init(x: -0.1, z: 0)))
setup.add(equipment: Card(index: 1, faceUp: true, position: .init(x: +0.1, z: 0)))
setup.add(equipment: Die(index: 0, position: .init(x: 0, z: 0.2)))
```

Some equipment can represent a group, such as a player’s hand in a card game. To organize equipment hierarchically, set the [`parentID`](/documentation/TabletopKit/EquipmentState/parentID) property of the [`State`](/documentation/TabletopKit/Equipment/State) property during gameplay. In your equipment structure implementation, you can override the [`layoutChildren(for:visualState:)`](/documentation/TabletopKit/Equipment/layoutChildren(for:visualState:)) method to lay out the containing equipment.

Optionally, add one or more [`ScoreCounter`](/documentation/TabletopKit/ScoreCounter) objects to the `TableSetup` object to keep score of the game. Use either the [`add(counter:)`](/documentation/TabletopKit/TableSetup/add(counter:)) or [`add(counters:)`](/documentation/TabletopKit/TableSetup/add(counters:)) method to add score counters.

Finally, create the [`TabletopGame`](/documentation/TabletopKit/TabletopGame) instance from the `TableSetup` object by passing it to the [`init(tableSetup:version:)`](/documentation/TabletopKit/TabletopGame/init(tableSetup:version:)) initializer.

```swift
game = TabletopGame(tableSetup: setup)
```

## Topics

### Creating a setup object from a table

[`init(tabletop: some Tabletop)`](/documentation/TabletopKit/TableSetup/init(tabletop:)-4cfut)

[`init(tabletop: some EntityTabletop)`](/documentation/TabletopKit/TableSetup/init(tabletop:)-7ima6)

### Adding seats to place players

[`func add(seat: some TableSeat)`](/documentation/TabletopKit/TableSetup/add(seat:)-a9qw)

Add the given seat to the table setup.

[`func add(seat: some EntityTableSeat)`](/documentation/TabletopKit/TableSetup/add(seat:)-4alrc)

[`func add(seats: some Sequence)`](/documentation/TabletopKit/TableSetup/add(seats:)-4068d)

Add the given seats to the table setup.

[`func add(seats: some Sequence)`](/documentation/TabletopKit/TableSetup/add(seats:)-4asnu)

### Adding equipment for gameplay

[`func add(equipment: some Equipment)`](/documentation/TabletopKit/TableSetup/add(equipment:)-29pef)

Add the given equipment to the table setup.

[`func add<E>(equipment: E)`](/documentation/TabletopKit/TableSetup/add(equipment:)-294gb)

[`func add(equipment: some EntityEquipment)`](/documentation/TabletopKit/TableSetup/add(equipment:)-24tv6)

[`func add<E>(equipment: E)`](/documentation/TabletopKit/TableSetup/add(equipment:)-7qwj2)

Add the given equipment to the table setup.

[`func add(equipment: some Sequence)`](/documentation/TabletopKit/TableSetup/add(equipment:)-4k6m6)

Add the given equipment to the table setup.

[`func add<E>(equipment: some Sequence)`](/documentation/TabletopKit/TableSetup/add(equipment:)-3d7h9)

[`func add(equipment: some Sequence)`](/documentation/TabletopKit/TableSetup/add(equipment:)-9syh2)

[`func add<E>(equipment: some Sequence)`](/documentation/TabletopKit/TableSetup/add(equipment:)-9h887)

Add the given equipment to the table setup.

### Adding counters to keep score

[`func add(counter: ScoreCounter)`](/documentation/TabletopKit/TableSetup/add(counter:))

[`func add(counters: some Sequence<ScoreCounter>)`](/documentation/TabletopKit/TableSetup/add(counters:))

### Registering an action

[`func register<Action>(action: Action.Type)`](/documentation/TabletopKit/TableSetup/register(action:))

Register a custom action of given type. Each type of custom action needs to be registered before it can be used.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)