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

# Equipment

A protocol for equipment that players directly interact with in a game.

```
protocol Equipment : Identifiable where Self.ID == EquipmentIdentifier
```

## Overview

To represent equipment in your game, such as cards, pieces, and dice, following these steps:

- Create a structure that conforms to this protocol.
- Declare the [`initialState`](/documentation/TabletopKit/Equipment/initialState) property as either
  [`BaseEquipmentState`](/documentation/TabletopKit/BaseEquipmentState), [`DieState`](/documentation/TabletopKit/DieState), or [`CardState`](/documentation/TabletopKit/CardState), depending on the type of data you want TabletopKit to sync between players. For more complex data, use [`RawValueState`](/documentation/TabletopKit/RawValueState).
- Declare the `id` property as a [`EquipmentIdentifier`](/documentation/TabletopKit/EquipmentIdentifier) structure.
- Implement an initializer that sets the `id` and [`initialState`](/documentation/TabletopKit/Equipment/initialState) properties.

Optionally, implement the [`layoutChildren(for:visualState:)`](/documentation/TabletopKit/Equipment/layoutChildren(for:visualState:)) method for equipment that represents groups, and the [`restingOrientation(state:)`](/documentation/TabletopKit/Equipment/restingOrientation(state:)) method to provide a custom resting orientation.

## Topics

### Gettting the initial state of the equipment

[`var initialState: Self.State`](/documentation/TabletopKit/Equipment/initialState)

[`associatedtype State : EquipmentState`](/documentation/TabletopKit/Equipment/State)

### Displaying the equipment

[`func layoutChildren(for: TableSnapshot, visualState: TableVisualState) -> any EquipmentLayout`](/documentation/TabletopKit/Equipment/layoutChildren(for:visualState:))

This function provides the layout of the direct children of this equipment and is called whenever the snapshot changes.
Override it to provide a custom layout.
The output of this function is considered to be only a function of its inputs. Reaching out to data outside what is provided might result in undefined behavior.   

[`func restingOrientation(state: Self.State) -> Rotation3D`](/documentation/TabletopKit/Equipment/restingOrientation(state:))

The resting orientation of the equipment given the current State.         

## Relationships

### Inherited By

[`EntityEquipment`](/documentation/TabletopKit/EntityEquipment)

### Inherits From

[`Identifiable`](/documentation/Swift/Identifiable)

---

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)