コード例 #1
0
    IEnumerator LoadGameLevel(CustomLevel level)
    {
        yield return(StartCoroutine(LoadLoadingScreen()));

        LoadingScreenController lsc = LoadingScreenController.GetInstance();

        lsc?.SetLevelName(level.name);

        AsyncOperation targetLevel = SceneManager.LoadSceneAsync(level.sceneBuiltInId, LoadSceneMode.Additive);

        while (!targetLevel.isDone)
        {
            targetLevel.allowSceneActivation = false;
            int percentage = Convert.ToInt32(targetLevel.progress * 100);
            lsc?.SetLoadingProgress(percentage);

            if (targetLevel.progress >= 0.9f)
            {
                break;
            }

            yield return(null);
        }

        lsc?.SetLoaded(true);
        yield return(new WaitUntil(() => Input.GetKeyDown(KeyCode.Space)));

        targetLevel.allowSceneActivation = true;
    }
 private static LoadingScreenController GetOrSetInstance()
 {
     if (_instance == null)
     {
         _instance = new LoadingScreenController();
     }
     return(_instance);
 }
コード例 #3
0
    // Use this for initialization
    void Start()
    {
        btn = GetComponent <Button> ();
        btn.onClick.AddListener(generateCards);

        CCC = GameObject.FindGameObjectWithTag("CardCreatorController").GetComponent <CardCreatorController> ();
        LSC = GameObject.FindGameObjectWithTag("LoadingScreenController").GetComponent <LoadingScreenController> ();
        generateCardsFirstTime();          // at the start
    }
 private void Awake()
 {
     if (Instance != null && Instance != this)
     {
         Destroy(gameObject);
     }
     else
     {
         Instance = this;
     }
 }
コード例 #5
0
        public static SButton AddScene(string scene)
        {
            SButton button = new SButton(scene)
            {
                Alignment = TextAnchor.MiddleLeft,
                With      = { new SFadeInAnimation() },
                OnClick   = b => {
                    LoadingScreenController.LoadScene(scene, "", "");
                }
            };

            ScenesGroup.Children.Add(button);
            return(button);
        }
コード例 #6
0
 void Awake()
 {
     if (instanceOf == null)
     {
         instanceOf = this;
         DontDestroyOnLoad(gameObject);
         Loading(false, null);
     }
     else
     {
         Destroy(this);
         return;
     }
 }
コード例 #7
0
ファイル: ErrorTrap.cs プロジェクト: pepoluan/NRaas
        /*
         * public static void OnLoadObject(int index, ref object obj)
         * {
         *  using (TestSpan span = new TestSpan(TimeSpanLogger.Bin, "OnLoadObject", DebuggingLevel))
         *  {
         *      try
         *      {
         *          // Too many, and don't care
         *          if (IsIgnored(obj)) return;
         *      }
         *      catch (Exception e)
         *      {
         *          DebugException(obj.GetType().ToString(), e);
         *      }
         *  }
         * }
         */

        public static void ChangeLoadingScreenCaption(string text)
        {
            LoadingScreenController controller = LoadingScreenController.Instance;

            if (controller == null)
            {
                return;
            }

            if (controller.mTipText == null)
            {
                return;
            }

            controller.mTipText.Caption = text;
        }
コード例 #8
0
    public static IEnumerator Load(int id)
    {
        int            lsId = (int)DefaultScreens.LoadingScreen;
        AsyncOperation loadingScreenOperation = SceneManager.LoadSceneAsync(lsId, LoadSceneMode.Additive);

        while (!loadingScreenOperation.isDone)
        {
            yield return(null);
        }

        yield return(null);

        GameObject contls           = GameObject.FindGameObjectWithTag("LoadingScreenControllers");
        LoadingScreenController lsc = contls.GetComponent <LoadingScreenController>();

        AsyncOperation targetLevel = SceneManager.LoadSceneAsync(id, LoadSceneMode.Additive);

        targetLevel.allowSceneActivation = false;

        while (!targetLevel.isDone)
        {
            int percentage = Convert.ToInt32(targetLevel.progress * 100);
            lsc.SetLoadingProgress(percentage);

            if (targetLevel.progress >= 0.9f)
            {
                lsc.SetLoaded(true);
                if (Input.GetKeyDown(KeyCode.Space))
                {
                    targetLevel.allowSceneActivation = true;
                }
            }
            yield return(null);
        }

        targetLevel.completed += o =>
        {
            SceneManager.UnloadSceneAsync(SceneManager.GetActiveScene())
            .completed += ao =>
            {
                SceneManager.UnloadSceneAsync((int)DefaultScreens.LoadingScreen);
            };
        };

        yield return(null);
    }
コード例 #9
0
        public void OnSearch(string searchString)
        {
            if (string.IsNullOrEmpty(searchString))
            {
                return;
            }

            const string _loadingScreenPrefabPath = "Prefabs/Production/LoadingPanel";
            var          go = NGUITools.AddChild(gameObject, (GameObject)Resources.Load(_loadingScreenPrefabPath));

            _loadingScreen = go.GetComponent <LoadingScreenController> ();
            _loadingScreen._loadingLabel.text = "Searching...";
            _searchString = searchString;

            HelperMethods.AddInteractionBlocker();

            ITTDataCache.Instance.Data.GetDataEntry((int)DataCacheIndices.USER_FLAGS, HelperMethods.Instance.UnFlagCurrentLocation);
            ITTDataCache.Instance.GetGeoLocationData(searchString, OnUpdateGeoLocation, OnFailGeoData);
            model.inputBox.value = null;
        }
コード例 #10
0
        private void BtnLaunch_LeftClick(object sender, EventArgs e)
        {
            SavedGame sg = savedGames[lbSaveGameList.SelectedIndex];

            Logger.Log("Loading saved game " + sg.FileName);

            File.Delete(ProgramConstants.GamePath + ProgramConstants.SPAWNER_SETTINGS);
            StreamWriter sw = new StreamWriter(ProgramConstants.GamePath + ProgramConstants.SPAWNER_SETTINGS);

            sw.WriteLine("; generated by DTA Client");
            sw.WriteLine("[Settings]");
            sw.WriteLine("Scenario=spawnmap.ini");
            sw.WriteLine("SaveGameName=" + sg.FileName);
            sw.WriteLine("LoadSaveGame=Yes");
            sw.WriteLine("SidebarHack=" + ClientConfiguration.Instance.SidebarHack);
            sw.WriteLine("CustomLoadScreen=" + LoadingScreenController.GetLoadScreenName("g"));
            sw.WriteLine("Firestorm=No");
            sw.WriteLine("GameSpeed=" + UserINISettings.Instance.GameSpeed);
            sw.WriteLine();
            sw.Close();

            File.Delete(ProgramConstants.GamePath + "spawnmap.ini");
            sw = new StreamWriter(ProgramConstants.GamePath + "spawnmap.ini");
            sw.WriteLine("[Map]");
            sw.WriteLine("Size=0,0,50,50");
            sw.WriteLine("LocalSize=0,0,50,50");
            sw.WriteLine();
            sw.Close();

            discordHandler?.UpdatePresence(sg.GUIName, true);

            Enabled = false;
            GameProcessLogic.GameProcessExited += GameProcessExited_Callback;

            GameProcessLogic.StartGameProcess();
        }
