Seat board
Shows who is sitting in an ST Seat, using OnSeatEntered and OnSeatExited.
SeatBoard.cs
using StageTime.SDK;
using TMPro;
/// <summary>
/// On an STSeat: shows who sits (OnSeatEntered / OnSeatExited run on everyone, with the player). The Sit
/// and Stand buttons seat or stand the local player through the station.
/// </summary>
public class SeatBoard : StageTimeBehaviour
{
public TMP_Text label;
private STSeat station;
private int sits;
private void Start()
{
station = GetComponent<STSeat>();
Show("Empty");
}
public override void OnSeatEntered(StageTimePlayer player)
{
sits++;
Show((player != null ? player.displayName : "someone") + " is sitting");
}
public override void OnSeatExited(StageTimePlayer player)
{
Show((player != null ? player.displayName : "someone") + " stood up");
}
public void Sit()
{
if (station != null) station.Sit(Networking.LocalPlayer);
}
public void Stand()
{
if (station != null) station.StandUp(Networking.LocalPlayer);
}
private void Show(string state)
{
if (label != null) label.text = $"{state}\nSits: {sits}";
}
}