Exemplo 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));
        }
Exemplo n.º 2
0
 public string GetLobbyMemberData(Steamworks.SteamID steamIDMember, StaticString key)
 {
     if (this.SteamMatchMakingService != null && this.SteamIDLobby != null)
     {
         return(this.SteamMatchMakingService.SteamMatchMaking.GetLobbyMemberData(this.SteamIDLobby, steamIDMember, key));
     }
     return(null);
 }
Exemplo n.º 3
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();
        }
Exemplo n.º 4
0
    private void RefreshPlayerLine(string playerName, int playerIndex)
    {
        Steamworks.SteamID steamID = Steamworks.SteamID.Zero;
        if (Steamworks.SteamAPI.IsSteamRunning)
        {
            try
            {
                steamID    = new Steamworks.SteamID(Convert.ToUInt64(playerName, 16));
                playerName = Steamworks.SteamAPI.SteamFriends.GetFriendPersonaName(steamID);
                goto IL_4E;
            }
            catch
            {
                Diagnostics.LogWarning("Unable to get player name from steam ID " + playerName);
                goto IL_4E;
            }
        }
        playerName = Environment.UserName + "(no Steam)";
IL_4E:
        this.PlayersTitleLabels[playerIndex].AgeTransform.Visible = true;
        this.PlayersTitleLabels[playerIndex].Text = playerName;
        AgeTooltip ageTooltip = this.PlayersTitleLabels[playerIndex].AgeTransform.AgeTooltip;

        if (ageTooltip != null)
        {
            ageTooltip.Content = playerName;
        }
        if (steamID == this.Session.SteamIDUser && playerIndex == 0)
        {
            this.CompetitorIsLocalOwner = true;
        }
        SessionMode sessionMode = this.Session.SessionMode;

        if (sessionMode == SessionMode.Single)
        {
            this.PlayerReadyToggles[playerIndex].AgeTransform.Visible = false;
            this.PlayerKickButtons[playerIndex].AgeTransform.Visible  = false;
            return;
        }
        if (sessionMode - SessionMode.Private > 2)
        {
            throw new ArgumentOutOfRangeException();
        }
        bool lobbyMemberData = this.Session.GetLobbyMemberData <bool>(steamID, "Ready", false);

        this.PlayerReadyToggles[playerIndex].AgeTransform.Visible = true;
        this.PlayerReadyToggles[playerIndex].State = lobbyMemberData;
        this.PlayerKickButtons[playerIndex].AgeTransform.Visible = (this.CompetitorIsHuman && this.Session.IsHosting && !this.CompetitorIsLocalOwner);
        this.PlayerKickButtons[playerIndex].OnActivateMethod     = "OnKickUserCB";
        this.PlayerKickButtons[playerIndex].OnActivateData       = steamID.ToString();
        bool visible = steamID == this.Session.LobbyOwnerSteamID;

        this.PlayerHostingIcons[playerIndex].AgeTransform.Visible = visible;
    }
Exemplo n.º 5
0
    private void MultiplayerProgress_ProgressChange(Steamworks.SteamID steamIDUser, int empireIndex, string status)
    {
        Diagnostics.Log("[MP_Progress] Empire#{0} {1} {2}", new object[]
        {
            empireIndex,
            steamIDUser,
            status
        });
        float num    = (float)((Diagnostics.MultiplayerProgress.UserProgresses.Length - 1) / 4 + 1);
        float height = (28f * num + 2f) * (AgeUtils.HighDefinition ? AgeUtils.HighDefinitionFactor : 1f);

        this.PlayerLoadStatusGroup.ForceHeight(height, true);
        this.UpdatePlayerLoadStatus();
    }