コード例 #11
0
        public override void Startup()
        {
            string msg = "InWorldStateEx:Startup";

            CRAPJailBreak.InsanityWriteLog(msg);

            try
            {
                // StateMachineState:Startup()
                mBaseCallFlag |= BaseCallFlag.kStartup;
                //base.Startup();

                msg += Common.NewLine + "A";
                CRAPJailBreak.InsanityWriteLog(msg);

                Sims3.Gameplay.UI.Responder.GameStartup();

                bool flag = false;

                try
                {
                    ModalDialog.EnableModalDialogs = false;

                    if (World.IsEditInGameFromWBMode())
                    {
                        Sims3.Gameplay.Autonomy.Autonomy.DisableMoodContributors = true;
                    }

                    msg += Common.NewLine + "B";
                    CRAPJailBreak.InsanityWriteLog(msg);

                    mStateMachine   = StateMachine.Create(0x1, "InWorld");
                    mSubStates[0x0] = new LiveModeState();
                    mSubStates[0x1] = new BuildModeState();
                    mSubStates[0x2] = new BuyModeState();
                    mSubStates[0xc] = new ShoppingModeState();
                    mSubStates[0x3] = new CASFullModeState();
                    mSubStates[0x4] = new CASDresserModeState();
                    mSubStates[0x5] = new CASMirrorModeState();
                    mSubStates[0x6] = new CASTattooModeState();
                    mSubStates[0x7] = new CASStylistModeState();
                    mSubStates[0x8] = new CASTackModeState();
                    mSubStates[0x9] = new CASCollarModeState();
                    mSubStates[0xa] = new CASSurgeryFaceModeState();
                    mSubStates[0xb] = new CASSurgeryBodyModeState();
                    mSubStates[0xf] = new PlayFlowState();
                    mSubStates[0xe] = new EditTownState();

                    foreach (InWorldSubState state in mSubStates)
                    {
                        mStateMachine.AddState(state);
                    }

                    msg += Common.NewLine + "C";
                    CRAPJailBreak.InsanityWriteLog(msg);

                    StateMachineManager.AddMachine(mStateMachine);
                    if (GameStates.IsTravelling || GameStates.IsEditingOtherTown)
                    {
                        try
                        {
                            Sims3.Gameplay.WorldBuilderUtil.CharacterImportOnGameLoad.RemapSimDescriptionIds();
                        }
                        catch (Exception e)
                        {
                            Common.DebugException("RemapSimDescriptionIds", e);
                        }
                    }

                    msg += Common.NewLine + "D";
                    CRAPJailBreak.InsanityWriteLog(msg);

                    if (GameStates.IsTravelling)
                    {
                        msg += Common.NewLine + "E1";
                        CRAPJailBreak.InsanityWriteLog(msg);

                        GameStates.ImportTravellingHousehold();
                    }
                    else if ((!GameStates.IsEditingOtherTown) && (GameUtils.GetCurrentWorldType() == WorldType.Base) && (GameStates.HasTravelData) && (GameStates.TravelHousehold == null))
                    {
                        msg += Common.NewLine + "E2";
                        CRAPJailBreak.InsanityWriteLog(msg);

                        GameStates.ClearTravelStatics();
                    }

                    msg += Common.NewLine + "F";
                    CRAPJailBreak.InsanityWriteLog(msg);

                    Sim selectedActor = PlumbBob.SelectedActor;
                    if (selectedActor != null)
                    {
                        msg += Common.NewLine + "SelectedActor: " + selectedActor.FullName;
                        msg += Common.NewLine + "SkillManager: " + (selectedActor.SkillManager != null);
                        msg += Common.NewLine + "SocialComponent: " + (selectedActor.SocialComponent != null);
                        msg += Common.NewLine + "CareerManager: " + (selectedActor.CareerManager != null);
                        msg += Common.NewLine + "TraitManager: " + (selectedActor.TraitManager != null);
                        msg += Common.NewLine + "SimDescription: " + (selectedActor.SimDescription != null);
                        msg += Common.NewLine + "InteractionQueue: " + (selectedActor.InteractionQueue != null);
                        msg += Common.NewLine + "OccultManager: " + (selectedActor.OccultManager != null);
                    }
                    else
                    {
                        msg += Common.NewLine + "No SelectedActor";
                    }

                    CRAPJailBreak.InsanityWriteLog(msg);

                    try
                    {
                        mPostWorldInitializers = new Initializers("PostWorldInitializers", this);

                        /*
                         * for (int i = 0; i < mPostWorldInitializers.mInitializerRecords.Count; i++)
                         * {
                         *  Initializers.Record record = mPostWorldInitializers.mInitializerRecords[i];
                         *
                         *  if ((record.mTypeName.Replace(" ", "") == "Sims3.Gameplay.CAS.SimDescription,Sims3GameplaySystems") &&
                         *      (record.mInitName == "PostLoadFixUp"))
                         *  {
                         *      record.mTypeName = typeof(SimDescriptionEx).FullName + "," + typeof(SimDescriptionEx).Assembly.GetName();
                         *
                         *      // Record is a struct, we must replace the old copy with a new one
                         *      mPostWorldInitializers.mInitializerRecords[i] = record;
                         *  }
                         * }
                         *
                         * //Initialize(mPostWorldInitializers);
                         */

                        mPostWorldInitializers.Initialize();
                    }
                    catch (Exception e)
                    {
                        CRAPJailBreak.InsanityException(msg, e);
                    }

                    msg += Common.NewLine + "G";
                    CRAPJailBreak.InsanityWriteLog(msg);

                    List <SimDescription> dyingSims = null;
                    if (GameStates.IsTravelling)
                    {
                        dyingSims = GameStates.PostTravelingFixUp();
                    }

                    msg += Common.NewLine + "H";
                    CRAPJailBreak.InsanityWriteLog(msg);

                    if (GameStates.IsEditingOtherTown)
                    {
                        GameStates.PostLoadEditTownFixup();
                    }

                    msg += Common.NewLine + "I";
                    CRAPJailBreak.InsanityWriteLog(msg);

                    GameStates.NullEditTownDataDataIfEditingOriginalStartingWorld();
                    try
                    {
                        if (GameUtils.IsOnVacation())
                        {
                            if ((dyingSims != null) && (AgingManager.NumberAgingYearsElapsed != -1f))
                            {
                                float yearsGone = GameStates.NumberAgingYearsElapsed - AgingManager.NumberAgingYearsElapsed;

                                // Custom function
                                StoryProgressionService.FixUpAfterTravel(yearsGone, dyingSims);
                            }
                            AgingManager.NumberAgingYearsElapsed = GameStates.NumberAgingYearsElapsed;
                        }
                    }
                    catch (Exception e)
                    {
                        CRAPJailBreak.InsanityException(msg, e);
                    }

                    msg += Common.NewLine + "J";
                    CRAPJailBreak.InsanityWriteLog(msg);

                    Sims3.Gameplay.Gameflow.GameSpeed pause = Sims3.Gameplay.Gameflow.GameSpeed.Pause;

                    if (GameStates.StartupState == SubState.LiveMode)
                    {
                        flag = !GameStates.IsEditingOtherTown && (((GameStates.ForceStateChange || !PlayFlowModel.Singleton.GameEntryLive) || (PlumbBob.SelectedActor != null)) || GameStates.IsTravelling);
                        if (flag)
                        {
                            if (Sims3.Gameplay.Gameflow.sGameLoadedFromWorldFile)
                            {
                                pause = Sims3.SimIFace.Gameflow.GameSpeed.Normal;
                            }
                            else
                            {
                                pause = Sims3.Gameplay.Gameflow.sPersistedGameSpeed;
                            }
                        }
                    }

                    msg += Common.NewLine + "K";
                    CRAPJailBreak.InsanityWriteLog(msg);

                    Sims3.Gameplay.Gameflow.sGameLoadedFromWorldFile = false;
                    string s = CommandLine.FindSwitch("speed");
                    if (s != null)
                    {
                        int num2;
                        if (int.TryParse(s, out num2))
                        {
                            pause = (Sims3.Gameplay.Gameflow.GameSpeed)num2;
                        }
                        else
                        {
                            ParserFunctions.TryParseEnum <Sims3.Gameplay.Gameflow.GameSpeed>(s, out pause, Sims3.Gameplay.Gameflow.GameSpeed.Normal);
                        }
                    }

                    msg += Common.NewLine + "L";
                    CRAPJailBreak.InsanityWriteLog(msg);

                    Sims3.Gameplay.Gameflow.SetGameSpeed(pause, Sims3.Gameplay.Gameflow.SetGameSpeedContext.GameStates);
                    NotificationManager.Load();
                }
                finally
                {
                    ModalDialog.EnableModalDialogs = true;
                }

                switch (GameStates.StartupState)
                {
                case SubState.EditTown:
                    msg += Common.NewLine + "StartupState: EditTown";

                    GameUtils.EnableSceneDraw(true);
                    LoadingScreenController.Unload();
                    GotoEditTown();
                    break;

                case SubState.PlayFlow:
                    if (World.IsEditInGameFromWBMode())
                    {
                        msg += Common.NewLine + "StartupState: PlayFlow (A)";

                        GameUtils.EnableSceneDraw(true);
                        LoadingScreenController.Unload();
                        GotoLiveMode();
                    }
                    else if (!PlayFlowModel.PlayFlowEnabled || !PlayFlowModel.Singleton.GameEntryLive)
                    {
                        msg += Common.NewLine + "StartupState: PlayFlow (B)";

                        GameUtils.EnableSceneDraw(true);
                        LoadingScreenController.Unload();
                        GotoLiveMode();
                    }
                    else
                    {
                        msg += Common.NewLine + "StartupState: PlayFlow (C)";

                        GotoPlayFlow();
                    }
                    break;

                case SubState.LiveMode:
                    if (flag)
                    {
                        msg += Common.NewLine + "StartupState: LiveMode (A)";

                        GameUtils.EnableSceneDraw(true);
                        LoadingScreenController.Unload();
                        GotoLiveMode();
                    }
                    else
                    {
                        msg += Common.NewLine + "StartupState: LiveMode (B)";

                        GameUtils.EnableSceneDraw(true);
                        LoadingScreenController.Unload();
                        GotoPlayFlow();
                    }
                    break;
                }

                msg += Common.NewLine + "M";
                CRAPJailBreak.InsanityWriteLog(msg);

                if (Sims3.Gameplay.Gameflow.sShowObjectReplacedWarning)
                {
                    SimpleMessageDialog.Show(Common.LocalizeEAString("Ui/Warning/LoadGame:Warning"), Common.LocalizeEAString("Ui/Warning/LoadGame:ReplacedObjects"), ModalDialog.PauseMode.PauseSimulator);
                    Sims3.Gameplay.Gameflow.sShowObjectReplacedWarning = false;
                }
            }
            catch (Exception e)
            {
                CRAPJailBreak.InsanityException(msg, e);
            }
        }
