using System; namespace LobbyRelaySample { /// /// Current state of the user in the lobby. /// This is a Flags enum to allow for the Inspector to select multiples for various UI features. /// [Flags] public enum UserStatus { None = 0, Connecting = 1, // User has joined a lobby but has not yet connected to Relay. Lobby = 2, // User is in a lobby and connected to Relay. Ready = 4, // User has selected the ready button, to ready for the "game" to start. InGame = 8, // User is part of a "game" that has started. Menu = 16 // User is not in a lobby, in one of the main menus. } /// /// Data for a local player instance. This will update data and is observed to know when to push local player changes to the entire lobby. /// [Serializable] public class LocalPlayer : Observed { public CallbackValue IsHost = new CallbackValue(false); public CallbackValue DisplayName = new CallbackValue(""); public CallbackValue Emote = new CallbackValue(EmoteType.None); public CallbackValue UserStatus = new CallbackValue((UserStatus)0); public CallbackValue ID = new CallbackValue(""); public LocalPlayer(string id, bool isHost, string displayName, EmoteType emote = default, UserStatus status = default) { IsHost.Value = isHost; DisplayName.Value = displayName; Emote.Value = emote; UserStatus.Value = status; ID.Value = id; } public void ResetState() { IsHost.Value = false; Emote.Value = EmoteType.None; UserStatus.Value = LobbyRelaySample.UserStatus.Menu; } public override void CopyObserved(LocalPlayer observed) { OnChanged(this); } } }