TableSeat
A protocol for seats at the table that players occupy.
Declaration
protocol TableSeat : Identifiable where Self.ID == TableSeatIdentifierOverview
To represent seats in your game, follow these steps:
Create a structure that conforms to this protocol.
Set the State type alias to TableSeatState.
Declare the
idproperty as a TableSeatIdentifier structure.Declare the initialState property as a State structure.
Implement an initializer that sets these properties.
struct Seat: TableSeat {
typealias State = TableSeatState
var id: TableSeatIdentifier
var initialState: State
init(index: Int = 0, position: TableVisualState.Point2D) {
id = .seat(index)
initialState = .init(pose: .init(position: position, rotation: .init()))
}
}Then add the seats to the TableSetup object using one of its add methods. For example, use the add(seat:) method to specify a position for the seat.
var setup = TableSetup(tabletop: table)
setup.add(seat: Seat(index: 0, position: .init(x: 0, z: -0.5)))To render seats using RealityKit, conform to the EntityTableSeat protocol instead.