Esempio n. 1
0
        private T TryGetLobbyData <T>(ISteamMatchMakingService matchMakingService, Steamworks.SteamID steamIDLobby, string lobbyDataKey, bool validationRequired = true)
        {
            string lobbyData = matchMakingService.SteamMatchMaking.GetLobbyData(steamIDLobby, lobbyDataKey);

            if (!string.IsNullOrEmpty(lobbyData))
            {
                try
                {
                    if (typeof(T).IsEnum)
                    {
                        return((T)((object)Enum.Parse(typeof(T), lobbyData)));
                    }
                    return((T)((object)Convert.ChangeType(lobbyData, typeof(T))));
                }
                catch
                {
                }
            }
            if (validationRequired)
            {
                Diagnostics.LogWarning("ELCP: Lobby Data {0} {1} failed to validate", new object[]
                {
                    lobbyDataKey,
                    (lobbyData == null) ? "null" : lobbyData
                });
                this.IsValid = false;
            }
            return(default(T));
        }
Esempio n. 2
0
        public LobbyDescription(ISteamMatchMakingService matchMakingService, Steamworks.SteamID steamIDLobby)
        {
            this.IsValid         = true;
            this.SteamIDLobby    = steamIDLobby;
            this.MajorFactions   = this.TryGetLobbyData <int>(matchMakingService, steamIDLobby, "NumberOfMajorFactions", true);
            this.Name            = this.TryGetLobbyData <string>(matchMakingService, steamIDLobby, "name", true);
            this.AdvancedSeasons = this.TryGetLobbyData <bool>(matchMakingService, steamIDLobby, "AdvancedSeasons", true);
            this.DownloadableContentSharedByServer = this.TryGetLobbyData <uint>(matchMakingService, steamIDLobby, "sbs", false);
            this.EmpireInfoAccessibility           = this.TryGetLobbyData <string>(matchMakingService, steamIDLobby, "EmpireInfoAccessibility", true);
            this.FreeSlots         = this.TryGetLobbyData <int>(matchMakingService, steamIDLobby, "FreeSlots", true);
            this.GameDifficulty    = this.TryGetLobbyData <string>(matchMakingService, steamIDLobby, "GameDifficulty", true);
            this.GameHasEnded      = this.TryGetLobbyData <bool>(matchMakingService, steamIDLobby, "_GameHasEnded", false);
            this.GameInProgress    = this.TryGetLobbyData <bool>(matchMakingService, steamIDLobby, "_GameInProgress", false);
            this.GameIsMigrating   = this.TryGetLobbyData <bool>(matchMakingService, steamIDLobby, "_GameIsMigrating", false);
            this.GameSpeed         = this.TryGetLobbyData <string>(matchMakingService, steamIDLobby, "GameSpeed", true);
            this.Hash              = this.TryGetLobbyData <string>(matchMakingService, steamIDLobby, "runtimehash", true);
            this.IsMultiplayerSave = this.TryGetLobbyData <bool>(matchMakingService, steamIDLobby, "_IsSavedGame", false);
            this.Launching         = this.TryGetLobbyData <bool>(matchMakingService, steamIDLobby, "_Launching", false);
            this.OccupiedSlots     = this.TryGetLobbyData <int>(matchMakingService, steamIDLobby, "OccupiedSlots", true);
            string text = this.TryGetLobbyData <string>(matchMakingService, steamIDLobby, "runtimeconfiguration", true);

            this.RuntimeConfiguration = ((!string.IsNullOrEmpty(text)) ? text.Split(Amplitude.String.Separators) : null);
            this.SeasonDifficulty     = this.TryGetLobbyData <string>(matchMakingService, steamIDLobby, "SeasonDifficulty", true);
            this.PlayWithMadSeason    = this.TryGetLobbyData <bool>(matchMakingService, steamIDLobby, "PlayWithMadSeason", true);
            this.PlayWithKaiju        = this.TryGetLobbyData <bool>(matchMakingService, steamIDLobby, "PlayWithKaiju", true);
            this.MadSeasonType        = this.TryGetLobbyData <string>(matchMakingService, steamIDLobby, "MadSeasonType", true);
            this.SessionMode          = this.TryGetLobbyData <SessionMode>(matchMakingService, steamIDLobby, "SessionMode", true);
            this.SteamIDOwner         = this.TryGetLobbyData <ulong>(matchMakingService, steamIDLobby, "Owner", true);
            this.TimedEncounters      = this.TryGetLobbyData <bool>(matchMakingService, steamIDLobby, "TimedEncounter", true);
            this.TimedTurns           = this.TryGetLobbyData <bool>(matchMakingService, steamIDLobby, "TimedTurn", true);
            this.Turn = this.TryGetLobbyData <int>(matchMakingService, steamIDLobby, "_Turn", true);
            long version = this.TryGetLobbyData <long>(matchMakingService, steamIDLobby, "Version", true);

            this.Version            = new Amplitude.Unity.Framework.Version(version);
            this.WithCustomFactions = this.TryGetLobbyData <bool>(matchMakingService, steamIDLobby, "CustomFactions", true);
            this.WorldShape         = this.TryGetLobbyData <string>(matchMakingService, steamIDLobby, "WorldShape", true);
            this.WorldSize          = this.TryGetLobbyData <string>(matchMakingService, steamIDLobby, "WorldSize", true);
            this.WorldTemperature   = this.TryGetLobbyData <string>(matchMakingService, steamIDLobby, "Temperature", true);
            this.WorldWrap          = this.TryGetLobbyData <string>(matchMakingService, steamIDLobby, "WorldWrap", true);
            this.VictoryConditions  = null;
            IDatabase <VictoryCondition> database = Databases.GetDatabase <VictoryCondition>(false);

            if (database != null)
            {
                List <VictoryCondition> list = new List <VictoryCondition>();
                foreach (VictoryCondition victoryCondition in database)
                {
                    if (this.TryGetLobbyData <bool>(matchMakingService, steamIDLobby, victoryCondition.Name, false))
                    {
                        list.Add(victoryCondition);
                    }
                }
                this.VictoryConditions = list.ToArray();
            }
            this.InitializeFlags();
        }
