示例#1
0
文件: AnnexEx.cs 项目: yakoder/NRaas
            protected override void OnPerform()
            {
                Common.DebugNotify("StartGraduationCeremonyTask:OnPerform");

                if (mThs.IsAGraduationCeremonyInProgressAndIfNecessaryStartOne())
                {
                    foreach (SimDescription sim in new List <SimDescription>(mThs.mGraduatingSims.Keys))
                    {
                        try
                        {
                            Instantiation.PerformOffLot(sim, mThs.RabbitHoleProxy.LotCurrent, null);

                            if ((sim.CreatedSim != null) && (sim.CreatedSim.InteractionQueue != null))
                            {
                                sim.CreatedSim.ShowTNSIfSelectable(TNSNames.CollegeGraduationStarting, null, sim.CreatedSim, new object[] { sim.CreatedSim });
                                Annex.UniversityGraduationCeremony entry = Annex.UniversityGraduationCeremony.Singleton.CreateInstance(mThs, sim.CreatedSim, new InteractionPriority(InteractionPriorityLevel.High), false, true) as Annex.UniversityGraduationCeremony;
                                sim.CreatedSim.InteractionQueue.AddNext(entry);
                                ActiveTopic.RemoveTopicFromSim(sim.CreatedSim, "University Graduation");
                            }
                        }
                        catch (Exception e)
                        {
                            Common.Exception(sim, e);
                        }
                    }

                    Dictionary <ulong, SimDescription> loadedSims = SimListing.GetResidents(false);

                    foreach (MiniSimDescription sim in new List <MiniSimDescription>(mThs.mForeignVisitors))
                    {
                        try
                        {
                            // Custom
                            //   EA Standard attempts to reimport existing sims without checking
                            SimDescription local;
                            if (loadedSims.TryGetValue(sim.SimDescriptionId, out local))
                            {
                                if (!mThs.mLocalVisitors.Contains(local))
                                {
                                    mThs.mLocalVisitors.Add(local);
                                }
                            }
                            else
                            {
                                SimDescription simDescription = MiniSims.UnpackSimAndUpdateRel(sim);
                                if (simDescription != null)
                                {
                                    Household.CreateTouristHousehold();
                                    Household.TouristHousehold.AddTemporary(simDescription);
                                    sim.Instantiated = true;
                                    (Responder.Instance.HudModel as Sims3.Gameplay.UI.HudModel).OnSimCurrentWorldChanged(true, sim);

                                    if (simDescription.AgingState != null)
                                    {
                                        simDescription.AgingState.MergeTravelInformation(sim);
                                    }

                                    mThs.mLocalVisitors.Add(simDescription);
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            Common.Exception(sim, e);
                        }
                    }

                    Dictionary <SimDescription, bool> performed = new Dictionary <SimDescription, bool>();

                    foreach (SimDescription sim in new List <SimDescription>(mThs.mLocalVisitors))
                    {
                        try
                        {
                            if (mThs.mGraduatingSims.ContainsKey(sim))
                            {
                                continue;
                            }

                            if (performed.ContainsKey(sim))
                            {
                                continue;
                            }
                            performed[sim] = true;

                            Instantiation.PerformOffLot(sim, mThs.RabbitHoleProxy.LotCurrent, null);

                            if ((sim.CreatedSim != null) && (sim.CreatedSim.InteractionQueue != null))
                            {
                                InteractionInstance instance = Annex.AttendGraduationCeremony.Singleton.CreateInstance(mThs, sim.CreatedSim, new InteractionPriority(InteractionPriorityLevel.High), true, true);
                                sim.CreatedSim.InteractionQueue.AddNext(instance);
                            }
                        }
                        catch (Exception e)
                        {
                            Common.Exception(sim, e);
                        }
                    }
                }
            }