コード例 #12
0
    /// <summary>
    /// Signals the game manager to connect to a server
    /// </summary>
    public IEnumerator ConnectToServerCoroutine(string hostname, int port)
    {
        // open loading screen
        AsyncOperation loadLoadingScreenTask = SceneManager.LoadSceneAsync("LoadingScreen", LoadSceneMode.Additive);

        while (!loadLoadingScreenTask.isDone)
        {
            yield return(null);
        }

        Debug.Log("Loading screen opened");

        SceneManager.SetActiveScene(SceneManager.GetSceneByName("LoadingScreen"));
        SceneManager.MoveGameObjectToScene(gameObject, SceneManager.GetSceneByName("LoadingScreen"));
        AsyncOperation unloadMainMenuTask = SceneManager.UnloadSceneAsync("MainMenu");

        while (!unloadMainMenuTask.isDone)
        {
            yield return(null);
        }

        Debug.Log("Closed main menu");

        // find loading screen controller
        _loadingScreen = GameObject.FindGameObjectWithTag("Loading Screen Controller").GetComponent <LoadingScreenController>();
        _loadingScreen.UpdateSubtitleText($"Attempting to connect to {hostname}:{port}");

        // set up network client
        _disconnecting        = false;
        _client               = new NetworkClient();
        _client.Disconnected += ClientDisconnectedEventHandler;
        Task connectTask = new Task(() =>
        {
            _client.Connect(hostname, port);
        });

        connectTask.Start();

        while (!connectTask.IsCompleted)
        {
            yield return(null);
        }

        if (connectTask.IsFaulted || !_client.Connected)
        {
            throw (Exception)connectTask.Exception ?? new UnityException("Connection failed: Unknown");
        }

        _loadingScreen.UpdateSubtitleText("Connection established. Logging in...");

        // perform handshake/login
        LoginSuccessPacket loginSuccess = null;
        JoinGamePacket     joinGame     = null;

        // TODO: put the rest of the login packets here
        // player abilities, item slot change, etc.

        // send off packets
        _client.WritePackets(new Packet[] {
            new HandshakePacket()
            {
                Address   = hostname,
                Port      = port,
                NextState = NetworkClient.ProtocolState.LOGIN
            },
            new LoginStartPacket()
            {
                Username = Username
            }
        });

        _client.State = NetworkClient.ProtocolState.LOGIN;

        // get login response
        while (true)
        {
            try
            {
                var packet = _client.ReadNextPacket();
                switch ((ClientboundIDs)packet.ID)
                {
                case ClientboundIDs.LOGIN_SUCCESS:
                    loginSuccess = new LoginSuccessPacket(packet);
                    break;

                case ClientboundIDs.JOIN_GAME:
                    joinGame = new JoinGamePacket(packet);
                    break;

                case ClientboundIDs.LOGIN_DISCONNECT:
                    Disconnect($"Disconnected from server: {new DisconnectPacket(packet).JSONResponse}");
                    yield break;
                }
            }
            catch (Exception e)
            {
                Disconnect($"Failed to login: {e.Message}");
                yield break;
            }

            if (loginSuccess != null && joinGame != null)
            {
                _client.State = NetworkClient.ProtocolState.PLAY;
                break;
            }
        }

        _loadingScreen.UpdateSubtitleText("Downloading world...");

        // set settings from server
        _playerUuid   = loginSuccess.UUID;
        _currentWorld = new World(DebugCanvas)
        {
            Dimension = joinGame.Dimension,
        };

        // open game scene
        AsyncOperation loadGameTask = SceneManager.LoadSceneAsync("Game", LoadSceneMode.Additive);

        while (!loadGameTask.isDone)
        {
            yield return(null);
        }
        SceneManager.SetActiveScene(SceneManager.GetSceneByName("Game"));
        SceneManager.MoveGameObjectToScene(gameObject, SceneManager.GetSceneByName("Game"));

        // set up references in game scene
        _currentWorld.ChunkRenderer             = Instantiate(ChunkRendererPrefab, Vector3.zero, Quaternion.identity).GetComponent <ChunkRenderer>();
        _currentWorld.ChunkRenderer.DebugCanvas = DebugCanvas;

        // start network worker tasks
        _netReadTask = new Task(() =>
        {
            NetworkReadWorker(_cancellationTokenSource.Token);
        }, _cancellationTokenSource.Token);
        _netReadTask.Start();

        _netWriteTask = new Task(() =>
        {
            NetworkWriteWorker(_cancellationTokenSource.Token);
        }, _cancellationTokenSource.Token);
        _netWriteTask.Start();

        _initialized = true;

        // start tick loop
        StartCoroutine(ClientTickLoopCoroutine(_cancellationTokenSource.Token));
    }