Esempio n. 3
0
 public void Close()
 {
     if (this.opened || this.opening || this.reopening)
     {
         this.opened    = false;
         this.opening   = false;
         this.reopening = false;
         if (this.SteamMatchMakingService != null)
         {
             this.SteamMatchMakingService.SteamLobbyChatMsg     -= this.SteamMatchMakingService_SteamLobbyChatMsg;
             this.SteamMatchMakingService.SteamLobbyChatUpdate  -= this.SteamMatchMakingService_SteamLobbyChatUpdate;
             this.SteamMatchMakingService.SteamLobbyDataUpdate  -= this.SteamMatchMakingService_SteamLobbyDataUpdate;
             this.SteamMatchMakingService.SteamLobbyEnter       -= this.SteamMatchMakingService_SteamLobbyEnter;
             this.SteamMatchMakingService.SteamLobbyGameCreated -= this.SteamMatchMakingService_SteamLobbyGameCreated;
             this.SteamMatchMakingService.SteamLobbyInvite      -= this.SteamMatchMakingService_SteamLobbyInvite;
             this.SteamMatchMakingService.SteamLobbyKicked      -= this.SteamMatchMakingService_SteamLobbyKicked;
             ISteamClientService service = Services.GetService <ISteamClientService>();
             Diagnostics.Assert(service != null);
             service.ClientSteamServersDisconnected  -= this.ISteamClientService_ClientSteamServersDisconnected;
             service.ClientSteamServerConnectFailure -= this.ISteamClientService_ClientSteamServerConnectFailure;
             service.ClientP2PSessionConnectFail     -= this.ISteamClientService_ClientP2PSessionConnectFail;
             if (this.SteamIDLobby != null)
             {
                 this.SteamMatchMakingService.SteamMatchMaking.LeaveLobby(this.SteamIDLobby);
                 this.SteamIDLobby = null;
             }
             this.SteamMatchMakingService = null;
         }
         if (!this.disposing)
         {
             this.OnSessionChange(new SessionChangeEventArgs(SessionChangeAction.Closed, this));
         }
         this.hosting = false;
     }
     if (Session.lobbyCreatedCallback != null)
     {
         Session.lobbyCreatedCallback = null;
         if (this.lobbyCreatedCallResult != null)
         {
             this.lobbyCreatedCallResult.Dispose();
             this.lobbyCreatedCallResult = null;
         }
     }
     Session.lobbyCreatedCallback = null;
 }
