Пример #1
0
        public override void Startup()
        {
            Common.StringBuilder msg = new Common.StringBuilder("ToInWorldStateEx:Startup");
            Traveler.InsanityWriteLog(msg);

            try
            {
                sStatusCount = 0;

                LoadSaveManager.ObjectGroupLoaded += OnObjectGroupLoaded;

                sOnWorldLoadFinishedEventHandler       = World.sOnWorldLoadFinishedEventHandler;
                World.sOnWorldLoadFinishedEventHandler = OnWorldLoadFinishedEx;

                World.sOnWorldLoadStatusEventHandler += OnWorldLoadStatusEx;

                base.Startup();

                msg += Common.NewLine + "FileName: " + GameStates.LoadFileName;
                Traveler.InsanityWriteLog(msg);
            }
            catch (Exception e)
            {
                Traveler.InsanityException(msg, e);
            }
        }
Пример #2
0
        public override void Shutdown()
        {
            Common.StringBuilder msg = new Common.StringBuilder("TravelArrivalStateEx:Shutdown");
            Traveler.InsanityWriteLog(msg);

            try
            {
                base.Shutdown();

                LoadSaveManager.ObjectGroupLoaded -= ToInWorldStateEx.OnObjectGroupLoaded;

                World.sOnWorldLoadStatusEventHandler -= ToInWorldStateEx.OnWorldLoadStatusEx;

                World.sOnWorldLoadFinishedEventHandler -= ToInWorldStateEx.OnWorldLoadFinishedEx;
                World.sOnWorldLoadFinishedEventHandler += ToInWorldStateEx.sOnWorldLoadFinishedEventHandler;

                msg += "A";
                msg += Common.NewLine + "StatusCount: " + ToInWorldStateEx.StatusCount;
                Traveler.InsanityWriteLog(msg);
            }
            catch (Exception e)
            {
                Traveler.InsanityException(msg, e);
            }
        }
Пример #3
0
        public override void Startup()
        {
            Common.StringBuilder msg = new Common.StringBuilder("PlayFlowStateEx:Startup" + Common.NewLine);
            Traveler.InsanityWriteLog(msg);

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

                ProductVersion prevVersions = EditTownModel.sEPVenuesPlaced;

                base.Startup();

                if (GameStates.HasTravelData)
                {
                    EditTownModel.sEPVenuesPlaced = prevVersions;
                }

                msg += Common.NewLine + "B";
                Traveler.InsanityWriteLog(msg);
            }
            catch (Exception e)
            {
                Traveler.InsanityException(msg, e);
            }
        }
Пример #4
0
        public override void SendToNextState()
        {
            Common.StringBuilder msg = new Common.StringBuilder("TravelDepartureStateEx:SendToNextState" + Common.NewLine);
            Traveler.InsanityWriteLog(msg);

            try
            {
                base.SendToNextState();

                msg += GameStates.sStartupState.ToString();
                Traveler.InsanityWriteLog(msg);
            }
            catch (Exception e)
            {
                Traveler.InsanityException(msg, e);
            }
        }
Пример #5
0
        public override void Startup()
        {
            Common.StringBuilder msg = new Common.StringBuilder("TravelDepartureStateEx:Startup" + Common.NewLine);
            Traveler.InsanityWriteLog(msg);

            try
            {
                base.Startup();

                msg += "A";
                Traveler.InsanityWriteLog(msg);
            }
            catch (Exception e)
            {
                Traveler.InsanityException(msg, e);
            }
        }
Пример #6
0
        public static void OnWorldLoadStatusEx(object sender, EventArgs args)
        {
            Common.StringBuilder msg = new Common.StringBuilder("ToInWorldState:OnWorldLoadStatusEx");

            try
            {
                sStatusCount++;
                msg += Common.NewLine + "Count: " + sStatusCount;
                msg += Common.NewLine + "Sender: " + sender;
                msg += Common.NewLine + "Args: " + args;
                Traveler.InsanityWriteLog(msg);
            }
            catch (Exception e)
            {
                Traveler.InsanityException(msg, e);
            }
        }