Exemplo n.º 6
0
        private void InitializeFlags()
        {
            if (this.GameInProgress)
            {
                this.Flags |= MenuJoinGameScreen.LobbyDescription.LobbyFlag.GameInProgress;
            }
            if (this.GameHasEnded)
            {
                this.Flags |= MenuJoinGameScreen.LobbyDescription.LobbyFlag.GameHasEnded;
            }
            if (this.GameIsMigrating)
            {
                this.Flags |= MenuJoinGameScreen.LobbyDescription.LobbyFlag.GameIsMigrating;
            }
            if (this.IsMultiplayerSave)
            {
                this.Flags |= MenuJoinGameScreen.LobbyDescription.LobbyFlag.FromSavedGame;
            }
            if (this.Version != Amplitude.Unity.Framework.Application.Version)
            {
                this.Flags |= MenuJoinGameScreen.LobbyDescription.LobbyFlag.VersionMismatch;
            }
            if (this.SessionMode == SessionMode.Protected)
            {
                this.Flags |= MenuJoinGameScreen.LobbyDescription.LobbyFlag.FriendsOnly;
            }
            Steamworks.SteamID steamID = new Steamworks.SteamID(this.SteamIDOwner);
            if (steamID.IsValid)
            {
                Steamworks.EFriendRelationship friendRelationship = Steamworks.SteamAPI.SteamFriends.GetFriendRelationship(steamID);
                if (friendRelationship == Steamworks.EFriendRelationship.k_EFriendRelationshipFriend)
                {
                    this.Flags |= MenuJoinGameScreen.LobbyDescription.LobbyFlag.FriendlyLobby;
                }
            }
            this.Flags |= MenuJoinGameScreen.LobbyDescription.LobbyFlag.RuntimeConfigurationMismatch;
            IRuntimeService service = Services.GetService <IRuntimeService>();

            if (service != null && service.Runtime != null && service.Runtime.RuntimeModules != null && this.RuntimeConfiguration != null)
            {
                string[] array = (from runtimeModule in service.Runtime.RuntimeModules
                                  select runtimeModule.Name).ToArray <string>();
                string[] array2 = array.Except(this.RuntimeConfiguration).ToArray <string>();
                string[] array3 = this.RuntimeConfiguration.Except(array).ToArray <string>();
                if (array2.Length + array3.Length == 0)
                {
                    this.Flags &= ~MenuJoinGameScreen.LobbyDescription.LobbyFlag.RuntimeConfigurationMismatch;
                }
            }
        }
Exemplo n.º 7
0
 private IEnumerator SteamGetSteamUserName()
 {
     Steamworks.SteamUser steamUser = Steamworks.SteamAPI.SteamUser;
     if (steamUser != null)
     {
         Steamworks.SteamID steamIDUser = Steamworks.SteamAPI.SteamUser.SteamID;
         Diagnostics.Log("[Steam] Steam user id is '" + steamIDUser + "'.");
         string userName = Steamworks.SteamAPI.SteamFriends.GetFriendPersonaName(steamIDUser);
         Diagnostics.Log("[Steam] Steam user name is '" + userName + "'.");
         Application.UserUniqueID = steamIDUser.AccountID;
         Application.UserName     = userName;
     }
     yield break;
 }
Exemplo n.º 8
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.");
    }
Exemplo n.º 9
0
 public T GetLobbyMemberData <T>(Steamworks.SteamID steamIDMember, StaticString key, T defaultValue)
 {
     if (this.SteamMatchMakingService != null && this.SteamIDLobby != null)
     {
         string lobbyMemberData = this.SteamMatchMakingService.SteamMatchMaking.GetLobbyMemberData(this.SteamIDLobby, steamIDMember, key);
         if (!string.IsNullOrEmpty(lobbyMemberData))
         {
             try
             {
                 return((T)((object)Convert.ChangeType(lobbyMemberData, typeof(T))));
             }
             catch
             {
                 return(defaultValue);
             }
             return(defaultValue);
         }
     }
     return(defaultValue);
 }
Exemplo n.º 10
0
    private void SteamMatchMaking_CallbackRequestLobbyList(object sender, SteamMatchMakingRequestLobbyListEventArgs e)
    {
        Diagnostics.Log("Request Lobby List : " + e.Message.m_nLobbiesMatching + " result(s).");
        this.GameSessionsTable.Enable          = true;
        this.RefreshButton.AgeTransform.Enable = true;
        this.StatusLabel.AgeTransform.Visible  = false;
        this.StatusLabel.Text = string.Empty;
        this.LobbyDescriptions.Clear();
        int num = 0;

        while ((long)num < (long)((ulong)e.Message.m_nLobbiesMatching))
        {
            Steamworks.SteamID lobbyByIndex = this.MatchMakingService.SteamMatchMaking.GetLobbyByIndex(num);
            if (lobbyByIndex.IsValid)
            {
                MenuJoinGameScreen.LobbyDescription lobbyDescription = new MenuJoinGameScreen.LobbyDescription(this.MatchMakingService, lobbyByIndex);
                Diagnostics.Log("[Lobby] {0}", new object[]
                {
                    lobbyDescription.Flags
                });
                if (lobbyDescription.IsValid)
                {
                    if (!lobbyDescription.HasFlag(MenuJoinGameScreen.LobbyDescription.LobbyFlag.GameHasEnded) && !lobbyDescription.HasFlag(MenuJoinGameScreen.LobbyDescription.LobbyFlag.GameIsMigrating))
                    {
                        if (!lobbyDescription.HasFlag(MenuJoinGameScreen.LobbyDescription.LobbyFlag.FriendsOnly))
                        {
                            this.LobbyDescriptions.Add(lobbyDescription);
                        }
                        else if (lobbyDescription.HasFlag(MenuJoinGameScreen.LobbyDescription.LobbyFlag.FriendsOnly | MenuJoinGameScreen.LobbyDescription.LobbyFlag.FriendlyLobby))
                        {
                            this.LobbyDescriptions.Add(lobbyDescription);
                        }
                    }
                }
            }
            num++;
        }
        this.MatchMakingService.SteamMatchMakingRequestLobbyList -= this.SteamMatchMaking_CallbackRequestLobbyList;
        this.steamAPICall = 0UL;
        this.RefreshContent();
    }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