Esempio n. 4
0
    public static void SteamMatchMaking_TryConnectingToLobby(ulong ConnectToLobbyID)
    {
        ISteamMatchMakingService service = Services.GetService <ISteamMatchMakingService>();

        if (service == null || service.SteamMatchMaking == null)
        {
            Diagnostics.LogWarning("ELCP: Steam matchmaking is null; make sure your Steam client is running...");
            return;
        }
        Steamworks.SteamID steamIDLobby = new Steamworks.SteamID(ConnectToLobbyID);
        if (service.SteamMatchMaking.RequestLobbyData(steamIDLobby))
        {
            PleaseWaitPanel.Instance.Show(AgeLocalizer.Instance.LocalizeString("%GameClientStateConnectingToServer"));
            service.SteamLobbyDataUpdate += ELCPUtilities.SteamMatchMaking_SteamLobbyDataUpdate;
            ELCPUtilities.LobbyID         = ConnectToLobbyID;
            return;
        }
        Diagnostics.LogWarning("ELCP: Failed to request the list of lobbies.");
    }
Esempio n. 5
0
        public void Open(Steamworks.SteamID steamIDLobby)
        {
            if (this.opened)
            {
                throw new InvalidOperationException("The session is already opened; consider closing it first or calling 'Reopen' instead.");
            }
            this.SteamMatchMakingService = Services.GetService <ISteamMatchMakingService>();
            if (this.SteamMatchMakingService == null)
            {
                throw new InvalidOperationException("Cannot find the steam match making service.");
            }
            if (!steamIDLobby.IsValid)
            {
                throw new ArgumentException("The steamIDLobby is not valid.");
            }
            this.SteamIDLobby = steamIDLobby;
            this.opened       = false;
            this.opening      = true;
            this.reopening    = true;
            this.hosting      = false;
            this.SessionMode  = SessionMode.Public;
            this.SteamMatchMakingService.SteamLobbyChatMsg     += this.SteamMatchMakingService_SteamLobbyChatMsg;
            this.SteamMatchMakingService.SteamLobbyChatUpdate  += this.SteamMatchMakingService_SteamLobbyChatUpdate;
            this.SteamMatchMakingService.SteamLobbyDataUpdate  += this.SteamMatchMakingService_SteamLobbyDataUpdate;
            this.SteamMatchMakingService.SteamLobbyEnter       += this.SteamMatchMakingService_SteamLobbyEnter;
            this.SteamMatchMakingService.SteamLobbyGameCreated += this.SteamMatchMakingService_SteamLobbyGameCreated;
            this.SteamMatchMakingService.SteamLobbyInvite      += this.SteamMatchMakingService_SteamLobbyInvite;
            this.SteamMatchMakingService.SteamLobbyKicked      += this.SteamMatchMakingService_SteamLobbyKicked;
            ISteamClientService service = Services.GetService <ISteamClientService>();

            Diagnostics.Assert(service != null);
            service.ClientSteamServersDisconnected  += this.ISteamClientService_ClientSteamServersDisconnected;
            service.ClientSteamServerConnectFailure += this.ISteamClientService_ClientSteamServerConnectFailure;
            service.ClientP2PSessionConnectFail     += this.ISteamClientService_ClientP2PSessionConnectFail;
            this.OnSessionChange(new SessionChangeEventArgs(SessionChangeAction.Opening, this));
            this.SteamMatchMakingService.SteamMatchMaking.JoinLobby(steamIDLobby);
        }
