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); } } } }
public static void CleanupAcademics(Logger log) { Dictionary <ulong, SimDescription> sims = SimListing.GetResidents(false); foreach (SimDescription sim in sims.Values) { if (sim.CareerManager == null) { continue; } AcademicCareer career = sim.OccupationAsAcademicCareer; if (career != null) { if ((career.mDegree == null) || (AcademicDegreeManager.GetStaticElement(career.mDegree.AcademicDegreeName) == null)) { career.LeaveJobNow(Career.LeaveJobReason.kJobBecameInvalid); } } AcademicDegreeManager manager = sim.CareerManager.DegreeManager; if (manager == null) { continue; } List <AcademicDegreeNames> remove = new List <AcademicDegreeNames>(); foreach (AcademicDegree degree in manager.List) { if (AcademicDegreeManager.GetStaticElement(degree.AcademicDegreeName) == null) { remove.Add(degree.AcademicDegreeName); } } foreach (AcademicDegreeNames degree in remove) { manager.RemoveElement((ulong)degree); if (log != null) { log("Remove Corrupt Degree: " + sim.FullName); } } } if (AcademicCareer.sAcademicSims != null) { for (int i = AcademicCareer.sAcademicSims.Count - 1; i >= 0; i--) { bool remove = false; SimDescription sim; if (!sims.TryGetValue(AcademicCareer.sAcademicSims[i], out sim)) { remove = true; } else { AcademicCareer career = sim.OccupationAsAcademicCareer; if (career == null) { remove = true; } else if (career.mDegree == null) { remove = true; } else if (career.Coworkers == null) { remove = true; } } if (remove) { if (log != null) { if (sim != null) { log(" Removed: " + sim.FullName); } else { log(" Removed: " + AcademicCareer.sAcademicSims[i]); } } AcademicCareer.sAcademicSims.RemoveAt(i); } } } }