Пример #7
0
        public static void OnWorldLoadFinishedEx(object sender, EventArgs args)
        {
            Common.StringBuilder msg = new Common.StringBuilder("ToInWorldState:OnWorldLoadFinishedEx <Begin>");
            Traveler.InsanityWriteLog(msg);

            try
            {
                using (Common.TestSpan span = new Common.TestSpan(Common.ExternalTimeSpanLogger.sLogger, "OnWorldLoadFinishedEx", Common.DebugLevel.Low))
                {
                    msg += Common.NewLine + "Order";

                    foreach (Delegate del in sOnWorldLoadFinishedEventHandler.GetInvocationList())
                    {
                        msg += Common.NewLine + del.Method + " : " + del.Method.DeclaringType.AssemblyQualifiedName + " : " + del.Target;
                    }

                    msg += Common.NewLine + "Actual";

                    foreach (Delegate del in sOnWorldLoadFinishedEventHandler.GetInvocationList())
                    {
                        using (Common.TestSpan subSpan = new Common.TestSpan(Common.ExternalTimeSpanLogger.sLogger, "OnWorldLoadFinishedEx: " + del.Method + " : " + del.Method.DeclaringType.AssemblyQualifiedName, Common.DebugLevel.Low))
                        {
                            msg += Common.NewLine + del.Method + " : " + del.Method.DeclaringType.AssemblyQualifiedName + " : " + del.Target;
                            Traveler.InsanityWriteLog(msg);

                            try
                            {
                                del.DynamicInvoke(new object[] { sender, args });
                            }
                            catch (Exception e)
                            {
                                Traveler.InsanityException(msg, e);
                            }
                        }
                    }
                }

                msg += Common.NewLine + "ToInWorldState:OnWorldLoadFinishedEx <End>";
                Traveler.InsanityWriteLog(msg);
            }
            catch (Exception e)
            {
                Traveler.InsanityException(msg, e);
            }
        }
Пример #8
0
        public static void OnObjectGroupLoaded(IScriptObjectGroup group)
        {
            Common.StringBuilder msg = new Common.StringBuilder("ToInWorldState:OnObjectGroupLoaded");

            try
            {
                sStatusCount++;

                msg += Common.NewLine + "Count: " + sStatusCount;
                msg += Common.NewLine + "Group: " + group;

                IDictionary objects = group.AttachedObjects;
                if (objects != null)
                {
                    msg += Common.NewLine + "Count: " + objects.Count;

                    if (objects.Count > 0)
                    {
                        foreach (object obj in objects.Keys)
                        {
                            msg += Common.NewLine + "First Key: " + obj.GetType();
                            break;
                        }

                        foreach (object obj in objects.Values)
                        {
                            if (obj != null)
                            {
                                msg += Common.NewLine + "First Value: " + obj.GetType();
                            }
                            break;
                        }

                        Traveler.InsanityWriteLog(msg);
                    }
                }
            }
            catch (Exception e)
            {
                Traveler.InsanityException(msg, e);
            }
        }