Esempio n. 6
0
        public void Reopen(SessionMode sessionMode, int maximumNumberOfLobbyMembers = 16)
        {
            if (!this.opened)
            {
                Diagnostics.LogWarning("The session is not opened, therefore it cannot be reopened. Please consider calling 'Open' instead.");
                return;
            }
            if (!this.hosting)
            {
                Diagnostics.LogWarning("Only the host is supposed to reopen its own session.");
                return;
            }
            Diagnostics.Log("Changing session mode from '{0}' to '{1}'...", new object[]
            {
                this.SessionMode,
                sessionMode
            });
            if (sessionMode != this.SessionMode)
            {
                this.opened    = false;
                this.opening   = true;
                this.reopening = true;
                this.OnSessionChange(new SessionChangeEventArgs(SessionChangeAction.Reopening, this));
                SessionMode sessionMode2 = this.SessionMode;
                this.SessionMode = sessionMode;
                this.SetLobbyData("SessionMode", sessionMode.ToString(), true);
                this.SetLobbyData("Owner", this.SteamIDUser, true);
                switch (this.SessionMode)
                {
                case SessionMode.Single:
                    if (this.SteamMatchMakingService != null)
                    {
                        this.SteamMatchMakingService.SteamLobbyChatMsg     -= this.SteamMatchMakingService_SteamLobbyChatMsg;
                        this.SteamMatchMakingService.SteamLobbyChatUpdate  -= this.SteamMatchMakingService_SteamLobbyChatUpdate;
                        this.SteamMatchMakingService.SteamLobbyDataUpdate  -= this.SteamMatchMakingService_SteamLobbyDataUpdate;
                        this.SteamMatchMakingService.SteamLobbyEnter       -= this.SteamMatchMakingService_SteamLobbyEnter;
                        this.SteamMatchMakingService.SteamLobbyGameCreated -= this.SteamMatchMakingService_SteamLobbyGameCreated;
                        this.SteamMatchMakingService.SteamLobbyInvite      -= this.SteamMatchMakingService_SteamLobbyInvite;
                        this.SteamMatchMakingService.SteamLobbyKicked      -= this.SteamMatchMakingService_SteamLobbyKicked;
                        ISteamClientService service = Services.GetService <ISteamClientService>();
                        Diagnostics.Assert(service != null);
                        service.ClientSteamServersDisconnected  -= this.ISteamClientService_ClientSteamServersDisconnected;
                        service.ClientSteamServerConnectFailure -= this.ISteamClientService_ClientSteamServerConnectFailure;
                        service.ClientP2PSessionConnectFail     -= this.ISteamClientService_ClientP2PSessionConnectFail;
                        if (this.SteamIDLobby != null)
                        {
                            this.SteamMatchMakingService.SteamMatchMaking.LeaveLobby(this.SteamIDLobby);
                            this.SteamIDLobby = null;
                        }
                    }
                    this.opened    = true;
                    this.opening   = false;
                    this.reopening = false;
                    this.OnSessionChange(new SessionChangeEventArgs(SessionChangeAction.Reopened, this));
                    break;

                case SessionMode.Private:
                case SessionMode.Protected:
                case SessionMode.Public:
                    if (sessionMode2 == SessionMode.Single)
                    {
                        this.SteamMatchMakingService = Services.GetService <ISteamMatchMakingService>();
                        if (this.SteamMatchMakingService == null)
                        {
                            throw new InvalidOperationException("Cannot find the steam match making service.");
                        }
                        if (maximumNumberOfLobbyMembers < 1)
                        {
                            throw new ArgumentOutOfRangeException("The maximum number of lobby members should be greater that zero.");
                        }
                        this.MaximumNumberOfLobbyMembers = maximumNumberOfLobbyMembers;
                        this.SteamMatchMakingService.SteamLobbyChatMsg     += this.SteamMatchMakingService_SteamLobbyChatMsg;
                        this.SteamMatchMakingService.SteamLobbyChatUpdate  += this.SteamMatchMakingService_SteamLobbyChatUpdate;
                        this.SteamMatchMakingService.SteamLobbyDataUpdate  += this.SteamMatchMakingService_SteamLobbyDataUpdate;
                        this.SteamMatchMakingService.SteamLobbyEnter       += this.SteamMatchMakingService_SteamLobbyEnter;
                        this.SteamMatchMakingService.SteamLobbyGameCreated += this.SteamMatchMakingService_SteamLobbyGameCreated;
                        this.SteamMatchMakingService.SteamLobbyInvite      += this.SteamMatchMakingService_SteamLobbyInvite;
                        this.SteamMatchMakingService.SteamLobbyKicked      += this.SteamMatchMakingService_SteamLobbyKicked;
                        ISteamClientService service2 = Services.GetService <ISteamClientService>();
                        Diagnostics.Assert(service2 != null);
                        service2.ClientSteamServersDisconnected  += this.ISteamClientService_ClientSteamServersDisconnected;
                        service2.ClientSteamServerConnectFailure += this.ISteamClientService_ClientSteamServerConnectFailure;
                        service2.ClientP2PSessionConnectFail     += this.ISteamClientService_ClientP2PSessionConnectFail;
                        Steamworks.SteamMatchMaking.ELobbyType lobbyType = this.SessionMode.ToSteamMatchMakingLobbyType();
                        ulong steamAPICall = this.SteamMatchMakingService.SteamMatchMaking.CreateLobby(lobbyType, 1);
                        if (Session.lobbyCreatedCallback != null)
                        {
                            Session.lobbyCreatedCallback = null;
                            if (this.lobbyCreatedCallResult != null)
                            {
                                this.lobbyCreatedCallResult.Dispose();
                                this.lobbyCreatedCallResult = null;
                            }
                        }
                        Session.lobbyCreatedCallback = new Steamworks.LobbyCreatedCallback(this.Steamworks_LobbyCreated);
                        this.lobbyCreatedCallResult  = new Steamworks.CallResult(Steamworks.SteamAPI_RegisterLobbyCreatedDelegate(steamAPICall, Session.lobbyCreatedCallback));
                    }
                    else
                    {
                        this.SteamMatchMakingService.SteamMatchMaking.SetLobbyType(this.SteamIDLobby, this.SessionMode.ToSteamMatchMakingLobbyType());
                        if (this.MaximumNumberOfLobbyMembers > 1)
                        {
                            this.SteamMatchMakingService.SteamMatchMaking.SetLobbyMemberLimit(this.SteamIDLobby, this.MaximumNumberOfLobbyMembers);
                        }
                        this.opened    = true;
                        this.opening   = false;
                        this.reopening = false;
                        this.OnSessionChange(new SessionChangeEventArgs(SessionChangeAction.Reopened, this));
                    }
                    break;
                }
            }
        }