コード例 #13
0
ファイル: LiveModeStateEx.cs プロジェクト: yakoder/NRaas
        public override void Startup()
        {
            Common.StringBuilder msg = new Common.StringBuilder("LiveModeStateEx:Startup" + Common.NewLine);
            Traveler.InsanityWriteLog(msg);

            try
            {
                UIManager.BlackBackground(false);

                msg += "A1";
                Traveler.InsanityWriteLog(msg);

                // StateMachineState:Startup()
                mBaseCallFlag |= BaseCallFlag.kStartup;

                // InWorldSubState:Startup()
                while (sDelayNextStateStartupCount > 0x0)
                {
                    SpeedTrap.Sleep();
                }

                msg += "A2";
                Traveler.InsanityWriteLog(msg);

                EventTracker.SendEvent(new InWorldSubStateEvent(this, true));

                //base.Startup();

                msg += "A3";
                Traveler.InsanityWriteLog(msg);

                ShowUI(true);

                if (CameraController.IsMapViewModeEnabled() && !TutorialModel.Singleton.IsTutorialRunning())
                {
                    CameraController.EnableCameraMapView(true);
                }

                msg += "B";
                Traveler.InsanityWriteLog(msg);

                CASExitLoadScreen.Close();

                bool traveling = false;
                if (GameStates.IsTravelling)
                {
                    if (GameStates.sTravelData == null)
                    {
                        GameStates.ClearTravelStatics();
                    }
                    else
                    {
                        traveling = true;
                        GameStatesEx.OnArrivalAtVacationWorld();
                    }
                }

                msg += "C";
                Traveler.InsanityWriteLog(msg);

                if (GameStates.sNextSimToSelect != null)
                {
                    DreamCatcher.SelectNoLotCheckImmediate(GameStates.sNextSimToSelect, true, true);
                    GameStates.sNextSimToSelect = null;
                }

                msg += "D";
                Traveler.InsanityWriteLog(msg);

                bool flag2 = false;
                if (LoadingScreenController.Instance != null)
                {
                    if ((GameStates.IsPerfTestRunning || (CommandLine.FindSwitch("campos") != null)) || (CommandLine.FindSwitch("camtarget") != null))
                    {
                        msg += "D1";
                        Traveler.InsanityWriteLog(msg);

                        GameUtils.EnableSceneDraw(true);
                        LoadingScreenController.Unload();
                    }
                    else if (traveling)
                    {
                        msg += "D2";
                        Traveler.InsanityWriteLog(msg);

                        uint customFlyThroughIndex = CameraController.GetCustomFlyThroughIndex();
                        if (GameStates.IsNewGame && (customFlyThroughIndex != 0x0))
                        {
                            msg += "D3";
                            Traveler.InsanityWriteLog(msg);

                            WaitForLotLoad(true, false);
                            ShowUI(false);
                            ShowMaptags(false);

                            msg += "D4";
                            Traveler.InsanityWriteLog(msg);

                            AudioManager.MusicMode = MusicMode.Flyby;
                            CameraController.OnCameraFlyThroughFinishedCallback += OnCameraFlyThroughFinishedEvent;
                            CameraController.StartFlyThrough(customFlyThroughIndex, false);
                            flag2 = true;

                            msg += "D5";
                            Traveler.InsanityWriteLog(msg);

                            GameUtils.EnableSceneDraw(true);
                            LoadingScreenController.Unload();
                            while (LoadingScreenController.Instance != null)
                            {
                                Sleep(0.0);
                            }
                        }
                        else
                        {
                            msg += "D6";
                            Traveler.InsanityWriteLog(msg);

                            WaitForLotLoad(true, true);
                            Camera.SetView(CameraView.SimView, true, true);
                        }
                    }
                    else
                    {
                        msg += "D7";
                        Traveler.InsanityWriteLog(msg);

                        Camera.RestorePersistedState();

                        msg += "D8";
                        Traveler.InsanityWriteLog(msg);

                        WaitForLotLoad(false, true);
                    }
                }
                else if (traveling)
                {
                    msg += "D9";
                    Traveler.InsanityWriteLog(msg);

                    WaitForLotLoad(!GameUtils.IsUniversityWorld(), true);
                    Camera.SetView(CameraView.SimView, true, true);
                }

                msg += "E";
                Traveler.InsanityWriteLog(msg);

                UserToolUtils.UserToolGeneric(0xc8, new ResourceKey(0x0L, 0x0, 0x0));
                if (!flag2)
                {
                    GameUtils.Unpause();
                }

                if (AudioManager.MusicMode != MusicMode.Flyby)
                {
                    AudioManager.MusicMode = MusicMode.None;
                }

                msg += "F";
                Traveler.InsanityWriteLog(msg);

                InWorldSubState.EdgeScrollCheck();
                InWorldSubState.OpportunityDialogCheck();

                try
                {
                    DreamsAndPromisesManager.ValidateLifetimeWishes();
                }
                catch (Exception e)
                {
                    Common.Exception(msg, e);
                }

                LifeEventManager.ValidatePendingLifeEvents();
                if (GameUtils.IsInstalled(ProductVersion.EP9))
                {
                    Tutorialette.TriggerLesson(Lessons.Degrees, Sim.ActiveActor);
                }

                if (GameUtils.GetCurrentWorldType() == WorldType.Base)
                {
                    Tutorialette.TriggerLesson(Lessons.Traveling, Sim.ActiveActor);
                }

                if (Sims3.Gameplay.ActiveCareer.ActiveCareer.ActiveCareerShowGeneralLesson)
                {
                    Tutorialette.TriggerLesson(Lessons.Professions, Sim.ActiveActor);
                }

                msg += "G";
                Traveler.InsanityWriteLog(msg);

                Tutorialette.TriggerLesson(Lessons.AgingStageLengths, Sim.ActiveActor);

                Sim selectedActor = PlumbBob.SelectedActor;
                if (selectedActor != null)
                {
                    // Custom
                    if (GameStates.sMovingWorldData != null)
                    {
                        WorldData.MergeFromCrossWorldData();
                    }

                    if (selectedActor.LotHome != null)
                    {
                        if (selectedActor.LotHome.HasVirtualResidentialSlots)
                        {
                            Tutorialette.TriggerLesson(Lessons.ApartmentLiving, selectedActor);
                        }
                    }
                    else
                    {
                        Lot lot = Helpers.TravelUtilEx.FindLot();
                        if (lot != null)
                        {
                            lot.MoveIn(selectedActor.Household);

                            foreach (SimDescription sim in Households.All(selectedActor.Household))
                            {
                                if (sim.CreatedSim == null)
                                {
                                    FixInvisibleTask.Perform(sim, false);
                                }
                                else
                                {
                                    bool replace = (sim.CreatedSim == selectedActor);

                                    ResetSimTask.Perform(sim.CreatedSim, false);

                                    if (replace)
                                    {
                                        selectedActor = sim.CreatedSim;
                                    }
                                }
                            }

                            msg += "MoveIn";
                        }
                    }

                    if (selectedActor.Household != null)
                    {
                        foreach (SimDescription description in Households.Humans(selectedActor.Household))
                        {
                            // Custom
                            if (GameStates.sMovingWorldData != null)
                            {
                                CrossWorldControl.Restore(description);
                            }

                            if (description.Child || description.Teen)
                            {
                                Tutorialette.TriggerLesson(Lessons.Pranks, null);
                                break;
                            }
                        }
                    }

                    if (selectedActor.BuffManager != null)
                    {
                        BuffMummysCurse.BuffInstanceMummysCurse element = selectedActor.BuffManager.GetElement(BuffNames.MummysCurse) as BuffMummysCurse.BuffInstanceMummysCurse;
                        if (element != null)
                        {
                            BuffMummysCurse.SetCursedScreenFX(element.CurseStage, false);
                        }
                    }

                    if (selectedActor.CareerManager != null)
                    {
                        selectedActor.CareerManager.UpdateCareerUI();
                    }

                    if (Traveler.Settings.mAllowSpawnWeatherStone && GameUtils.IsInstalled(ProductVersion.EP7) && GameUtils.IsInstalled(ProductVersion.EP8))
                    {
                        Sims3.Gameplay.UI.Responder.Instance.TrySpawnWeatherStone();
                    }
                }

                msg += "H";
                Traveler.InsanityWriteLog(msg);

                // Custom
                if (GameStates.sMovingWorldData != null)
                {
                    GameStatesEx.UpdateMiniSims(GameStatesEx.GetAllSims());

                    foreach (SimDescription sim in Households.All(Household.ActiveHousehold))
                    {
                        MiniSimDescription miniSim = MiniSimDescription.Find(sim.SimDescriptionId);
                        if (miniSim != null)
                        {
                            miniSim.Instantiated = true;
                            if (miniSim.HomeWorld != GameUtils.GetCurrentWorld())
                            {
                                miniSim.HomeWorld = GameUtils.GetCurrentWorld();
                            }
                        }

                        if (sim.HomeWorld != GameUtils.GetCurrentWorld())
                        {
                            sim.HomeWorld = GameUtils.GetCurrentWorld();
                        }
                    }
                }

                GameStates.SetupPostMoveData();
                GameStates.ClearMovingData();
                MovingWorldsWizardCheck();

                // Custom
                Household.IsTravelImport = false;

                InWorldSubStateEx.PlaceLotWizardCheck(this);

                msg += "I";
                Traveler.InsanityWriteLog(msg);

                foreach (Sim sim in LotManager.Actors)
                {
                    try
                    {
                        if (sim.HasBeenDestroyed)
                        {
                            continue;
                        }

                        OccultManager occultManager = sim.OccultManager;
                        if (occultManager != null)
                        {
                            occultManager.RestoreOccultIfNecessary();
                        }
                    }
                    catch (Exception e)
                    {
                        Common.Exception(sim, null, msg, e);
                    }
                }

                msg += "J";
                Traveler.InsanityWriteLog(msg);

                // Custom
                foreach (SimDescription description in SimListing.GetResidents(false).Values)
                {
                    if (description.LotHome == null)
                    {
                        continue;
                    }

                    MiniSimDescription miniSimDescription = description.GetMiniSimDescription();
                    if (miniSimDescription != null)
                    {
                        miniSimDescription.LotHomeId = description.LotHome.LotId;
                    }
                }

                msg += "K";
                Traveler.InsanityWriteLog(msg);
            }
            catch (Exception e)
            {
                Traveler.InsanityException(msg, e);
            }
            finally
            {
                CASExitLoadScreen.Close();
            }
        }