0
 private void ISteamClientService_ClientP2PSessionConnectFail(object sender, P2PSessionConnectFailEventArgs e)
 {
     Steamworks.SteamID steamID = new Steamworks.SteamID(e.Message.m_steamIDRemote);
     Diagnostics.LogWarning("[Session] P2PSessionConnectFail with {0}.", new object[]
     {
         steamID
     });
     if (Session.IgnoreP2PSessionConnectFail != steamID)
     {
         if (!this.IsHosting && steamID == this.SteamIDServer)
         {
             this.OnError(Session.ErrorLevel.Error, "%SessionP2PSessionConnectFail", (int)e.Message.m_eP2PSessionError);
             this.Close();
         }
     }
     else
     {
         Diagnostics.LogWarning("[Session] P2PSessionConnectFail ignored for {0}.", new object[]
         {
             Session.IgnoreP2PSessionConnectFail
         });
         Session.IgnoreP2PSessionConnectFail = null;
     }
 }
Exemplo n.º 13
0
    public static EmpireInfo Read(Amplitude.Unity.Session.Session session, int empireIndex)
    {
        if (session == null)
        {
            throw new ArgumentNullException("session");
        }
        if (empireIndex < 0)
        {
            throw new IndexOutOfRangeException("Empire index must be a positive integer.");
        }
        if (empireIndex == 0)
        {
            try
            {
                string lobbyData = session.GetLobbyData <string>(EmpireInfo.EmpireInfoAccessibility, null);
                EmpireInfo.LastAccessibilityLevel = (EmpireInfo.Accessibility)((int)Enum.Parse(typeof(EmpireInfo.Accessibility), lobbyData));
            }
            catch
            {
                EmpireInfo.LastAccessibilityLevel = EmpireInfo.Accessibility.Default;
            }
        }
        string x          = string.Format("Empire{0}", empireIndex);
        string lobbyData2 = session.GetLobbyData <string>(x, null);

        if (string.IsNullOrEmpty(lobbyData2))
        {
            return(null);
        }
        string     x2         = string.Format("Faction{0}", empireIndex);
        string     x3         = string.Format("Color{0}", empireIndex);
        string     lobbyData3 = session.GetLobbyData <string>(x2, null);
        string     lobbyData4 = session.GetLobbyData <string>(x3, null);
        EmpireInfo empireInfo = new EmpireInfo();

        empireInfo.EmpireIndex  = empireIndex;
        empireInfo.EmpireName   = "Empire#" + empireIndex;
        empireInfo.Faction      = Faction.Decode(lobbyData3);
        empireInfo.FactionColor = Color.white;
        empireInfo.Players      = lobbyData2;
        string value = Amplitude.Unity.Framework.Application.Registry.GetValue <string>("Settings/UI/EmpireColorPalette", "Standard");
        IDatabase <Palette> database = Databases.GetDatabase <Palette>(false);
        Palette             palette;

        if (database != null && database.TryGetValue(value, out palette))
        {
            if (palette.Colors == null || palette.Colors.Length == 0)
            {
                Diagnostics.LogError("Invalid color palette (name: '{0}').", new object[]
                {
                    value
                });
            }
            else
            {
                try
                {
                    int num = int.Parse(lobbyData4);
                    empireInfo.FactionColor = palette.Colors[num];
                }
                catch
                {
                    Diagnostics.LogError("Failed to retrieve faction color from palette (palette name: '{0}', color index: '{1}').", new object[]
                    {
                        value,
                        lobbyData4
                    });
                }
            }
        }
        string lobbyData5 = session.GetLobbyData <string>(VictoryCondition.ReadOnlyVictory, null);

        if (!string.IsNullOrEmpty(lobbyData5))
        {
            IDatabase <VictoryCondition> database2 = Databases.GetDatabase <VictoryCondition>(false);
            if (database2 != null)
            {
                char[] separator = new char[]
                {
                    '&'
                };
                string[] array = lobbyData5.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                if (array.Length != 0)
                {
                    List <VictoryCondition> list = new List <VictoryCondition>();
                    string[] array2 = array;
                    for (int i = 0; i < array2.Length; i++)
                    {
                        string[] array3 = array2[i].Split(Amplitude.String.Separators, StringSplitOptions.RemoveEmptyEntries);
                        int      j      = 1;
                        while (j < array3.Length)
                        {
                            int num2;
                            if (int.TryParse(array3[j], out num2) && num2 == empireIndex)
                            {
                                VictoryCondition item;
                                if (database2.TryGetValue(array3[0], out item))
                                {
                                    list.Add(item);
                                    break;
                                }
                                break;
                            }
                            else
                            {
                                j++;
                            }
                        }
                    }
                    empireInfo.VictoryConditions = list.ToArray();
                }
            }
            else
            {
                Diagnostics.LogError("Unable to retrieve the database of victory conditions.");
            }
        }
        ILocalizationService service = Services.GetService <ILocalizationService>();

        empireInfo.LocalizedName = string.Empty;
        string[] array4 = lobbyData2.Split(Amplitude.String.Separators, StringSplitOptions.RemoveEmptyEntries);
        for (int k = 0; k < array4.Length; k++)
        {
            if (service != null)
            {
                if (array4[k].StartsWith("AI"))
                {
                    if (empireInfo.Faction.Name == "FactionELCPSpectator")
                    {
                        empireInfo.LocalizedName = AgeLocalizer.Instance.LocalizeString("%NotificationEncounterParticipationModeSpectatorTitle");
                    }
                    else
                    {
                        empireInfo.LocalizedName = MajorEmpire.GenerateAIName(empireInfo.Faction.Affinity.Name, empireInfo.EmpireIndex);
                    }
                }
                else
                {
                    Steamworks.SteamID steamID  = new Steamworks.SteamID(Convert.ToUInt64(array4[k], 16));
                    string             newValue = AgeLocalizer.Instance.LocalizeString("%DefaultPlayerName");
                    if (Steamworks.SteamAPI.IsSteamRunning)
                    {
                        newValue = Steamworks.SteamAPI.SteamFriends.GetFriendPersonaName(steamID);
                    }
                    string     name        = (empireInfo.LocalizedName.Length != 0) ? "%EmpireNameFormatAdditionnalHuman" : "%EmpireNameFormatHuman";
                    EmpireInfo empireInfo2 = empireInfo;
                    empireInfo2.LocalizedName += service.Localize(name).ToString().Replace("$PlayerName", newValue);
                }
            }
        }
        empireInfo.IsActiveOrLocalPlayer  = false;
        empireInfo.EmpireEliminated       = false;
        empireInfo.EmpireExplorationBits  = 0;
        empireInfo.EmpireInfiltrationBits = 0;
        IGameService service2 = Services.GetService <IGameService>();

        if (service2 != null && service2.Game != null)
        {
            IPlayerControllerRepositoryService service3 = service2.Game.Services.GetService <IPlayerControllerRepositoryService>();
            if (service3 != null && service3.ActivePlayerController != null && service3.ActivePlayerController.Empire != null)
            {
                empireInfo.IsActiveOrLocalPlayer = (service3.ActivePlayerController.Empire.Index == empireIndex);
            }
            else
            {
                Steamworks.SteamUser steamUser = Steamworks.SteamAPI.SteamUser;
                if (steamUser != null)
                {
                    empireInfo.IsActiveOrLocalPlayer = empireInfo.Players.Contains(steamUser.SteamID.ToString());
                }
            }
            global::Game game = service2.Game as global::Game;
            if (game != null && game.Empires != null)
            {
                MajorEmpire majorEmpire = game.Empires[empireIndex] as MajorEmpire;
                if (majorEmpire.IsEliminated)
                {
                    empireInfo.EmpireEliminated = true;
                }
                empireInfo.AlliedIndexList = new List <int>();
                for (int l = 0; l < game.Empires.Length; l++)
                {
                    MajorEmpire majorEmpire2 = game.Empires[l] as MajorEmpire;
                    if (majorEmpire2 == null)
                    {
                        break;
                    }
                    if (majorEmpire2.Index == empireIndex)
                    {
                        empireInfo.EmpireExplorationBits  |= 1 << empireIndex;
                        empireInfo.EmpireInfiltrationBits |= 1 << empireIndex;
                    }
                    else
                    {
                        DepartmentOfForeignAffairs agency = majorEmpire2.GetAgency <DepartmentOfForeignAffairs>();
                        if (agency != null)
                        {
                            DiplomaticRelation diplomaticRelation = agency.GetDiplomaticRelation(majorEmpire);
                            if (diplomaticRelation != null && diplomaticRelation.State != null && diplomaticRelation.State.Name != DiplomaticRelationState.Names.Unknown)
                            {
                                empireInfo.EmpireExplorationBits |= 1 << majorEmpire2.Index;
                                if (diplomaticRelation.State.Name == DiplomaticRelationState.Names.Alliance)
                                {
                                    empireInfo.AlliedIndexList.Add(majorEmpire2.Index);
                                }
                            }
                        }
                        DepartmentOfIntelligence agency2 = majorEmpire2.GetAgency <DepartmentOfIntelligence>();
                        if (agency2 != null && agency2.IsEmpireInfiltrated(majorEmpire))
                        {
                            empireInfo.EmpireInfiltrationBits |= 1 << majorEmpire2.Index;
                        }
                    }
                }
            }
        }
        return(empireInfo);
    }
    public override void Begin(params object[] parameters)
    {
        base.Begin(parameters);
        IMouseCursorService service = Services.GetService <IMouseCursorService>();

        if (service != null)
        {
            service.AddKey("Loading");
        }
        Diagnostics.Log("GameClientState_GameLaunched.");
        int             num      = 0;
        ISessionService service2 = Services.GetService <ISessionService>();

        Diagnostics.Assert(service2 != null);
        Diagnostics.Assert(service2.Session != null);
        Diagnostics.Assert(service2.Session.IsOpened);
        string text = service2.Session.SteamIDUser.ToString();

        Diagnostics.Assert(service2.Session.SteamIDUser.AccountID == Amplitude.Unity.Framework.Application.UserUniqueID);
        PlayerController playerController = new PlayerController(base.GameClient)
        {
            PlayerID = "player#" + service2.Session.SteamIDUser.AccountID
        };

        for (;;)
        {
            string x         = string.Format("Empire{0}", num);
            string lobbyData = service2.Session.GetLobbyData <string>(x, null);
            if (string.IsNullOrEmpty(lobbyData))
            {
                break;
            }
            if (lobbyData.Contains(text))
            {
                goto IL_113;
            }
            num++;
        }
        Diagnostics.LogError("Player doesn't belong here (SteamUserID: {0}).", new object[]
        {
            text
        });
        goto IL_12C;
IL_113:
        playerController.Empire = base.GameClient.Game.Empires[num];
IL_12C:
        int num2 = 0;

        for (;;)
        {
            string x2         = string.Format("Empire{0}", num2);
            string lobbyData2 = service2.Session.GetLobbyData <string>(x2, null);
            if (string.IsNullOrEmpty(lobbyData2))
            {
                break;
            }
            base.GameClient.Game.Empires[num2].IsControlledByAI = true;
            MajorEmpire majorEmpire = base.GameClient.Game.Empires[num2] as MajorEmpire;
            if (majorEmpire != null)
            {
                if (!lobbyData2.StartsWith("AI"))
                {
                    majorEmpire.IsControlledByAI = false;
                    if (Steamworks.SteamAPI.IsSteamRunning)
                    {
                        string[] array = lobbyData2.Split(Amplitude.String.Separators, StringSplitOptions.RemoveEmptyEntries);
                        for (int i = 0; i < array.Length; i++)
                        {
                            Steamworks.SteamID steamID = new Steamworks.SteamID(Convert.ToUInt64(array[i], 16));
                            if (!service2.Session.GetLobbyMemberData <bool>(steamID, "Ready", false) && base.GameClient.Session.SessionMode != SessionMode.Single)
                            {
                                majorEmpire.BindPlayer(new Player(majorEmpire)
                                {
                                    Type          = PlayerType.AI,
                                    Location      = ((base.GameClient.Session.GameServer == null) ? PlayerLocation.Remote : PlayerLocation.Local),
                                    LocalizedName = MajorEmpire.GenerateBasicAIName(majorEmpire.Index)
                                });
                            }
                            else
                            {
                                string text2 = Steamworks.SteamAPI.SteamFriends.GetFriendPersonaName(steamID);
                                if (text2 == null)
                                {
                                    text2 = AgeLocalizer.Instance.LocalizeString("%DefaultPlayerName");
                                }
                                majorEmpire.BindPlayer(new Player(majorEmpire)
                                {
                                    Type          = PlayerType.Human,
                                    Location      = ((!(steamID == base.GameClient.SteamIDUser)) ? PlayerLocation.Remote : PlayerLocation.Local),
                                    LocalizedName = text2,
                                    SteamID       = steamID
                                });
                            }
                        }
                    }
                    else
                    {
                        Diagnostics.LogWarning("Steam is not running, cannot get player's name, setting a default one.");
                        majorEmpire.BindPlayer(new Player(majorEmpire)
                        {
                            Type          = PlayerType.Human,
                            Location      = PlayerLocation.Local,
                            LocalizedName = AgeLocalizer.Instance.LocalizeString("%DefaultPlayerName"),
                            SteamID       = Steamworks.SteamID.Zero
                        });
                    }
                }
                else
                {
                    majorEmpire.BindPlayer(new Player(majorEmpire)
                    {
                        Type          = PlayerType.AI,
                        Location      = ((base.GameClient.Session.GameServer == null) ? PlayerLocation.Remote : PlayerLocation.Local),
                        LocalizedName = MajorEmpire.GenerateBasicAIName(majorEmpire.Index)
                    });
                }
            }
            num2++;
        }
        IPlayerControllerRepositoryService service3 = base.GameClient.Game.GetService <IPlayerControllerRepositoryService>();

        if (service3 != null)
        {
            for (int j = 0; j < base.GameClient.Game.Empires.Length; j++)
            {
                PlayerController playerController2 = new PlayerController(base.GameClient)
                {
                    Empire   = base.GameClient.Game.Empires[j],
                    PlayerID = base.GameClient.Game.Empires[j].PlayerID
                };
                service3.Register(playerController2);
                base.GameClient.Game.Empires[j].PlayerController         = playerController2;
                base.GameClient.Game.Empires[j].PlayerControllers.Client = playerController2;
            }
        }
        if (service3 != null)
        {
            service3.Register(playerController);
            service3.SetActivePlayerController(playerController);
        }
        Ticket.ResetCounter(0UL);
        Amplitude.Unity.View.IViewService service4 = Services.GetService <Amplitude.Unity.View.IViewService>();
        if (service4 != null)
        {
            WorldView worldView = (WorldView)service4.FindByType(typeof(WorldView));
            if (worldView != null)
            {
                worldView.WorldViewTechniqueChange += this.WorldView_WorldViewTechniqueChange;
            }
            service4.PostViewChange(typeof(WorldView), new object[0]);
        }
        Amplitude.Unity.Gui.IGuiService service5 = Services.GetService <Amplitude.Unity.Gui.IGuiService>();
        Diagnostics.Assert(service5 != null);
        ConsolePanel guiPanel = service5.GetGuiPanel <ConsolePanel>();

        Diagnostics.Assert(guiPanel != null);
        guiPanel.Load();
        guiPanel.Hide(false);
    }