Esempio n. 7
0
        public void Open(SessionMode sessionMode, int maximumNumberOfLobbyMembers = 16)
        {
            if (this.opened)
            {
                throw new InvalidOperationException("The session is already opened; consider closing it first or calling 'Reopen' instead.");
            }
            this.opening     = true;
            this.reopening   = false;
            this.hosting     = true;
            this.SessionMode = sessionMode;
            this.SetLobbyData("SessionMode", sessionMode.ToString(), true);
            this.SetLobbyData("Owner", this.SteamIDUser, true);
            this.SetLobbyData("Version", Amplitude.Unity.Framework.Application.Version.ToLong(), true);
            this.OnSessionChange(new SessionChangeEventArgs(SessionChangeAction.Opening, this));
            switch (this.SessionMode)
            {
            case SessionMode.Single:
                this.opened    = true;
                this.opening   = false;
                this.reopening = false;
                this.OnSessionChange(new SessionChangeEventArgs(SessionChangeAction.Opened, this));
                break;

            case SessionMode.Private:
            case SessionMode.Protected:
            case SessionMode.Public:
            {
                if (maximumNumberOfLobbyMembers < 1)
                {
                    throw new ArgumentOutOfRangeException("The maximum number of lobby members should be greater that zero.");
                }
                this.MaximumNumberOfLobbyMembers = maximumNumberOfLobbyMembers;
                this.SteamMatchMakingService     = Services.GetService <ISteamMatchMakingService>();
                if (this.SteamMatchMakingService == null)
                {
                    throw new InvalidOperationException("Cannot find the steam match making service.");
                }
                this.SteamMatchMakingService.SteamLobbyChatMsg     += this.SteamMatchMakingService_SteamLobbyChatMsg;
                this.SteamMatchMakingService.SteamLobbyChatUpdate  += this.SteamMatchMakingService_SteamLobbyChatUpdate;
                this.SteamMatchMakingService.SteamLobbyDataUpdate  += this.SteamMatchMakingService_SteamLobbyDataUpdate;
                this.SteamMatchMakingService.SteamLobbyEnter       += this.SteamMatchMakingService_SteamLobbyEnter;
                this.SteamMatchMakingService.SteamLobbyGameCreated += this.SteamMatchMakingService_SteamLobbyGameCreated;
                this.SteamMatchMakingService.SteamLobbyInvite      += this.SteamMatchMakingService_SteamLobbyInvite;
                this.SteamMatchMakingService.SteamLobbyKicked      += this.SteamMatchMakingService_SteamLobbyKicked;
                ISteamClientService service = Services.GetService <ISteamClientService>();
                Diagnostics.Assert(service != null);
                service.ClientSteamServersDisconnected  += this.ISteamClientService_ClientSteamServersDisconnected;
                service.ClientSteamServerConnectFailure += this.ISteamClientService_ClientSteamServerConnectFailure;
                service.ClientP2PSessionConnectFail     += this.ISteamClientService_ClientP2PSessionConnectFail;
                Steamworks.SteamMatchMaking.ELobbyType lobbyType = this.SessionMode.ToSteamMatchMakingLobbyType();
                ulong steamAPICall = this.SteamMatchMakingService.SteamMatchMaking.CreateLobby(lobbyType, 1);
                if (Session.lobbyCreatedCallback != null)
                {
                    Session.lobbyCreatedCallback = null;
                    if (this.lobbyCreatedCallResult != null)
                    {
                        this.lobbyCreatedCallResult.Dispose();
                        this.lobbyCreatedCallResult = null;
                    }
                }
                Session.lobbyCreatedCallback = new Steamworks.LobbyCreatedCallback(this.Steamworks_LobbyCreated);
                this.lobbyCreatedCallResult  = new Steamworks.CallResult(Steamworks.SteamAPI_RegisterLobbyCreatedDelegate(steamAPICall, Session.lobbyCreatedCallback));
                break;
            }
            }
        }