コード例 #14
0
        public static Lot PromptForLot()
        {
            Lot baseCampLot = LotManager.GetBaseCampLot();

            if (!UIUtils.IsOkayToStartModalDialog(false, true))
            {
                return(null);
            }

            List <IMapTagPickerInfo> mapTagPickerInfos = new List <IMapTagPickerInfo>();

            mapTagPickerInfos.Add(new MapTagPickerLotInfo(baseCampLot, MapTagType.BaseCamp));
            Dictionary <ulong, bool> dictionary = new Dictionary <ulong, bool>();

            foreach (Lot lot in LotManager.AllLots)
            {
                if (!lot.IsResidentialLot)
                {
                    continue;
                }

                if (lot.IsWorldLot)
                {
                    continue;
                }

                if (lot.Household != null)
                {
                    continue;
                }

                if (lot.ResidentialLotSubType == ResidentialLotSubType.kEP1_PlayerOwnable)
                {
                    continue;
                }

                Lot.LotMetrics metrics = new Lot.LotMetrics();
                lot.GetLotMetrics(ref metrics);
                if (metrics.FridgeCount == 0)
                {
                    continue;
                }

                if ((lot != null) && !dictionary.ContainsKey(lot.LotId))
                {
                    dictionary[lot.LotId] = true;
                    mapTagPickerInfos.Add(new MapTagPickerLotInfo(lot, MapTagType.AvailableHousehold));
                }
            }

            GameUtils.EnableSceneDraw(true);
            LoadingScreenController.Unload();
            while (LoadingScreenController.Instance != null)
            {
                SpeedTrap.Sleep(0);
            }

            IMapTagPickerInfo info = MapTagPickerDialog.Show(mapTagPickerInfos, TravelUtil.LocalizeString("ChooseHomeLot", new object[0]), TravelUtil.LocalizeString("Accept", new object[0]), false);

            if (info == null)
            {
                return(null);
            }

            return(LotManager.GetLot(info.LotId));
        }
コード例 #15
0
ファイル: GameInitState.cs プロジェクト: VictorTverdy/Omni
 public override void PreconfigureStateScene()
 {
     m_loadingScreenController = m_sceenGameObject.GetComponentInChildren <LoadingScreenController>();
 }
コード例 #16
0
		public void OnSearch(string searchString)
		{
			if (string.IsNullOrEmpty(searchString)) {
				return;
			}

			const string _loadingScreenPrefabPath = "Prefabs/Production/LoadingPanel";
			var go = NGUITools.AddChild(gameObject, (GameObject)Resources.Load(_loadingScreenPrefabPath));
			_loadingScreen = go.GetComponent<LoadingScreenController> ();
			_loadingScreen._loadingLabel.text = "Searching...";
			_searchString = searchString;

			HelperMethods.AddInteractionBlocker();

			ITTDataCache.Instance.Data.GetDataEntry((int)DataCacheIndices.USER_FLAGS, HelperMethods.Instance.UnFlagCurrentLocation);
			ITTDataCache.Instance.GetGeoLocationData(searchString, OnUpdateGeoLocation, OnFailGeoData);
			model.inputBox.value = null;
		}
コード例 #17
0
        public void LinkEveryController()
        {
            //obvious question - "why":
            //this is for mono ahead of time compilation. By referencing everything here,
            //we make sure these classes and generic variants are AOT compiled

            var load  = new LoadingScreen();
            var loadc = new LoadingScreenController(null, null, null);


            var screen = new PersonSelectionEdit();
            var t      = new TerrainController(null, null, null, null, null);
            var n      = new Network.Network(null, null, null, null);
            var v      = new Credits();
            var cd     = new Common.DataService.ClientDataService(null, null, null);
            var c      = new CoreGameScreen();
            var cc     = new CoreGameScreenController(null, null, null, null, null);
            var s      = new SandboxGameScreen();
            var ps     = new PersonSelection(null, null);
            var psc    = new PersonSelectionController(null, null, null, null);
            var cl1    = new Server.Clients.AuthClient("");
            var cl2    = new Server.Clients.CityClient("");
            var cl3    = new Server.Clients.ApiClient("");
            var ls     = new LoginScreen(null);
            var lc     = new LoginController(null, null);
            var lr     = new Regulators.LoginRegulator(null, null, null);

            var seled    = new PersonSelectionEditController(null, null);
            var casr     = new Regulators.CreateASimRegulator(null);
            var purch    = new Regulators.PurchaseLotRegulator(null);
            var conn     = new Regulators.LotConnectionRegulator(null, null, null);
            var t2       = new Regulators.CityConnectionRegulator(null, null, null, null, Kernel, null);
            var neigh    = new Regulators.GenericActionRegulator <NhoodRequest, NhoodResponse>(null);
            var bulletin = new Regulators.GenericActionRegulator <BulletinRequest, BulletinResponse>(null);
            var regu     = new Regulators.RegulatorsModule();

            var prov = new CacheProvider();
            var clip = new AuthClientProvider(null);
            var citp = new CityClientProvider(null);
            var ar   = new Server.Clients.AriesClient(null);
            var tso  = new cTSOSerializerProvider(null);
            var ser  = new Server.Protocol.Voltron.DataService.cTSOSerializer(null);
            var mods = new ModelSerializerProvider(null);
            var dbs  = new Common.DatabaseService.DatabaseService(null);
            var cds  = new Common.DataService.ClientDataService(null, null, null);

            var arp  = new Server.Protocol.Aries.AriesProtocolDecoder(null);
            var are  = new Server.Protocol.Aries.AriesProtocolEncoder(null);
            var serc = new Common.Serialization.SerializationContext(null, null);

            var ff   = new FieldFont();
            var fa   = new FieldAtlas();
            var fg   = new FieldGlyph();
            var kp   = new KerningPair();
            var met  = new Metrics();
            var dict = new Dictionary <char, FieldGlyph>();

            var packets = new object[]
            {
                new ClientOnlinePDU(),
                new HostOnlinePDU(),
                new SetIgnoreListPDU(),
                new SetIgnoreListResponsePDU(),
                new SetInvinciblePDU(),
                new RSGZWrapperPDU(),
                new TransmitCreateAvatarNotificationPDU(),
                new DataServiceWrapperPDU(),
                new DBRequestWrapperPDU(),
                new OccupantArrivedPDU(),
                new ClientByePDU(),
                new ServerByePDU(),
                new FindPlayerPDU(),
                new FindPlayerResponsePDU(),
                new ChatMsgPDU(),
                new AnnouncementMsgPDU(),

                new MessagingWindowController(null, null, null),
                new Controllers.Panels.SecureTradeController(null, null),
                new GizmoSearchController(null, null, null),
                new GizmoTop100Controller(null, null, null, null, null),
                new LotAdmitController(null, null, null),
                new GizmoController(null, null, null),
                new PersonPageController(null, null, null),
                new LotPageController(null, null),
                new BookmarksController(null, null, null),
                new RelationshipDialogController(null, null, null, null),
                new InboxController(null, null, null, null),
                new JoinLotProgressController(null, null),
                new DisconnectController(null, null, null, null, null),
                new GenericSearchController(null, null),
                new NeighPageController(null, null),
                new RatingListController(null, null, null),
                new RatingSummaryController(null, null, null),
                new NeighborhoodActionController(null),

                ImmutableList.Create <uint>(),
                ImmutableList.Create <JobLevel>(),
                ImmutableList.Create <Relationship>(),
                ImmutableList.Create <Bookmark>(),
                ImmutableList.Create <bool>(),

                new cTSOGenericData(),
            };
        }