Пример #9
0
        public static PlaceResults LocateHomeAndPlaceSimsAtVacationWorld(Household household, ref Sim simToSelect)
        {
            PlaceResults results = PlaceResults.Failure;

            Common.StringBuilder msg = new Common.StringBuilder("LocateHomeAndPlaceSimsAtVacationWorld" + Common.NewLine);

            try
            {
                if (household != null)
                {
                    msg += "A";

                    if (GameStates.DestinationTravelWorld == WorldName.University)
                    {
                        Dictionary <SimDescription, AcademicDegreeManager> managers = new Dictionary <SimDescription, AcademicDegreeManager>();

                        try
                        {
                            foreach (SimDescription sim in Households.All(household))
                            {
                                if (sim.CareerManager == null)
                                {
                                    continue;
                                }

                                managers[sim] = sim.CareerManager.DegreeManager;

                                if ((sim.ChildOrBelow) || (sim.IsPet))
                                {
                                    sim.CareerManager.mDegreeManager = null;
                                }
                                else if ((sim.CareerManager.DegreeManager != null) && (sim.CareerManager.DegreeManager.EnrollmentCouseLoad == 0))
                                {
                                    sim.CareerManager.mDegreeManager = null;
                                }
                            }

                            TravelUtil.MoveIntoUniversityHousehold(household);

                            foreach (SimDescription sim in Households.All(household))
                            {
                                CustomAcademicDegrees.AdjustCustomAcademics(sim);
                            }
                        }
                        finally
                        {
                            foreach (SimDescription sim in Households.All(household))
                            {
                                if (sim.CareerManager == null)
                                {
                                    continue;
                                }

                                AcademicDegreeManager manager;
                                if (!managers.TryGetValue(sim, out manager))
                                {
                                    continue;
                                }

                                sim.CareerManager.mDegreeManager = manager;
                            }
                        }

                        results = PlaceResults.BaseCamp;
                    }
                    else
                    {
                        TravelUtil.ProcessDeedsAndMoveInHousehold(household);

                        if (household.LotHome == null)
                        {
                            msg += "B";

                            bool manual = false;

                            Lot choice = PromptForLot();
                            if (choice == null)
                            {
                                choice = FindLot();
                            }
                            else
                            {
                                manual = true;
                            }

                            if (choice != null)
                            {
                                msg += "C";

                                msg += Common.NewLine + choice.Name + Common.NewLine;

                                choice.MoveIn(household);

                                Mailbox mailboxOnLot = Mailbox.GetMailboxOnLot(choice);
                                if (mailboxOnLot != null)
                                {
                                    mailboxOnLot.ListenToReturnFromWorld();
                                }

                                if (household.LotHome != null)
                                {
                                    msg += "D";

                                    if (manual)
                                    {
                                        results = PlaceResults.BaseCamp;
                                    }
                                    else
                                    {
                                        results = PlaceResults.Residential;
                                    }
                                }
                            }
                        }
                        else
                        {
                            msg += "E";

                            results = PlaceResults.BaseCamp;
                        }
                    }

                    if (household.LotHome != null)
                    {
                        msg += "F";

                        foreach (Service service in Services.AllServices)
                        {
                            if (service == null)
                            {
                                continue;
                            }

                            if (service.DefaultIsRequested())
                            {
                                continue;
                            }

                            service.MakeServiceRequest(household.LotHome, false, ObjectGuid.InvalidObjectGuid);
                        }

                        TravelUtil.TriggerTutorial(household);
                        TravelUtil.PlaceSimsOnSafeSpots(household, ref simToSelect);
                    }
                }
            }
            catch (Exception e)
            {
                Traveler.InsanityException(msg, e);
            }
            finally
            {
                Traveler.InsanityWriteLog(msg);
            }

            return(results);
        }
Пример #10
0
        public override void LoadUI()
        {
            Common.StringBuilder msg = new Common.StringBuilder("LiveModeStateEx:LoadUI" + Common.NewLine);

            try
            {
                bool reset = false;

                Sim selectedActor = PlumbBob.SelectedActor;
                if (selectedActor != null)
                {
                    msg += Common.NewLine + "SelectedActor: " + selectedActor.FullName;

                    // Elements used by HudModel:Initialize()
                    if (selectedActor.SkillManager == null)
                    {
                        reset = true;
                        msg  += Common.NewLine + "SkillManager: null";
                    }
                    else if (selectedActor.SocialComponent == null)
                    {
                        reset = true;
                        msg  += Common.NewLine + "SocialComponent: null";
                    }
                    else if (selectedActor.CareerManager == null)
                    {
                        reset = true;
                        msg  += Common.NewLine + "CareerManager: null";
                    }
                    else if (selectedActor.TraitManager == null)
                    {
                        reset = true;
                        msg  += Common.NewLine + "TraitManager: null";
                    }
                    else if (selectedActor.SimDescription == null)
                    {
                        reset = true;
                        msg  += Common.NewLine + "SimDescription: null";
                    }
                    else if (selectedActor.InteractionQueue == null)
                    {
                        reset = true;
                        msg  += Common.NewLine + "InteractionQueue: null";
                    }
                    else if (selectedActor.OccultManager == null)
                    {
                        reset = true;
                        msg  += Common.NewLine + "OccultManager: null";
                    }
                    else if (selectedActor.CelebrityManager == null)
                    {
                        reset = true;
                        msg  += Common.NewLine + "CelebrityManager: null";
                    }
                }
                else
                {
                    msg += Common.NewLine + "No SelectedActor";
                }

                if (reset)
                {
                    msg += Common.NewLine + "Perform Reset";

                    selectedActor = ResetSimTask.Perform(selectedActor, false);

                    if (selectedActor == null)
                    {
                        PlumbBob.DoSelectActor(null, true);
                    }
                    else
                    {
                        DreamCatcher.SelectNoLotCheckImmediate(selectedActor, false, true);
                    }
                }

                base.LoadUI();

                /*
                 * // From LiveModeState:LoadUI
                 * mMapTagController = new MapTagControllerEx();
                 * Simulator.AddObject(mMapTagController);
                 * HudController.Load();*/
            }
            catch (Exception e)
            {
                Traveler.InsanityException(msg, e);
            }
        }