Exemplo n.º 15
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;
    }
Exemplo n.º 16
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;
        }
    }
Exemplo n.º 17
0
    private void LoadGuiImage(params object[] parameters)
    {
        if (this.Background.Image != null)
        {
            AgeManager.Instance.ReleaseDynamicTexture(this.Background.Image.name);
        }
        string             text = string.Empty;
        GameSaveDescriptor gameSaveDescriptor = null;

        if (parameters.Length > 0)
        {
            for (int i = 0; i < parameters.Length; i++)
            {
                if (parameters[i] is string)
                {
                    text = (string)parameters[i];
                    this.Background.Image = (Resources.Load(text) as Texture2D);
                    if (this.Background.Image != null)
                    {
                        break;
                    }
                }
                if (parameters[i] is GameSaveDescriptor)
                {
                    gameSaveDescriptor = (parameters[i] as GameSaveDescriptor);
                }
            }
        }
        if (string.IsNullOrEmpty(text))
        {
            if (this.SessionService != null && this.SessionService.Session != null && this.SessionService.Session.IsOpened)
            {
                int num = 0;
                for (;;)
                {
                    string x         = string.Format("Empire{0}", num);
                    string lobbyData = this.SessionService.Session.GetLobbyData <string>(x, null);
                    if (string.IsNullOrEmpty(lobbyData))
                    {
                        break;
                    }
                    if (lobbyData.Contains(this.SessionService.Session.SteamIDUser.ToString()))
                    {
                        goto Block_11;
                    }
                    num++;
                }
                goto IL_201;
Block_11:
                string x2 = string.Format("Faction{0}", num);
                string lobbyData2 = this.SessionService.Session.GetLobbyData <string>(x2, null);
                if (!string.IsNullOrEmpty(lobbyData2))
                {
                    string[]               array      = lobbyData2.Split(Amplitude.String.Separators, StringSplitOptions.None);
                    string                 x3         = array[3];
                    GuiElement             guiElement = null;
                    IDatabase <GuiElement> database   = Databases.GetDatabase <GuiElement>(false);
                    if (database != null && database.TryGetValue(x3, out guiElement))
                    {
                        text = guiElement.Icons["MoodScore"];
                        this.Background.Image = (Resources.Load(text) as Texture2D);
                    }
                }
            }
IL_201:
            if (string.IsNullOrEmpty(text))
            {
                if (gameSaveDescriptor == null)
                {
                    IGameSerializationService service = Services.GetService <IGameSerializationService>();
                    if (service != null && service.GameSaveDescriptor != null)
                    {
                        gameSaveDescriptor = service.GameSaveDescriptor;
                    }
                }
                if (gameSaveDescriptor != null)
                {
                    int num2 = 0;
                    for (;;)
                    {
                        string key        = string.Format("Empire{0}", num2);
                        string lobbyData3 = gameSaveDescriptor.GameSaveSessionDescriptor.GetLobbyData <string>(key, null);
                        if (string.IsNullOrEmpty(lobbyData3))
                        {
                            break;
                        }
                        Steamworks.SteamID steamID = Steamworks.SteamAPI.SteamUser.SteamID;
                        bool flag  = lobbyData3.Contains(steamID.ToString());
                        bool flag2 = !lobbyData3.StartsWith("AI");
                        if (flag || (flag2 && string.IsNullOrEmpty(text)))
                        {
                            string key2       = string.Format("Faction{0}", num2);
                            string lobbyData4 = gameSaveDescriptor.GameSaveSessionDescriptor.GetLobbyData <string>(key2, null);
                            if (!string.IsNullOrEmpty(lobbyData4))
                            {
                                string[]               array2      = lobbyData4.Split(Amplitude.String.Separators, StringSplitOptions.None);
                                string                 x4          = array2[3];
                                GuiElement             guiElement2 = null;
                                IDatabase <GuiElement> database2   = Databases.GetDatabase <GuiElement>(false);
                                if (database2 != null && database2.TryGetValue(x4, out guiElement2))
                                {
                                    text = guiElement2.Icons["MoodScore"];
                                    this.Background.Image = (Resources.Load(text) as Texture2D);
                                }
                            }
                            if (flag)
                            {
                                break;
                            }
                        }
                        num2++;
                    }
                }
                if (string.IsNullOrEmpty(text))
                {
                    if (this.validGuiElements != null && this.validGuiElements.Count != 0)
                    {
                        GuiElement guiElement3 = this.validGuiElements[UnityEngine.Random.Range(0, this.validGuiElements.Count)];
                        Texture2D  image;
                        if (base.GuiService.GuiPanelHelper.TryGetTextureFromIcon(guiElement3, global::GuiPanel.IconSize.MoodScore, out image))
                        {
                            this.Background.Image = image;
                        }
                    }
                    else
                    {
                        this.Background.Image = (Resources.Load("GUI/DynamicBitmaps/Backdrop/Pov_Auriga") as Texture2D);
                    }
                }
            }
        }
    }