コード例 #18
0
        /// <summary>
        /// Starts a singleplayer mission.
        /// </summary>
        /// <param name="scenario">The internal name of the scenario.</param>
        /// <param name="requiresAddon">True if the mission is for Firestorm / Enhanced Mode.</param>
        private void LaunchMission(Mission mission)
        {
            bool copyMapsToSpawnmapINI = ClientConfiguration.Instance.CopyMissionsToSpawnmapINI;

            Logger.Log("About to write spawn.ini.");
            StreamWriter swriter = new StreamWriter(MainClientConstants.gamepath + "spawn.ini");

            swriter.WriteLine("; Generated by DTA Client");
            swriter.WriteLine("[Settings]");
            if (copyMapsToSpawnmapINI)
            {
                swriter.WriteLine("Scenario=spawnmap.ini");
            }
            else
            {
                swriter.WriteLine("Scenario=" + mission.Scenario);
            }

            // No one wants to play missions on Fastest, so we'll change it to Faster
            if (UserINISettings.Instance.GameSpeed == 0)
            {
                UserINISettings.Instance.GameSpeed.Value = 1;
            }

            swriter.WriteLine("GameSpeed=" + UserINISettings.Instance.GameSpeed);
            swriter.WriteLine("Firestorm=" + mission.RequiredAddon);
            swriter.WriteLine("CustomLoadScreen=" + LoadingScreenController.GetLoadScreenName(mission.Side));
            swriter.WriteLine("IsSinglePlayer=Yes");
            swriter.WriteLine("SidebarHack=" + ClientConfiguration.Instance.SidebarHack);
            swriter.WriteLine("Side=" + mission.Side);
            swriter.WriteLine("BuildOffAlly=" + mission.BuildOffAlly);

            IniFile difficultyIni;

            UserINISettings.Instance.Difficulty.Value = trbDifficultySelector.Value;
            if (trbDifficultySelector.Value == 0) // Easy
            {
                swriter.WriteLine("DifficultyModeHuman=0");
                swriter.WriteLine("DifficultyModeComputer=2");
                difficultyIni = new IniFile(ProgramConstants.GamePath + "INI\\Map Code\\Difficulty Easy.ini");
            }
            else if (trbDifficultySelector.Value == 1) // Normal
            {
                swriter.WriteLine("DifficultyModeHuman=1");
                swriter.WriteLine("DifficultyModeComputer=1");
                difficultyIni = new IniFile(ProgramConstants.GamePath + "INI\\Map Code\\Difficulty Medium.ini");
            }
            else //if (tbDifficultyLevel.Value == 2) // Hard
            {
                swriter.WriteLine("DifficultyModeHuman=2");
                swriter.WriteLine("DifficultyModeComputer=0");
                difficultyIni = new IniFile(ProgramConstants.GamePath + "INI\\Map Code\\Difficulty Hard.ini");
            }
            swriter.WriteLine();
            swriter.WriteLine();
            swriter.WriteLine();
            swriter.Close();

            if (copyMapsToSpawnmapINI)
            {
                IniFile mapIni = new IniFile(ProgramConstants.GamePath + mission.Scenario);
                IniFile.ConsolidateIniFiles(mapIni, difficultyIni);
                mapIni.WriteIniFile(ProgramConstants.GamePath + "spawnmap.ini");
            }

            UserINISettings.Instance.Difficulty.Value = trbDifficultySelector.Value;
            UserINISettings.Instance.SaveSettings();

            Logger.Log("About to launch main executable.");

            ((MainMenuDarkeningPanel)Parent).Hide();
            GameProcessLogic.StartGameProcess(0);
        }
コード例 #19
0
        /// <summary>
        /// Writes the spawner settings file and map file for a specific mission.
        /// </summary>
        /// <param name="mission">The mission.</param>
        /// <param name="selectedDifficultyLevel">The difficulty level of the mission.</param>
        public void WriteFilesForMission(Mission mission, int selectedDifficultyLevel, Dictionary <int, bool> globalFlagInfo)
        {
            bool copyMapsToSpawnmapINI = ClientConfiguration.Instance.CopyMissionsToSpawnmapINI;

            Logger.Log("Writing spawner settings and map file for a singleplayer session.");
            File.Delete(ProgramConstants.GamePath + ProgramConstants.SPAWNER_SETTINGS);
            using (StreamWriter swriter = new StreamWriter(ProgramConstants.GamePath + ProgramConstants.SPAWNER_SETTINGS))
            {
                swriter.WriteLine("; Generated by DTA Client");
                swriter.WriteLine("[Settings]");
                if (copyMapsToSpawnmapINI)
                {
                    swriter.WriteLine("Scenario=spawnmap.ini");
                }
                else
                {
                    swriter.WriteLine("Scenario=" + mission.Scenario);
                }

                // No one wants to play on Fastest
                if (UserINISettings.Instance.GameSpeed == 0)
                {
                    UserINISettings.Instance.GameSpeed.Value = 1;
                }

                swriter.WriteLine("GameSpeed=" + UserINISettings.Instance.GameSpeed);
                swriter.WriteLine("Firestorm=" + mission.RequiredAddon);
                swriter.WriteLine("CustomLoadScreen=" + LoadingScreenController.GetLoadScreenName(mission.Side));
                swriter.WriteLine("IsSinglePlayer=Yes");
                swriter.WriteLine("SidebarHack=" + ClientConfiguration.Instance.SidebarHack);
                swriter.WriteLine("Side=" + mission.Side);
                swriter.WriteLine("BuildOffAlly=" + mission.BuildOffAlly);
                if (UserINISettings.Instance.EnableSPAutoSave)
                {
                    swriter.WriteLine("AutoSaveGame=" + ClientConfiguration.Instance.SinglePlayerAutoSaveInterval);
                }

                UserINISettings.Instance.Difficulty.Value = selectedDifficultyLevel;

                swriter.WriteLine("DifficultyModeHuman=" + (mission.PlayerAlwaysOnNormalDifficulty ? "1" : selectedDifficultyLevel.ToString()));
                swriter.WriteLine("DifficultyModeComputer=" + GetComputerDifficulty(selectedDifficultyLevel));

                swriter.WriteLine();
                swriter.WriteLine();
                swriter.WriteLine();
            }

            var spawnIni = new IniFile(ProgramConstants.GamePath + ProgramConstants.SPAWNER_SETTINGS);

            if (globalFlagInfo != null && globalFlagInfo.Count > 0)
            {
                var globalFlagsSection = new IniSection("GlobalFlags");
                spawnIni.AddSection(globalFlagsSection);

                foreach (var kvp in globalFlagInfo)
                {
                    globalFlagsSection.SetStringValue($"GlobalFlag{ kvp.Key.ToString(CultureInfo.InvariantCulture) }", kvp.Value ? "yes" : "no");
                }

                spawnIni.WriteIniFile();
            }

            IniFile difficultyIni = new IniFile(ProgramConstants.GamePath + DifficultyIniPaths[selectedDifficultyLevel]);

            if (copyMapsToSpawnmapINI)
            {
                IniFile mapIni = new IniFile(ProgramConstants.GamePath + mission.Scenario);
                IniFile.ConsolidateIniFiles(mapIni, difficultyIni);

                // Force values of EndOfGame and SkipScore as our progression tracking currently relies on them
                mapIni.SetBooleanValue("Basic", "EndOfGame", true);
                mapIni.SetBooleanValue("Basic", "SkipScore", false);
                mapIni.WriteIniFile(ProgramConstants.GamePath + "spawnmap.ini");
            }
        }