Esempio n. 8
0
    private static void SteamMatchMaking_SteamLobbyDataUpdate(object sender, SteamLobbyDataUpdateEventArgs e)
    {
        PleaseWaitPanel.Instance.Hide(false);
        Diagnostics.Log("ELCP: LobbyDataUpdate, success? {0}, lobby {1}, expected {2}", new object[]
        {
            e.Message.m_bSuccess,
            e.Message.m_ulSteamIDLobby,
            ELCPUtilities.LobbyID
        });
        if (e.Message.m_bSuccess == 0 || ELCPUtilities.LobbyID != e.Message.m_ulSteamIDLobby)
        {
            return;
        }
        ISteamMatchMakingService service = Services.GetService <ISteamMatchMakingService>();

        Steamworks.SteamID steamID = new Steamworks.SteamID(ELCPUtilities.LobbyID);
        MenuJoinGameScreen.LobbyDescription lobbyDescription = new MenuJoinGameScreen.LobbyDescription(service, steamID);
        Diagnostics.Log("[Lobby] Flags: {0}, Lobby valid? {1}", new object[]
        {
            lobbyDescription.Flags,
            lobbyDescription.IsValid
        });
        service.SteamLobbyDataUpdate -= ELCPUtilities.SteamMatchMaking_SteamLobbyDataUpdate;
        ELCPUtilities.LobbyID         = 0UL;
        if (!lobbyDescription.IsValid)
        {
            return;
        }
        IRuntimeModuleSubscriptionService service2 = Services.GetService <IRuntimeModuleSubscriptionService>();

        if (service == null || service2 == null || !steamID.IsValid)
        {
            return;
        }
        string[] array  = new string[0];
        string[] array2 = new string[0];
        RuntimeModuleConfigurationState runtimeModuleListState = service2.GetRuntimeModuleListState(lobbyDescription.RuntimeConfiguration, out array, out array2);

        Diagnostics.Log("ELCP runtimeModuleConfigurationState {0} missingWorkshopItems {1} missingNonWorkshopItems {2} RuntimeConfiguration {3}", new object[]
        {
            runtimeModuleListState + 1,
            array.Length,
            array2.Length,
            (lobbyDescription.RuntimeConfiguration == null) ? -1 : lobbyDescription.RuntimeConfiguration.Length
        });
        switch (runtimeModuleListState + 1)
        {
        case RuntimeModuleConfigurationState.Yellow:
            Services.GetService <IRuntimeService>().Runtime.FiniteStateMachine.PostStateChange(typeof(RuntimeState_Lobby), new object[]
            {
                steamID
            });
            return;

        case RuntimeModuleConfigurationState.Red:
            ELCPUtilities.SelectedLobby = lobbyDescription;
            if (array.Length != 0)
            {
                string text = AgeLocalizer.Instance.LocalizeString("%ConfirmDownloadModsBeforeActivation");
                MessagePanel.Instance.Show(text.Replace("$NumberOfMods", array.Length.ToString()), "%Confirmation", MessagePanelButtons.OkCancel, new MessagePanel.EventHandler(ELCPUtilities.SteamMatchMaking_OnConfirmOpenActivationPanel), MessagePanelType.IMPORTANT, new MessagePanelButton[0]);
                return;
            }
            ELCPUtilities.SteamMatchMaking_OnConfirmOpenActivationPanel(Amplitude.Unity.Gui.GuiScreen.CurrentScreen, new MessagePanelResultEventArgs(MessagePanelResult.Ok));
            return;

        case (RuntimeModuleConfigurationState)3:
            ELCPUtilities.SelectedLobby = lobbyDescription;
            ELCPUtilities.SteamMatchMaking_OnConfirmOpenActivationPanel(Amplitude.Unity.Gui.GuiScreen.CurrentScreen, new MessagePanelResultEventArgs(MessagePanelResult.Ok));
            return;

        default:
            return;
        }
    }
