Exemple #1
0
    private void OnMouseEnterCB()
    {
        IMouseCursorService service = Services.GetService <IMouseCursorService>();

        Diagnostics.Assert(service != null);
        service.AddKey(base.GetType().ToString());
    }
    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);
    }