コード例 #20
0
        /// <summary>
        /// Starts a singleplayer mission.
        /// </summary>
        /// <param name="scenario">The internal name of the scenario.</param>
        /// <param name="requiresAddon">True if the mission is for Firestorm / Enhanced Mode.</param>
        private void LaunchMission(Mission mission)
        {
            bool copyMapsToSpawnmapINI = ClientConfiguration.Instance.CopyMissionsToSpawnmapINI;

            Logger.Log("About to write spawn.ini.");
            StreamWriter swriter = new StreamWriter(ProgramConstants.GamePath + "spawn.ini");

            swriter.WriteLine("; Generated by DTA Client");
            swriter.WriteLine("[Settings]");
            if (copyMapsToSpawnmapINI)
            {
                swriter.WriteLine("Scenario=spawnmap.ini");
            }
            else
            {
                swriter.WriteLine("Scenario=" + mission.Scenario);
            }

            // No one wants to play missions on Fastest, so we'll change it to Faster
            if (UserINISettings.Instance.GameSpeed == 0)
            {
                UserINISettings.Instance.GameSpeed.Value = 1;
            }

            swriter.WriteLine("GameSpeed=" + UserINISettings.Instance.GameSpeed);
            swriter.WriteLine("Firestorm=" + mission.RequiredAddon);
            swriter.WriteLine("CustomLoadScreen=" + LoadingScreenController.GetLoadScreenName(mission.Side.ToString()));
            swriter.WriteLine("IsSinglePlayer=Yes");
            swriter.WriteLine("SidebarHack=" + ClientConfiguration.Instance.SidebarHack);
            swriter.WriteLine("Side=" + mission.Side);
            swriter.WriteLine("BuildOffAlly=" + mission.BuildOffAlly);

            UserINISettings.Instance.Difficulty.Value = trbDifficultySelector.Value;

            swriter.WriteLine("DifficultyModeHuman=" + (mission.PlayerAlwaysOnNormalDifficulty ? "1" : trbDifficultySelector.Value.ToString()));
            swriter.WriteLine("DifficultyModeComputer=" + GetComputerDifficulty());

            IniFile difficultyIni  = new IniFile(ProgramConstants.GamePath + DifficultyIniPaths[trbDifficultySelector.Value]);
            string  difficultyName = DifficultyNames[trbDifficultySelector.Value];

            swriter.WriteLine();
            swriter.WriteLine();
            swriter.WriteLine();
            swriter.Close();

            if (copyMapsToSpawnmapINI)
            {
                IniFile mapIni = new IniFile(ProgramConstants.GamePath + mission.Scenario);
                IniFile.ConsolidateIniFiles(mapIni, difficultyIni);
                mapIni.WriteIniFile(ProgramConstants.GamePath + "spawnmap.ini");
            }

            UserINISettings.Instance.Difficulty.Value = trbDifficultySelector.Value;
            UserINISettings.Instance.SaveSettings();

            ((MainMenuDarkeningPanel)Parent).Hide();

            discordHandler?.UpdatePresence(mission.GUIName, difficultyName, mission.IconPath, true);
            GameProcessLogic.GameProcessExited += GameProcessExited_Callback;

            GameProcessLogic.StartGameProcess();
        }