Exemplo n.º 18
0
    private void RefreshHandicapDroplist(string lobbyData5)
    {
        if (this.Session.IsHosting && this.canModifyOwnEmpireSettings)
        {
            if (this.Session.SessionMode == SessionMode.Single)
            {
                this.AiDifficultyDroplist.ReadOnly = false;
            }
            if (this.Session.SessionMode != SessionMode.Single)
            {
                if (this.CompetitorIsHuman)
                {
                    string[]           array   = lobbyData5.Split(Amplitude.String.Separators, StringSplitOptions.RemoveEmptyEntries);
                    Steamworks.SteamID steamID = Steamworks.SteamID.Zero;
                    if (Steamworks.SteamAPI.IsSteamRunning)
                    {
                        try
                        {
                            steamID = new Steamworks.SteamID(Convert.ToUInt64(array[0], 16));
                        }
                        catch
                        {
                            this.AiDifficultyDroplist.ReadOnly = true;
                            return;
                        }
                    }
                    if (steamID == Steamworks.SteamID.Zero || !Steamworks.SteamAPI.IsSteamRunning)
                    {
                        this.AiDifficultyDroplist.ReadOnly = true;
                        return;
                    }
                    if (this.Session.GetLobbyMemberData <bool>(steamID, "Ready", false))
                    {
                        this.AiDifficultyDroplist.ReadOnly = true;
                    }
                    else
                    {
                        this.AiDifficultyDroplist.ReadOnly = false;
                    }
                }
                else
                {
                    this.AiDifficultyDroplist.ReadOnly = false;
                }
            }
        }
        else
        {
            this.AiDifficultyDroplist.ReadOnly = true;
        }
        List <string> list  = new List <string>();
        List <string> list2 = new List <string>();

        for (int i = 0; i < 11; i++)
        {
            string key  = "%Handicap" + i.ToString() + "Title";
            string key2 = "%Handicap" + i.ToString() + "Tooltip";
            list.Add(AgeLocalizer.Instance.LocalizeString(key));
            string text = AgeLocalizer.Instance.LocalizeString(key2);
            if ((this.CompetitorIsHuman && i > 5) || (!this.CompetitorIsHuman && i < 5))
            {
                text += AgeLocalizer.Instance.LocalizeString("%HandicapNoAchievementsTooltip");
            }
            list2.Add(text);
        }
        this.AiDifficultyDroplist.ItemTable                       = list.ToArray();
        this.AiDifficultyDroplist.TooltipTable                    = list2.ToArray();
        this.AiDifficultyDroplist.OnSelectionMethod               = "OnChangeHandicapCB";
        this.AiDifficultyDroplist.OnSelectionObject               = base.gameObject;
        this.AiDifficultyDroplist.AgeTransform.Visible            = true;
        this.AiDifficultyDroplist.AgeTransform.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%HandicapTooltip");
        AgeTransform[] array2 = this.AiDifficultyDroplist.AgeTransform.GetChildren().ToArray();
        if (!this.AiDifficultyDroplist.ReadOnly)
        {
            array2[0].Alpha   = 1f;
            array2[1].Visible = true;
            array2[3].Visible = true;
        }
        else
        {
            array2[0].Alpha   = 0.5f;
            array2[1].Visible = false;
            array2[3].Visible = false;
        }
        string x          = string.Format("Handicap{0}", this.EmpireIndex);
        string lobbyData6 = this.Session.GetLobbyData <string>(x, "5");

        if (!string.IsNullOrEmpty(lobbyData6))
        {
            try
            {
                this.AiDifficultyDroplist.SelectedItem = int.Parse(lobbyData6);
            }
            catch
            {
                Diagnostics.LogWarning("Failed to parse the lobbyDataHandicap");
            }
        }
    }
