Starting to shift responsibility off of lobby. Now, once a player is connected to Relay, the local player data will update from that instead of from the lobby. The data are still written to the lobby currently, however.
m_localLobby.AddPlayer(m_localUser);// The local LobbyUser object will be hooked into UI before the LocalLobby is populated during lobby join, so the LocalLobby must know about it already when that happens.
elseif(type==MessageType.UserSetEmote)// TODO: oh what are these doing here
{
EmoteTypeemote=(EmoteType)msg;
m_localUser.Emote=emote;
m_localUser.DisplayName="New Player";
Locator.Get.Messenger.Subscribe(this);
DefaultObserverSetup();
InitObservers();
BeginObservers();
}
/// <summary>
Debug.LogWarning($"Scene has less than the default expected Lobby Service Observers, ensure all the observers in the scene that need to watch the lobby service state are registered in the LobbyServiceObservers List.");
}
voidInitObservers()
voidBeginObservers()
{
if(gameStateObs==null)
{
Debug.LogError("Missing a gameStateObserver, please make sure all GameStateObservers in the scene are registered here.");
continue;
}
}
foreach(varserviceObsinm_LobbyServiceObservers)
serviceObs.BeginObserving(m_lobbyServiceData);
{
if(lobbyObs==null)
{
Debug.LogError("Missing a gameStateObserver, please make sure all GameStateObservers in the scene are registered here.");
continue;
}
}
{
if(userObs==null)
{
Debug.LogError("Missing a gameStateObserver, please make sure all GameStateObservers in the scene are registered here.");
continue;
}
}
foreach(varserviceObsinm_LobbyServiceObservers)
{
if(serviceObs==null)
{
Debug.LogError("Missing a gameStateObserver, please make sure all GameStateObservers in the scene are registered here.");
/// A local wrapper around a lobby's remote data, with additional functionality for providing that data to UI elements and tracking local player objects.
// TODO: It might make sense to change UpdateSlow to, rather than have a fixed cycle on which everything is bound, be able to track when each thing should update?
// I.e. what I want here now is for when a lobby async request comes in, if it has already been long enough, it immediately fires and then sets a cooldown.
// This is still necessary for detecting new players, although I think we could hit a case where the relay join ends up coming in before the cooldown?
// So, we should be able to create a new LobbyUser that way as well.
// That is, creating a (local) player via Relay or via Lobby should go through the same mechanism...? Or do we hold onto the Relay data until the player exists?
LocalLobby.LobbyDatainfo=newLocalLobby.LobbyData// Technically, this is largely redundant after the first assignment, but it won't do any harm to assign it again.
State=lobby.Data?.ContainsKey("State")==true?(LobbyState)int.Parse(lobby.Data["State"].Value):LobbyState.Lobby,// TODO: Consider TryParse, just in case (and below). Although, we don't have fail logic anyway...
// If the player isn't connected to Relay, or if we just don't know about them yet, get the most recent data that the lobby knows. // TODO: Relay should handle the latter case.
// (If we have no local representation of the player, that gets added by the LocalLobby.)
LobbyUserincomingData=newLobbyUser();// TODO: This is unclear; this should be just a data object replacing that of the user, not a new user whose data are taken.