private static void UpdateInWorldRelationships(MiniSimDescription ths, SimDescription myDesc) { foreach (MiniRelationship relationship in ths.mMiniRelationships) { MiniSimDescription description = Find(relationship.SimDescriptionId); if ((description != null) && description.Instantiated) { SimDescription y = SimDescription.Find(relationship.SimDescriptionId); if (y == null) { description.Instantiated = false; } else { Relationship unsafely; MiniRelationship mrB = description.FindMiniRelationship(ths, false); // Custom if (mrB != null) { if (GameStates.IsTravelling) { unsafely = Relationship.GetUnsafely(myDesc, y); } else { unsafely = Relationship.Get(myDesc, y, true); } unsafely.UpdateFromMiniRelationship(relationship, mrB); } } } } }
protected void CleanupMiniSims(Dictionary <ulong, IMiniSimDescription> existingSims) { if (MiniSimDescription.sMiniSims == null) { return; } List <MiniSimDescription> miniSims = new List <MiniSimDescription>(MiniSimDescription.sMiniSims.Values); foreach (MiniSimDescription miniSim in miniSims) { try { if (miniSim == null) { continue; } if (miniSim.mTraits == null) { // Correction for a reported script error miniSim.mTraits = new List <TraitNames>(); } IMiniSimDescription existingSim = null; string reason = null; if (!existingSims.TryGetValue(miniSim.SimDescriptionId, out existingSim)) { reason = "No Exist Mini Sim Removed: " + Relationships.GetFullName(miniSim); } else { miniSim.mFirstName = existingSim.FirstName; miniSim.mLastName = existingSim.LastName; string name = miniSim.FullName; if ((name == null) || (string.IsNullOrEmpty(name.Trim()))) { reason = "No Name Mini Sim Removed: " + Relationships.GetFullName(miniSim); } else if (existingSim is MiniSimDescription) { bool found = false; if (miniSim.mHomeLotId != 0) { //Overwatch.Log(" " + Relationships.GetFullName(miniSim) + " HomeLotId Save"); found = true; } else if (!string.IsNullOrEmpty(miniSim.JobOrServiceName)) { //Overwatch.Log(" " + Relationships.GetFullName(miniSim) + " JobOrServiceName Save"); found = true; } else if ((miniSim.MiniRelationships != null) && (miniSim.mMiniRelationships.Count > 0)) { //Overwatch.Log(" " + Relationships.GetFullName(miniSim) + " Relation Save"); found = true; } else if (miniSim.Genealogy != null) { if ((miniSim.Genealogy.Spouse != null) || (miniSim.Genealogy.Children.Count > 0) || (miniSim.Genealogy.Parents.Count > 0) || (miniSim.Genealogy.Siblings.Count > 0)) { //Overwatch.Log(" " + Relationships.GetFullName(miniSim) + " Genealogy Save"); found = true; } } if (!found) { reason = "No Relation Mini Sim Removed: " + Relationships.GetFullName(miniSim); } } if (!string.IsNullOrEmpty(reason)) { try { Annihilation.RemoveMSD(miniSim.SimDescriptionId); Overwatch.Log(reason); continue; } catch (Exception e) { Common.DebugException(miniSim.FullName, e); } } } } catch (Exception e) { Common.Exception(miniSim.FullName, e); } } if (!GameStates.IsOnVacation) { foreach (MiniSimDescription sim in MiniSimDescription.GetVacationWorldSimDescriptions()) { try { List <MiniRelationship> relations = new List <MiniRelationship>(sim.MiniRelationships); foreach (MiniRelationship relation in relations) { MiniSimDescription other = MiniSimDescription.Find(relation.SimDescriptionId); if (other == null) { continue; } MiniRelationship otherRelation = other.FindMiniRelationship(sim, false); if (otherRelation == null) { Overwatch.Log("Bad MiniRelationship Dropped " + Relationships.GetFullName(sim)); sim.mMiniRelationships.Remove(relation); } } } catch (Exception e) { Common.Exception(sim, e); } } } }