Exemplo n.º 19
0
 protected virtual void SteamMatchMakingService_SteamLobbyDataUpdate(object sender, SteamLobbyDataUpdateEventArgs e)
 {
     if (this.SteamIDLobby != null && this.SteamMatchMakingService != null)
     {
         if (e.Message.m_bSuccess == 0)
         {
             return;
         }
         if (e.Message.m_ulSteamIDLobby == this.SteamIDLobby)
         {
             if (e.Message.m_ulSteamIDMember == this.SteamIDLobby)
             {
                 Diagnostics.Log("SteamMatchMakingService_SteamLobbyDataUpdate (lobby: {0}).", new object[]
                 {
                     e.Message.m_ulSteamIDLobby
                 });
                 if (!this.hosting)
                 {
                     Steamworks.SteamID lobbyOwner = this.SteamMatchMakingService.SteamMatchMaking.GetLobbyOwner(this.SteamIDLobby);
                     if (lobbyOwner == this.SteamIDUser)
                     {
                         Diagnostics.LogWarning("We have been promoted lobby owner by steam! we are now hosting the game...");
                         this.hosting = true;
                     }
                     if (lobbyOwner != this.steamIDLobbyOwner)
                     {
                         this.steamIDLobbyOwner = lobbyOwner;
                         this.OnLobbyOwnerChange(new LobbyOwnerChangeEventArgs(this.SteamIDLobby, this.steamIDLobbyOwner));
                     }
                 }
                 Steamworks.SteamMatchMaking steamMatchMaking = this.SteamMatchMakingService.SteamMatchMaking;
                 int lobbyDataCount = steamMatchMaking.GetLobbyDataCount(this.SteamIDLobby);
                 for (int i = 0; i < lobbyDataCount; i++)
                 {
                     string x;
                     string text;
                     if (steamMatchMaking.GetLobbyDataByIndex(this.SteamIDLobby, i, out x, out text))
                     {
                         if (string.IsNullOrEmpty(text))
                         {
                             text = null;
                         }
                         this.SetLobbyData(x, text, false);
                     }
                 }
             }
             else
             {
                 Diagnostics.Log("SteamMatchMakingService_SteamLobbyDataUpdate (lobby: {0}).", new object[]
                 {
                     e.Message.m_ulSteamIDLobby
                 });
                 Steamworks.SteamID steamID = new Steamworks.SteamID(e.Message.m_ulSteamIDMember);
                 if (steamID.IsValid)
                 {
                     Diagnostics.Log("SteamMatchMakingService_SteamLobbyDataUpdate (member: {0}).", new object[]
                     {
                         e.Message.m_ulSteamIDMember
                     });
                     this.OnLobbyMemberDataChange(new LobbyMemberDataChangeEventArgs(steamID));
                 }
             }
         }
     }
 }