Esempio n. 9
0
    private static void SteamMatchMaking_CallbackRequestLobbyList(object sender, SteamMatchMakingRequestLobbyListEventArgs e)
    {
        PleaseWaitPanel.Instance.Hide(false);
        Diagnostics.Log("ELCP: Request Lobby List : " + e.Message.m_nLobbiesMatching + " result(s).");
        ISteamMatchMakingService service = Services.GetService <ISteamMatchMakingService>();

        Steamworks.SteamID steamID = new Steamworks.SteamID(ELCPUtilities.LobbyID);
        Diagnostics.Log("ELCP: looking for lobby: " + steamID.AccountID);
        int num = 0;

        while ((long)num < (long)((ulong)e.Message.m_nLobbiesMatching))
        {
            Steamworks.SteamID lobbyByIndex = service.SteamMatchMaking.GetLobbyByIndex(num);
            Diagnostics.Log(string.Concat(new object[]
            {
                "ELCP: lobbybyindex: ",
                lobbyByIndex.AccountID,
                " ",
                lobbyByIndex.IsValid.ToString()
            }));
            if (lobbyByIndex.IsValid && steamID.AccountID == lobbyByIndex.AccountID)
            {
                MenuJoinGameScreen.LobbyDescription lobbyDescription = new MenuJoinGameScreen.LobbyDescription(service, lobbyByIndex);
                Diagnostics.Log("[Lobby] Flags: {0}, Lobby valid? {1}", new object[]
                {
                    lobbyDescription.Flags,
                    lobbyDescription.IsValid
                });
                if (!lobbyDescription.IsValid)
                {
                    break;
                }
                IRuntimeModuleSubscriptionService service2 = Services.GetService <IRuntimeModuleSubscriptionService>();
                if (service == null || service2 == null || !steamID.IsValid)
                {
                    break;
                }
                string[] array  = new string[0];
                string[] array2 = new string[0];
                RuntimeModuleConfigurationState runtimeModuleListState = service2.GetRuntimeModuleListState(lobbyDescription.RuntimeConfiguration, out array, out array2);
                Diagnostics.Log("ELCP runtimeModuleConfigurationState {0} missingWorkshopItems {1} missingNonWorkshopItems {2} RuntimeConfiguration {3}", new object[]
                {
                    runtimeModuleListState + 1,
                    array.Length,
                    array2.Length,
                    (lobbyDescription.RuntimeConfiguration == null) ? -1 : lobbyDescription.RuntimeConfiguration.Length
                });
                switch (runtimeModuleListState + 1)
                {
                case RuntimeModuleConfigurationState.Yellow:
                    Services.GetService <IRuntimeService>().Runtime.FiniteStateMachine.PostStateChange(typeof(RuntimeState_Lobby), new object[]
                    {
                        steamID
                    });
                    goto IL_28B;

                case RuntimeModuleConfigurationState.Red:
                    ELCPUtilities.SelectedLobby = lobbyDescription;
                    if (array.Length != 0)
                    {
                        string text = AgeLocalizer.Instance.LocalizeString("%ConfirmDownloadModsBeforeActivation");
                        MessagePanel.Instance.Show(text.Replace("$NumberOfMods", array.Length.ToString()), "%Confirmation", MessagePanelButtons.OkCancel, new MessagePanel.EventHandler(ELCPUtilities.SteamMatchMaking_OnConfirmOpenActivationPanel), MessagePanelType.IMPORTANT, new MessagePanelButton[0]);
                        goto IL_28B;
                    }
                    ELCPUtilities.SteamMatchMaking_OnConfirmOpenActivationPanel(Amplitude.Unity.Gui.GuiScreen.CurrentScreen, new MessagePanelResultEventArgs(MessagePanelResult.Ok));
                    goto IL_28B;

                case (RuntimeModuleConfigurationState)3:
                    ELCPUtilities.SelectedLobby = lobbyDescription;
                    ELCPUtilities.SteamMatchMaking_OnConfirmOpenActivationPanel(Amplitude.Unity.Gui.GuiScreen.CurrentScreen, new MessagePanelResultEventArgs(MessagePanelResult.Ok));
                    goto IL_28B;

                default:
                    goto IL_28B;
                }
            }
            else
            {
                num++;
            }
        }
IL_28B:
        service.SteamMatchMakingRequestLobbyList -= ELCPUtilities.SteamMatchMaking_CallbackRequestLobbyList;
        ELCPUtilities.LobbyID      = 0UL;
        ELCPUtilities.steamAPICall = 0UL;
    }