Пример #11
0
        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();
            }
        }
Пример #12
0
        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);
            }
        }
Пример #13
0
        public static PlaceResults LocateHomeAndPlaceSimsAtVacationWorld(Household household, ref Sim simToSelect)
        {
            PlaceResults results = PlaceResults.Failure;

            Common.StringBuilder msg = new Common.StringBuilder("LocateHomeAndPlaceSimsAtVacationWorld" + Common.NewLine);

            try
            {
                if (household != null)
                {
                    msg += "A";

                    if (GameStates.DestinationTravelWorld == WorldName.University)
                    {
                        Dictionary <SimDescription, AcademicDegreeManager> managers = new Dictionary <SimDescription, AcademicDegreeManager>();

                        try
                        {
                            foreach (SimDescription sim in Households.All(household))
                            {
                                if (sim.CareerManager == null)
                                {
                                    continue;
                                }

                                managers[sim] = sim.CareerManager.DegreeManager;

                                if ((sim.ChildOrBelow) || (sim.IsPet))
                                {
                                    sim.CareerManager.mDegreeManager = null;
                                }
                                else if ((sim.CareerManager.DegreeManager != null) && (sim.CareerManager.DegreeManager.EnrollmentCouseLoad == 0))
                                {
                                    sim.CareerManager.mDegreeManager = null;
                                }
                            }

                            TravelUtil.MoveIntoUniversityHousehold(household);

                            foreach (SimDescription sim in Households.All(household))
                            {
                                CustomAcademicDegrees.AdjustCustomAcademics(sim);
                            }
                        }
                        finally
                        {
                            foreach (SimDescription sim in Households.All(household))
                            {
                                if (sim.CareerManager == null)
                                {
                                    continue;
                                }

                                AcademicDegreeManager manager;
                                if (!managers.TryGetValue(sim, out manager))
                                {
                                    continue;
                                }

                                sim.CareerManager.mDegreeManager = manager;
                            }
                        }

                        results = PlaceResults.BaseCamp;
                    }
                    else
                    {
                        TravelUtil.ProcessDeedsAndMoveInHousehold(household);

                        if (household.LotHome == null)
                        {
                            msg += "B";

                            bool manual = false;

                            Lot choice = PromptForLot();
                            if (choice == null)
                            {
                                choice = FindLot();
                            }
                            else
                            {
                                manual = true;
                            }

                            if (choice != null)
                            {
                                msg += "C";

                                msg += Common.NewLine + choice.Name + Common.NewLine;

                                choice.MoveIn(household);

                                Mailbox mailboxOnLot = Mailbox.GetMailboxOnLot(choice);
                                if (mailboxOnLot != null)
                                {
                                    mailboxOnLot.ListenToReturnFromWorld();
                                }

                                if (household.LotHome != null)
                                {
                                    msg += "D";

                                    if (manual)
                                    {
                                        results = PlaceResults.BaseCamp;
                                    }
                                    else
                                    {
                                        results = PlaceResults.Residential;
                                    }
                                }
                            }
                        }
                        else
                        {
                            msg += "E";

                            results = PlaceResults.BaseCamp;
                        }
                    }

                    if (household.LotHome != null)
                    {
                        msg += "F";

                        foreach (Service service in Services.AllServices)
                        {
                            if (service == null)
                            {
                                continue;
                            }

                            if (service.DefaultIsRequested())
                            {
                                continue;
                            }

                            service.MakeServiceRequest(household.LotHome, false, ObjectGuid.InvalidObjectGuid);
                        }

                        TravelUtil.TriggerTutorial(household);
                        TravelUtil.PlaceSimsOnSafeSpots(household, ref simToSelect);

                        // core block in pusharriveinteraction on ITimePortal preventing teens who travel alone from getting the arrive interaction thus
                        // appearing invisible
                        bool flag = true;
                        foreach (SimDescription desc in household.SimDescriptions)
                        {
                            if (desc.YoungAdultOrAbove)
                            {
                                flag = false;
                                break;
                            }
                        }

                        ITimePortal[] portalArray;
                        if (flag && ArriveHomeBehaviorInVacationWorld.ShouldArriveByTimePortal(household.LotHome, out portalArray))
                        {
                            new Common.AlarmTask(3f, TimeUnit.Minutes, PushArriveHomeInteractionEx);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Traveler.InsanityException(msg, e);
            }
            finally
            {
                Traveler.InsanityWriteLog(msg);
            }

            return(results);
        }