コード例 #21
0
ファイル: InWorldStateEx.cs プロジェクト: yakoder/NRaas
        public override void Startup()
        {
            Common.StringBuilder msg = new Common.StringBuilder("InWorldStateEx:Startup");
            Traveler.InsanityWriteLog(msg);

            try
            {
                // StateMachineState:Startup()
                mBaseCallFlag |= BaseCallFlag.kStartup;
                //base.Startup();

                msg += Common.NewLine + "A";
                Traveler.InsanityWriteLog(msg);

                Sims3.Gameplay.UI.Responder.GameStartup();

                mEnteredFromTravelling = GameStates.IsTravelling;

                bool flag = false;

                try
                {
                    ModalDialog.EnableModalDialogs = false;

                    if (World.IsEditInGameFromWBMode())
                    {
                        Sims3.Gameplay.Autonomy.Autonomy.DisableMoodContributors = true;
                    }

                    msg += Common.NewLine + "B";
                    Traveler.InsanityWriteLog(msg);

                    mStateMachine    = StateMachine.Create(0x1, "InWorld");
                    mSubStates[0]    = new LiveModeStateEx(GameStates.IsMovingWorlds); // Custom
                    mSubStates[1]    = new BuildModeState();
                    mSubStates[2]    = new BuyModeState();
                    mSubStates[12]   = new ShoppingModeState();
                    mSubStates[3]    = new CASFullModeState();
                    mSubStates[4]    = new CASDresserModeState();
                    mSubStates[5]    = new CASMirrorModeState();
                    mSubStates[6]    = new CASTattooModeState();
                    mSubStates[7]    = new CASStylistModeState();
                    mSubStates[8]    = new CASTackModeState();
                    mSubStates[9]    = new CASCollarModeState();
                    mSubStates[10]   = new CASSurgeryFaceModeState();
                    mSubStates[11]   = new CASSurgeryBodyModeState();
                    mSubStates[15]   = new PlayFlowStateEx(); // Custom
                    mSubStates[14]   = new EditTownStateEx(); // Custom
                    mSubStates[16]   = new BlueprintModeState();
                    mSubStates[17]   = new CASMermaidModeState();
                    mSubStates[0x12] = new CABModeState();
                    mSubStates[0x13] = new CABModeEditState();

                    foreach (InWorldSubState state in mSubStates)
                    {
                        mStateMachine.AddState(state);
                    }

                    msg += Common.NewLine + "C";
                    Traveler.InsanityWriteLog(msg);

                    StateMachineManager.AddMachine(mStateMachine);
                    if (GameStates.IsTravelling || GameStates.IsEditingOtherTown)
                    {
                        try
                        {
                            Sims3.Gameplay.WorldBuilderUtil.CharacterImportOnGameLoad.RemapSimDescriptionIds();
                        }
                        catch (Exception e)
                        {
                            Common.DebugException("RemapSimDescriptionIds", e);
                        }
                    }
                    else
                    {
                        CrossWorldControl.sRetention.RestoreHouseholds();
                    }

                    msg += Common.NewLine + "D";
                    Traveler.InsanityWriteLog(msg);

                    if (GameStates.IsTravelling)
                    {
                        msg += Common.NewLine + "E1";
                        Traveler.InsanityWriteLog(msg);

                        bool fail = false;
                        if (!GameStatesEx.ImportTravellingHousehold())
                        {
                            msg += Common.NewLine + "E3";

                            fail = true;
                        }

                        if ((GameStates.TravelHousehold == null) && (GameStates.sTravelData.mState == GameStates.TravelData.TravelState.StartVacation))
                        {
                            msg += Common.NewLine + "E4";

                            fail = true;
                        }

                        if (fail)
                        {
                            msg += Common.NewLine + "E5";
                            Traveler.InsanityWriteLog(msg);

                            GameStates.sStartupState = SubState.EditTown;

                            GameStates.ClearTravelStatics();

                            WorldData.SetVacationWorld(true, true);
                        }
                    }
                    else if ((!GameStates.IsEditingOtherTown) && (GameStates.HasTravelData) && (GameStates.TravelHousehold == null))
                    {
                        switch (GameUtils.GetCurrentWorldType())
                        {
                        case WorldType.Base:
                        case WorldType.Downtown:
                            msg += Common.NewLine + "E2";
                            Traveler.InsanityWriteLog(msg);

                            GameStates.ClearTravelStatics();
                            break;
                        }
                    }

                    // Custom
                    if (GameStates.sMovingWorldData != null)
                    {
                        Household.IsTravelImport = true;
                    }

                    msg += Common.NewLine + "F1";
                    Traveler.InsanityWriteLog(msg);

                    List <Household> households = new List <Household>(Household.sHouseholdList);
                    foreach (Household a in households)
                    {
                        if ((a.LotHome != null) && (a.LotHome.Household == null))
                        {
                            a.LotHome.mHousehold = a;
                        }

                        foreach (SimDescription simA in Households.All(a))
                        {
                            // Must be validated prior to SimDescription:PostLoadFixup()
                            if (simA.GameObjectRelationships != null)
                            {
                                for (int index = simA.GameObjectRelationships.Count - 1; index >= 0; index--)
                                {
                                    if ((simA.GameObjectRelationships[index] == null) ||
                                        (simA.GameObjectRelationships[index].GameObjectDescription == null) ||
                                        (simA.GameObjectRelationships[index].GameObjectDescription.GameObject == null) ||
                                        (!Objects.IsValid(simA.GameObjectRelationships[index].GameObjectDescription.GameObject.ObjectId)))
                                    {
                                        simA.GameObjectRelationships.RemoveAt(index);
                                    }
                                }
                            }

                            foreach (Household b in households)
                            {
                                if (a == b)
                                {
                                    continue;
                                }

                                if (!b.Contains(simA))
                                {
                                    continue;
                                }

                                if (b.NumMembers == 1)
                                {
                                    continue;
                                }

                                try
                                {
                                    b.Remove(simA, false);

                                    msg += Common.NewLine + "Duplicate: " + simA.FullName;
                                }
                                catch (Exception e)
                                {
                                    Common.Exception(simA, e);
                                }
                            }
                        }
                    }

                    msg += Common.NewLine + "F2";
                    Traveler.InsanityWriteLog(msg);

                    // Required to ensure that all homeworld specific data is fixed up properly (specifically careers)
                    using (BaseWorldReversion reversion = new BaseWorldReversion())
                    {
                        // Reset this, to allow the Seasons Manager to activate properly
                        SeasonsManager.sSeasonsValidForWorld = SeasonsManager.Validity.Undetermined;

                        try
                        {
                            mPostWorldInitializers = new Initializers("PostWorldInitializers", this);

                            using (CareerStore store = new CareerStore())
                            {
                                //InitializersEx.Initialize(mPostWorldInitializers);
                                mPostWorldInitializers.Initialize();
                            }
                        }
                        catch (Exception e)
                        {
                            Traveler.InsanityException(msg, e);
                        }
                    }

                    msg += Common.NewLine + "G1";
                    Traveler.InsanityWriteLog(msg);

                    try
                    {
                        if (GameStates.TravelHousehold != null)
                        {
                            LinkToTravelHousehold();

                            WorldName worldName = GameUtils.GetCurrentWorld();

                            switch (worldName)
                            {
                            case WorldName.China:
                            case WorldName.Egypt:
                            case WorldName.France:
                                break;

                            default:
                                foreach (SimDescription sim in Households.All(GameStates.TravelHousehold))
                                {
                                    if (sim.VisaManager == null)
                                    {
                                        continue;
                                    }

                                    WorldData.OnLoadFixup(sim.VisaManager);

                                    sim.VisaManager.SetVisaLevel(worldName, 3);
                                }
                                break;
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Traveler.InsanityException(msg, e);
                    }

                    msg += Common.NewLine + "G2";
                    Traveler.InsanityWriteLog(msg);

                    List <SimDescription> dyingSims = null;
                    if (GameStates.IsTravelling)
                    {
                        dyingSims = GameStatesEx.PostTravelingFixUp();
                    }

                    msg += Common.NewLine + "H";
                    Traveler.InsanityWriteLog(msg);

                    if (GameStates.IsEditingOtherTown)
                    {
                        GameStates.PostLoadEditTownFixup();
                    }

                    msg += Common.NewLine + "I";
                    Traveler.InsanityWriteLog(msg);

                    // We must stop the travel actions from running if the homeworld is an EA vacation world
                    WorldData.SetVacationWorld(true, false);

                    GameStates.NullEditTownDataDataIfEditingOriginalStartingWorld();
                    try
                    {
                        if (GameUtils.IsAnyTravelBasedWorld())
                        {
                            if ((dyingSims != null) && (AgingManager.NumberAgingYearsElapsed != -1f))
                            {
                                float yearsGone = GameStates.NumberAgingYearsElapsed - AgingManager.NumberAgingYearsElapsed;

                                // Custom function
                                FixUpAfterTravel(yearsGone, dyingSims);
                            }
                            AgingManager.NumberAgingYearsElapsed = GameStates.NumberAgingYearsElapsed;
                        }
                    }
                    catch (Exception e)
                    {
                        Traveler.InsanityException(msg, e);
                    }

                    msg += Common.NewLine + "J";
                    Traveler.InsanityWriteLog(msg);

                    Sims3.Gameplay.Gameflow.GameSpeed pause = Sims3.Gameplay.Gameflow.GameSpeed.Pause;

                    if (GameStates.StartupState == SubState.LiveMode)
                    {
                        flag = !GameStates.IsEditingOtherTown && (((GameStates.ForceStateChange || !PlayFlowModel.Singleton.GameEntryLive) || (PlumbBob.SelectedActor != null)) || GameStates.IsTravelling);
                        if (flag)
                        {
                            if (Sims3.Gameplay.Gameflow.sGameLoadedFromWorldFile)
                            {
                                pause = Sims3.SimIFace.Gameflow.GameSpeed.Normal;
                            }
                            else
                            {
                                pause = Sims3.Gameplay.Gameflow.sPersistedGameSpeed;
                            }
                        }
                    }

                    msg += Common.NewLine + "K";
                    Traveler.InsanityWriteLog(msg);

                    Sims3.Gameplay.Gameflow.sGameLoadedFromWorldFile = false;
                    string s = CommandLine.FindSwitch("speed");
                    if (s != null)
                    {
                        int num2;
                        if (int.TryParse(s, out num2))
                        {
                            pause = (Sims3.Gameplay.Gameflow.GameSpeed)num2;
                        }
                        else
                        {
                            ParserFunctions.TryParseEnum <Sims3.Gameplay.Gameflow.GameSpeed>(s, out pause, Sims3.Gameplay.Gameflow.GameSpeed.Normal);
                        }
                    }

                    msg += Common.NewLine + "L";
                    Traveler.InsanityWriteLog(msg);

                    Sims3.Gameplay.Gameflow.SetGameSpeed(pause, Sims3.Gameplay.Gameflow.SetGameSpeedContext.GameStates);
                    NotificationManager.Load();
                    MainMenu.TriggerPendingFsiWorldNotifications();
                }
                finally
                {
                    ModalDialog.EnableModalDialogs = true;
                }

                if (SocialFeatures.Accounts.IsLoggedIn())
                {
                    Notify(0, 0, 0L);
                }

                switch (GameStates.StartupState)
                {
                case SubState.EditTown:
                    msg += Common.NewLine + "StartupState: EditTown";

                    GameUtils.EnableSceneDraw(true);
                    LoadingScreenController.Unload();
                    GotoEditTown();
                    break;

                case SubState.PlayFlow:
                    if (World.IsEditInGameFromWBMode())
                    {
                        msg += Common.NewLine + "StartupState: PlayFlow (A)";

                        GameUtils.EnableSceneDraw(true);
                        LoadingScreenController.Unload();
                        GotoLiveMode();
                    }
                    else if (!PlayFlowModel.PlayFlowEnabled || !PlayFlowModel.Singleton.GameEntryLive)
                    {
                        msg += Common.NewLine + "StartupState: PlayFlow (B)";

                        GameUtils.EnableSceneDraw(true);
                        LoadingScreenController.Unload();
                        GotoLiveMode();
                    }
                    else
                    {
                        msg += Common.NewLine + "StartupState: PlayFlow (C)";

                        GotoPlayFlow();
                    }
                    break;

                case SubState.LiveMode:
                    // Custom
                    if (((!GameUtils.IsOnVacation() && !GameUtils.IsFutureWorld()) || EditTownModel.IsAnyLotBaseCampStatic() || EditTownModelEx.IsAnyUnoccupiedLotStatic()) && flag)
                    {
                        bool directToGame = false;
                        if (!GameStates.IsTravelling)
                        {
                            // Entering an existing save
                            directToGame = true;
                        }
                        else if (EditTownModel.IsAnyLotBaseCampStatic())
                        {
                            // Normal transition to base camp
                            directToGame = true;
                        }
                        else if (!GameUtils.IsInstalled(ProductVersion.EP9))
                        {
                            // Use custom household selection
                            directToGame = true;
                        }

                        // Custom
                        if ((flag) && (directToGame))
                        {
                            msg += Common.NewLine + "StartupState: LiveMode (A)";

                            GotoLiveMode();
                            break;
                        }
                        else
                        {
                            msg += Common.NewLine + "StartupState: LiveMode (C)";

                            GameUtils.EnableSceneDraw(true);
                            LoadingScreenController.Unload();
                            GotoPlayFlow();
                            break;
                        }
                    }

                    msg += Common.NewLine + "StartupState: LiveMode (B)";

                    GameUtils.EnableSceneDraw(true);
                    LoadingScreenController.Unload();
                    GotoEditTown();
                    break;
                }

                msg += Common.NewLine + "M";
                Traveler.InsanityWriteLog(msg);

                if (Sims3.Gameplay.Gameflow.sShowObjectReplacedWarning)
                {
                    SimpleMessageDialog.Show(Common.LocalizeEAString("Ui/Warning/LoadGame:Warning"), Common.LocalizeEAString("Ui/Warning/LoadGame:ReplacedObjects"), ModalDialog.PauseMode.PauseSimulator);
                    Sims3.Gameplay.Gameflow.sShowObjectReplacedWarning = false;
                }
            }
            catch (Exception e)
            {
                Traveler.InsanityException(msg, e);
            }
            finally
            {
                //Common.WriteLog(msg);
            }
        }