public static SimDescription UnpackSim(MiniSimDescription ths, bool updateGenealogy) { try { if (ths == null) { return(null); } // Calling ImportSimDescription prior to the Aging Manager being available is invalid, don't allow it if (AgingManager.Singleton == null) { return(null); } SimDescription desc = new SimDescription(); ResourceKeyContentCategory installed = ResourceKeyContentCategory.kInstalled; DownloadContent.ImportSimDescription(ths.mTravelKey, desc, ref installed); desc.SimDescriptionId = ths.mSimDescriptionId; if (desc.CareerManager != null) { // Fixup for careers require a household, which is not set until later in this process desc.CareerManager.mJob = null; desc.CareerManager.mSchool = null; } desc.Fixup(); if (updateGenealogy && !GameStates.IsTravelling) { if (desc.DefaultOutfitKey == ResourceKey.kInvalidResourceKey) { SimOutfit outfit = desc.GetOutfit(OutfitCategories.Everyday, 0x0); if ((outfit == null) || (!outfit.IsValid)) { desc.Dispose(false, false); return(null); } desc.UpdateFromOutfit(OutfitCategories.Everyday); } desc.CASGenealogy = ths.CASGenealogy; } Corrections.CleanupBrokenSkills(desc, null); OccultTypeHelper.ValidateOccult(desc, null); return(desc); } catch (Exception e) { Common.Exception(ths.FullName, e); return(null); } }
public static bool EnsureInstantiate(SimDescription sim, Lot lot) { if (sim.CreatedSim == null) { if (sim.Household == null) { if (!sim.IsValidDescription) { sim.Fixup(); } Urnstone urnstone = Urnstones.CreateGrave(sim, SimDescription.DeathType.OldAge, false, true); if (urnstone != null) { Common.Sleep(); if (!Urnstones.GhostSpawn(urnstone, lot)) { return(false); } } } else { Instantiation.Perform(sim, null); } } return(sim.CreatedSim != null); }
public static bool EnsureInstantiate(SimDescription sim, Lot lot) { if (sim.CreatedSim == null) { if (sim.Household == null) { if (!sim.IsValidDescription) { sim.Fixup(); } Urnstone urnstone = Urnstones.CreateGrave(sim, SimDescription.DeathType.OldAge, false, true); if (urnstone != null) { Common.Sleep(); if (!Urnstones.GhostSpawn(urnstone, lot)) { return false; } } } else { Instantiation.Perform(sim, null); } } return (sim.CreatedSim != null); }
protected override void PrivatePerformAction(bool prompt) { try { Overwatch.Log("Recover Missing Sims"); string msg = null; List <Sim> sims = new List <Sim>(LotManager.Actors); foreach (Sim sim in sims) { SimDescription simDesc = sim.SimDescription; if (simDesc == null) { continue; } if ((!sim.SimDescription.IsValidDescription) || (sim.Household == null)) { try { GreyedOutTooltipCallback callback = null; if (RecoverMissingSimTask.Allowed(sim.SimDescription, false, ref callback)) { simDesc.Fixup(); if (Instantiation.AttemptToPutInSafeLocation(sim, true)) { sim.Autonomy.Motives.RecreateMotives(sim); sim.SetObjectToReset(); } msg += Common.NewLine + simDesc.FullName; } } catch (Exception e) { Common.Exception(simDesc, e); } } } List <Household> houses = new List <Household>(Household.sHouseholdList); foreach (Household house in houses) { msg += Perform(house, prompt); } if ((msg != null) && (msg != "")) { Overwatch.AlarmNotify(Common.Localize("RecoverMissingSims:Success", false, new object[] { msg })); } } catch (Exception exception) { Common.Exception(Name, exception); } }
protected static bool Fixup(SimDescription me) { if (me == null) { return(true); } if (!me.IsValidDescription) { me.Fixup(); } return(me.Genealogy != null); }
public static SimDescription CreateProgenitor(ulong id, out bool unpacked) { unpacked = false; if (id == 0) { return(null); } if (FutureDescendantServiceEx.UnpackedSims.ContainsKey(id)) { return(FutureDescendantServiceEx.UnpackedSims[id]); } SimDescription sim = SimDescription.Find(id); if (sim == null) { MiniSimDescription msd = MiniSimDescription.Find(id); if (msd == null) { return(null); } // Custom sim = MiniSims.UnpackSimAndUpdateRel(msd); if (sim == null) { return(null); } Household.CreateTouristHousehold(); Household.TouristHousehold.AddTemporary(sim); msd.Instantiated = true; if (sim.AgingState != null) { sim.AgingState.MergeTravelInformation(msd); } FutureDescendantServiceEx.UnpackedSims.Add(id, sim); SpeedTrap.Sleep(); unpacked = true; } sim.Fixup(); return(sim); }
protected static bool Fixup(SimDescription me) { if (me == null) return true; if (!me.IsValidDescription) { me.Fixup(); } return (me.Genealogy != null); }
public static Sim Perform(Sim sim, bool fadeOut) { if (sim == null) { return(null); } try { SimDescription simDesc = sim.SimDescription; if (Simulator.GetProxy(sim.ObjectId) == null) { if (simDesc != null) { sim.Destroy(); } //sim.mSimDescription = null; return(null); } if (simDesc == null) { sim.mSimDescription = new SimDescription(); sim.Destroy(); return(null); } if (sim.LotHome != null) { simDesc.IsZombie = false; if (simDesc.CreatedSim != sim) { sim.Destroy(); simDesc.CreatedSim = null; return(null); } else { Bed myBed = null; BedData myBedData = null; foreach (Bed bed in sim.LotHome.GetObjects <Bed>()) { myBedData = bed.GetPartOwnedBy(sim); if (myBedData != null) { myBed = bed; break; } } ResetPosture(sim); if (simDesc.TraitManager == null) { simDesc.mTraitManager = new TraitManager(); } try { simDesc.Fixup(); Corrections.CleanupBrokenSkills(simDesc, null); ResetCareer(simDesc); simDesc.ClearSpecialFlags(); if (simDesc.Pregnancy == null) { try { if (simDesc.mMaternityOutfits == null) { simDesc.mMaternityOutfits = new OutfitCategoryMap(); } simDesc.SetPregnancy(0, false); simDesc.ClearMaternityOutfits(); } catch (Exception e) { Common.Exception(sim, null, "Pregnancy", e); } } if (sim.CurrentCommodityInteractionMap == null) { try { LotManager.PlaceObjectOnLot(sim, sim.ObjectId); if (sim.CurrentCommodityInteractionMap == null) { sim.ChangeCommodityInteractionMap(sim.LotHome.Map); } } catch (Exception e) { Common.Exception(sim, null, "ChangeCommodityInteractionMap", e); } } } catch (Exception e) { Common.Exception(sim, null, "Fixup", e); } ResetSituations(sim); CleanupSlots(sim); ResetInventory(sim); if (fadeOut) { bool active = (Sim.ActiveActor == sim); if (sSimReset.Valid) { sSimReset.Invoke <bool>(new object[] { simDesc.SimDescriptionId }); } ResetRouting(sim); using (CreationProtection protection = new CreationProtection(simDesc, sim, false, true, false)) { sim.Destroy(); Common.Sleep(); sim = FixInvisibleTask.InstantiateAtHome(simDesc, null); } if (sim != null) { if (active) { try { foreach (Sim member in Households.AllSims(sim.Household)) { if (member.CareerManager == null) { continue; } Occupation occupation = member.CareerManager.Occupation; if (occupation == null) { continue; } occupation.FormerBoss = null; } using (DreamCatcher.HouseholdStore store = new DreamCatcher.HouseholdStore(sim.Household, true)) { PlumbBob.DoSelectActor(sim, true); } } catch (Exception e) { Common.Exception(sim, null, "DoSelectActor", e); } } if ((myBed != null) && (myBedData != null)) { if (!(myBed is BedMultiPart) || (myBed is BedMultiPart && ((sim.Partner != null) && (sim.Partner.CreatedSim != null)))) { myBed.ClaimOwnership(sim, myBedData); } else { HandleDoubleBed(sim, myBed, myBedData); } } } } else { if (sim.Inventory == null) { sim.AddComponent <InventoryComponent>(new object[0x0]); } if (Instantiation.AttemptToPutInSafeLocation(sim, false)) { ResetRouting(sim); sim.SetObjectToReset(); // This is necessary to clear certain types of interactions // (it is also called in SetObjectToReset(), though doesn't always work there) if (sim.InteractionQueue != null) { sim.InteractionQueue.OnReset(); } } } ResetSkillModifiers(simDesc); ResetRole(sim); if (simDesc.IsEnrolledInBoardingSchool()) { simDesc.BoardingSchool.OnRemovedFromSchool(); } MiniSimDescription miniSim = MiniSimDescription.Find(simDesc.SimDescriptionId); if (miniSim != null) { miniSim.Instantiated = true; } UpdateInterface(sim); return(sim); } } else if (simDesc.Service is Butler) { if (Instantiation.AttemptToPutInSafeLocation(sim, true)) { sim.Motives.RecreateMotives(sim); sim.SetObjectToReset(); } return(sim); } else if (simDesc.IsImaginaryFriend) { OccultImaginaryFriend friend; if (OccultImaginaryFriend.TryGetOccultFromSim(sim, out friend)) { if (Simulator.GetProxy(friend.mDollId) != null) { friend.TurnBackIntoDoll(OccultImaginaryFriend.Destination.Owner); return(null); } } } else if (simDesc.IsBonehilda) { foreach (BonehildaCoffin coffin in Sims3.Gameplay.Queries.GetObjects <BonehildaCoffin>()) { if (coffin.mBonehilda == simDesc) { coffin.mBonehildaSim = null; break; } } } if (fadeOut) { sim.Destroy(); } return(null); } catch (Exception exception) { Common.Exception(sim, exception); return(sim); } }
// Lacks the "greater than eight" restriction public static bool GhostToPlayableGhost(Urnstone ths, Household newHousehold, Vector3 ghostPosition) { SimDescription simDescription = ths.DeadSimsDescription; if (!simDescription.IsValidDescription) { simDescription.Fixup(); } if (simDescription.Household != null) { simDescription.Household.Remove(simDescription, !simDescription.Household.IsSpecialHousehold); } if (!newHousehold.Contains(simDescription)) { newHousehold.Add(simDescription); } Sim ghost = Instantiation.Perform(simDescription, ghostPosition, null, null); if (ghost == null) { return(false); } ths.GhostSetup(ghost, true); ths.RemoveMourningRelatedBuffs(ghost); simDescription.ShowSocialsOnSim = true; simDescription.IsNeverSelectable = false; simDescription.Marryable = true; simDescription.Contactable = true; if (!simDescription.IsEP11Bot) { simDescription.AgingEnabled = true; simDescription.AgingState.ResetAndExtendAgingStage(0f); simDescription.PushAgingEnabledToAgingManager(); } string failureReason; if (!Inventories.TryToMove(ths, ghost.Inventory, true, out failureReason)) { Common.DebugNotify(failureReason); } //Inventories.TryToMove(ths, ghost); if (simDescription.Child || simDescription.Teen) { simDescription.AssignSchool(); } if (ghost.IsSelectable) { ghost.OnBecameSelectable(); } return(true); }
protected static Urnstone PrivateCreateGrave(SimDescription corpse) { string style; ProductVersion version = ProductVersion.BaseGame; switch (corpse.Species) { case CASAgeGenderFlags.Dog: case CASAgeGenderFlags.LittleDog: style = "tombstoneDog"; version = ProductVersion.EP5; break; case CASAgeGenderFlags.Horse: if (corpse.IsUnicorn) { style = "tombstoneUnicorn"; } else { style = "tombstoneHorse"; } version = ProductVersion.EP5; break; case CASAgeGenderFlags.Cat: style = "tombstoneCat"; version = ProductVersion.EP5; break; default: ulong lifetimeHappiness = corpse.LifetimeHappiness; if (lifetimeHappiness >= Urnstone.LifetimeHappinessWealthyTombstone) { style = "UrnstoneHumanWealthy"; } else if (lifetimeHappiness < Urnstone.LifetimeHappinessPoorTombstone) { style = "UrnstoneHumanPoor"; } else { style = "UrnstoneHuman"; } break; } Urnstone stone = GlobalFunctions.CreateObject(style, version, Vector3.OutOfWorld, 0, Vector3.UnitZ, null, null) as Urnstone; if (stone == null) { return(null); } corpse.Fixup(); stone.SetDeadSimDescription(corpse); stone.mPlayerMoveable = true; return(stone); }
protected static bool BumpUp(SimDescription a, SimDescription b, bool prompt, bool romantic) { Relationship relation = Relationship.Get(a, b, true); if (relation == null) { return(false); } LongTermRelationshipTypes currentState = relation.LTR.CurrentLTR; LongTermRelationshipTypes nextState = LongTermRelationshipTypes.Undefined; if (romantic) { nextState = NextPositiveRomanceState(currentState); } else { nextState = NextPositiveFriendState(currentState); } if (nextState == LongTermRelationshipTypes.Undefined) { if (prompt) { SimpleMessageDialog.Show(Common.Localize("Romance:BumpUpTitle"), Common.Localize("Romance:TooHigh")); } return(false); } /* * if (relation.LTR.RelationshipIsInappropriate(LTRData.Get(nextState))) * { * if (prompt) * { * SimpleMessageDialog.Show(Common.Localize("Romance:BumpUpTitle"), Common.Localize ("Romance:Improper", new object[] { Common.LocalizeStatus (a, b, nextState) })); * } * return false; * } */ if ((romantic) && (a.Genealogy.IsBloodRelated(b.Genealogy))) { if ((prompt) && (!AcceptCancelDialog.Show(Common.Localize("Romance:BloodPrompt", a.IsFemale, new object [] { a, b })))) { return(false); } } if ((currentState == LongTermRelationshipTypes.RomanticInterest) && (romantic)) { if ((a.Partner != null) && (a.Partner != b)) { if ((b.Partner != null) && (b.Partner != a)) { if ((prompt) && (!AcceptCancelDialog.Show(Common.Localize("Romance:DualPartnerPrompt", a.IsFemale, new object[] { a, b })))) { return(false); } } else { if ((prompt) && (!AcceptCancelDialog.Show(Common.Localize("Romance:PartnerPrompt", a.IsFemale, new object[] { a })))) { return(false); } } } else if ((b.Partner != null) && (b.Partner != a)) { if ((prompt) && (!AcceptCancelDialog.Show(Common.Localize("Romance:PartnerPrompt", b.IsFemale, new object[] { b })))) { return(false); } } if (a.Partner != null) { BumpDown(a, a.Partner, false, true); } if (b.Partner != null) { BumpDown(b, b.Partner, false, true); } if (a.TraitManager == null) { a.Fixup(); } if (b.TraitManager == null) { b.Fixup(); } Relationships.SetPartner(a, b); } ForceChangeState(relation, nextState); if (relation.LTR.CurrentLTR == LongTermRelationshipTypes.BestFriendsForever) { bool isPetBFF = ((!a.IsHuman) || (!b.IsHuman)); a.HasBFF = true; b.HasBFF = true; FindAndRemoveBFF(a, b, isPetBFF); FindAndRemoveBFF(b, a, isPetBFF); } if (currentState == relation.LTR.CurrentLTR) { return(false); } StyledNotification.Format format = new StyledNotification.Format(Common.Localize("Romance:Success", a.IsFemale, new object[] { a, b, LocalizeStatus(a, b, relation.LTR.CurrentLTR) }), StyledNotification.NotificationStyle.kGameMessagePositive); format.mTNSCategory = NotificationManager.TNSCategory.Lessons; StyledNotification.Show(format); return(true); }
protected override bool Run(SimDescription a, SimDescription b) { if (b == a) { return(Run(a, (SimDescription)null)); } else if (a == null) { if (b == null) { return(true); } return(Run(b, a)); } Sim womanSim = a.CreatedSim; Sim manSim = null; if (b != null) { manSim = b.CreatedSim; } if (!ApplyAll) { string text = StringInputDialog.Show(Name, Common.Localize(GetTitlePrefix() + ":Prompt"), "1"); if ((text == null) || (text == "")) { return(false); } mNumChildren = 1; if (!int.TryParse(text, out mNumChildren)) { SimpleMessageDialog.Show(Name, Common.Localize("Numeric:Error")); return(false); } mGender = NRaas.MasterControllerSpace.Helpers.Baby.SelectGender(); if (mGender == CASAgeGenderFlags.None) { return(false); } } int numChildren = mNumChildren; if (!NRaas.MasterController.Settings.mAllowOverStuffed) { int maxChildren = 0; if (womanSim.IsHuman) { maxChildren = 8 - CommonSpace.Helpers.Households.NumHumansIncludingPregnancy(a.Household); } else { maxChildren = 6 - CommonSpace.Helpers.Households.NumPetsIncludingPregnancy(a.Household); } if (numChildren > maxChildren) { numChildren = maxChildren; } } if (numChildren <= 0) { SimpleMessageDialog.Show(Name, Common.Localize("InstaBaby:Failure", a.IsFemale, new object[] { a })); } if (a.CelebrityManager == null) { a.Fixup(); } if (b.CelebrityManager == null) { b.Fixup(); } List <Sim> babies = null; if (a.IsHuman) { babies = GenerateHumanChildren(a, b, numChildren); } else { babies = GeneratePetChildren(a, b, numChildren); } if (!ApplyAll) { SimpleMessageDialog.Show(Name, Common.Localize("InstaBaby:Success", a.IsFemale, new object[] { a, numChildren })); } else { Common.Notify(Common.Localize("InstaBaby:Success", a.IsFemale, new object[] { a, numChildren })); } return(true); }
protected static Urnstone PrivateCreateGrave(SimDescription corpse) { string style; ProductVersion version = ProductVersion.BaseGame; switch (corpse.Species) { case CASAgeGenderFlags.Dog: case CASAgeGenderFlags.LittleDog: style = "tombstoneDog"; version = ProductVersion.EP5; break; case CASAgeGenderFlags.Horse: if (corpse.IsUnicorn) { style = "tombstoneUnicorn"; } else { style = "tombstoneHorse"; } version = ProductVersion.EP5; break; case CASAgeGenderFlags.Cat: style = "tombstoneCat"; version = ProductVersion.EP5; break; default: ulong lifetimeHappiness = corpse.LifetimeHappiness; if (lifetimeHappiness >= Urnstone.LifetimeHappinessWealthyTombstone) { style = "UrnstoneHumanWealthy"; } else if (lifetimeHappiness < Urnstone.LifetimeHappinessPoorTombstone) { style = "UrnstoneHumanPoor"; } else { style = "UrnstoneHuman"; } break; } Urnstone stone = GlobalFunctions.CreateObject(style, version, Vector3.OutOfWorld, 0, Vector3.UnitZ, null, null) as Urnstone; if (stone == null) { return null; } corpse.Fixup(); stone.SetDeadSimDescription(corpse); stone.mPlayerMoveable = true; return stone; }
//================================================================================================================== //================================================================================================================== static void RecoverMissingSims() { try{ List <Sim> sims = new List <Sim>(LotManager.Actors); foreach (Sim sim in sims) { try{ SimDescription simDesc = sim.SimDescription; if (simDesc == null) { continue; } if ((!sim.SimDescription.IsValidDescription) || (sim.Household == null)) { try{ if (SimIsMissing(sim.SimDescription, true)) { simDesc.Fixup(); sim.Autonomy?.Motives?.RecreateMotives(sim); sim.SetObjectToReset(); } }catch (Exception exception) { Alive.WriteLog(exception.Message + "\n\n" + exception.StackTrace + "\n\n" + exception.Source + "\n\n" + "RecoverMissingSims_foreach_missing"); }finally{ } } }catch (Exception exception) { Alive.WriteLog(exception.Message + "\n\n" + exception.StackTrace + "\n\n" + exception.Source + "\n\n" + "RecoverMissingSims_foreach"); }finally{ } } }catch (Exception exception) { Alive.WriteLog(exception.Message + "\n\n" + exception.StackTrace + "\n\n" + exception.Source + "\n\n" + "RecoverMissingSims"); }finally{ } try{ List <Household> houses = new List <Household>(Household.sHouseholdList); foreach (Household house in houses) { try{ if (house.LotHome == null) { continue; } var numSims = (house.AllSimDescriptions.Count); List <Sim> allSims = new List <Sim>(); foreach (SimDescription sim in house.AllSimDescriptions) { if (sim.CreatedSim == null) { continue; } allSims.Add(sim.CreatedSim); } if (numSims != allSims.Count) { List <SimDescription> allSimDescriptions = house.AllSimDescriptions; foreach (SimDescription description in allSimDescriptions) { bool flag = (true); foreach (Sim sim in allSims) { if (sim.SimDescription == description) { flag = (false); break; } } if (flag) { FixInvisibleSim(description); RecoverMissingSim(description, true); } } } }catch (Exception exception) { Alive.WriteLog(exception.Message + "\n\n" + exception.StackTrace + "\n\n" + exception.Source + "\n\n" + "RecoverMissingSims_households_foreach"); }finally{ } } }catch (Exception exception) { Alive.WriteLog(exception.Message + "\n\n" + exception.StackTrace + "\n\n" + exception.Source + "\n\n" + "RecoverMissingSims_households"); }finally{ } }
public static SimDescription UnpackSim(MiniSimDescription ths, bool updateGenealogy) { try { if (ths == null) return null; // Calling ImportSimDescription prior to the Aging Manager being available is invalid, don't allow it if (AgingManager.Singleton == null) return null; SimDescription desc = new SimDescription(); ResourceKeyContentCategory installed = ResourceKeyContentCategory.kInstalled; DownloadContent.ImportSimDescription(ths.mTravelKey, desc, ref installed); desc.SimDescriptionId = ths.mSimDescriptionId; if (desc.CareerManager != null) { // Fixup for careers require a household, which is not set until later in this process desc.CareerManager.mJob = null; desc.CareerManager.mSchool = null; } desc.Fixup(); if (updateGenealogy && !GameStates.IsTravelling) { if (desc.DefaultOutfitKey == ResourceKey.kInvalidResourceKey) { SimOutfit outfit = desc.GetOutfit(OutfitCategories.Everyday, 0x0); if ((outfit == null) || (!outfit.IsValid)) { desc.Dispose(false, false); return null; } desc.UpdateFromOutfit(OutfitCategories.Everyday); } desc.CASGenealogy = ths.CASGenealogy; } Corrections.CleanupBrokenSkills(desc, null); OccultTypeHelper.ValidateOccult(desc, null); return desc; } catch (Exception e) { Common.Exception(ths.FullName, e); return null; } }
public AddSims(Household house, IEnumerable <IMiniSimDescription> miniSims, bool overStuff, bool transferFunds, bool dreamCatcher) { mOldMembers = new List <SimDescription>(CommonSpace.Helpers.Households.All(house)); foreach (IMiniSimDescription iMiniSim in new List <IMiniSimDescription>(miniSims)) { if (overStuff) { if (iMiniSim.IsHuman) { if (CommonSpace.Helpers.Households.NumHumansIncludingPregnancy(house) >= 8) { continue; } } else { if (CommonSpace.Helpers.Households.NumPetsIncludingPregnancy(house) >= 6) { continue; } } } MiniSimDescription miniSim = null; bool lastActiveSim = false; SimDescription sim = iMiniSim as SimDescription; if (sim == null) { miniSim = iMiniSim as MiniSimDescription; if (miniSim == null) { continue; } sim = MiniSims.UnpackSimAndUpdateRel(miniSim); if (sim == null) { continue; } } else if (sim.CreatedSim == Sim.ActiveActor) { if (Households.NumSims(sim.Household) == 1) { lastActiveSim = true; } else { LotManager.SelectNextSim(); } } Household oldHouse = sim.Household; if (oldHouse != null) { if (oldHouse == Household.ActiveHousehold) { Household.RoommateManager.RemoveRoommateInternal(sim); } if ((transferFunds) && (oldHouse.NumMembers == 1)) { int funds = oldHouse.FamilyFunds; if (oldHouse.LotHome != null) { funds += oldHouse.LotHome.Cost; } house.ModifyFamilyFunds(funds); Households.TransferData(house, oldHouse); } house.AddWardrobeToWardrobe(oldHouse.Wardrobe); house.AddServiceUniforms(oldHouse.mServiceUniforms); oldHouse.Remove(sim, !oldHouse.IsSpecialHousehold); if (PetAdoption.sNeighborAdoption != null) { PetAdoption.sNeighborAdoption.mPetsToAdopt.Remove(sim); } if (sim.CreatedSim != null) { oldHouse.GetCaregiverRoutingMonitor(sim.CreatedSim.LotCurrent, true); } } if ((oldHouse != null) && (!mOldHouses.ContainsKey(oldHouse))) { mOldHouses.Add(oldHouse, true); } mNewMembers.Add(sim); if (house.Name == null) { house.Name = sim.LastName; } if ((sim.IsDead) && (!sim.IsPlayableGhost)) { Urnstone grave = Urnstones.CreateGrave(sim, false); if (grave != null) { Urnstones.GhostToPlayableGhost(grave, house, house.LotHome.EntryPoint()); } } else { // Must be performed or the Household:Add() will bounce if (!sim.IsValidDescription) { sim.Fixup(); } MiniSims.ProtectedAddHousehold(house, sim); if (sim.IsPet) { foreach (PetPoolType type in Enum.GetValues(typeof(PetPoolType))) { if (PetPoolManager.IsPetInPoolType(sim, type)) { PetPoolManager.RemovePet(type, sim, true); } } } if ((CarNpcManager.Singleton != null) && (CarNpcManager.Singleton.NpcDriversManager != null)) { if (CarNpcManager.Singleton.NpcDriversManager.mDescPools != null) { for (int i = 0; i < CarNpcManager.Singleton.NpcDriversManager.mDescPools.Length; i++) { Stack <SimDescription> stack = CarNpcManager.Singleton.NpcDriversManager.mDescPools[i]; if (stack == null) { continue; } List <SimDescription> list = new List <SimDescription>(); foreach (SimDescription stackSim in stack) { if (stackSim == sim) { while (stack.Count > 0) { list.Add(stack.Pop()); } list.Remove(sim); for (int j = list.Count - 1; j >= 0; j--) { stack.Push(list[j]); } } } } } if ((sim.CreatedSim != null) && (CarNpcManager.Singleton.NpcDriversManager.mNpcDrivers != null)) { CarNpcManager.Singleton.NpcDriversManager.mNpcDrivers.Remove(sim.CreatedSim); } } } if (house.LotHome != null) { Instantiation.EnsureInstantiate(sim, house.LotHome); } if (miniSim != null) { (Sims3.Gameplay.UI.Responder.Instance.HudModel as HudModel).OnSimCurrentWorldChanged(true, miniSim); AgingManager.Singleton.AddSimDescription(sim); sim.AgingState.MergeTravelInformation(miniSim); sim.SetFlags(SimDescription.FlagField.AgingEnabled, true); } try { if (sim.Service != null) { sim.Service.EndService(sim); } if (sim.CreatedSim != null) { sim.CreatedSim.BuffManager.RemoveElement(BuffNames.StrayPet); DreamCatcher.AdjustSelectable(sim, sim.Household == Household.ActiveHousehold, dreamCatcher); sim.CreatedSim.SetObjectToReset(); sim.CreatedSim.Motives.RecreateMotives(sim.CreatedSim); Sim.MakeSimGoHome(sim.CreatedSim, false); if (lastActiveSim) { PlumbBob.DoSelectActor(sim.CreatedSim, false); } } } catch (Exception e) { Common.DebugException(sim, e); } } }
public SimDescription CreateNewSim(SimDescription mom, SimDescription dad, CASAgeGenderFlags ages, CASAgeGenderFlags genders, CASAgeGenderFlags species, bool updateGenealogy) { if (dad == null) { dad = GetSim(CASAgeGenderFlags.Male, species, mom); if (dad == null) { dad = GetSim(CASAgeGenderFlags.Female, species, mom); if (dad == null) { return(null); } } } CASAgeGenderFlags gender = (CASAgeGenderFlags)RandomUtil.SelectOneRandomBit((uint)(genders)); CASAgeGenderFlags age = (CASAgeGenderFlags)RandomUtil.SelectOneRandomBit((uint)(ages)); if (dad.CelebrityManager == null) { dad.Fixup(); } if (mom.CelebrityManager == null) { mom.Fixup(); } SimDescription newSim = null; try { if (mom.Species == CASAgeGenderFlags.Human) { newSim = Genetics.MakeDescendant(dad, mom, age, gender, 100, new Random(), false, updateGenealogy, true, GetGeneticWorld(), false); newSim.HomeWorld = GameUtils.GetCurrentWorld(); } else { newSim = GeneticsPet.MakePetDescendant(dad, mom, age, gender, mom.Species, new Random(), updateGenealogy, GeneticsPet.SetName.SetNameNonInteractive, 0, OccultTypes.None); } } catch (Exception e) { Common.Exception(dad, mom, e); } if (newSim == null) { return(null); } if (!updateGenealogy) { FacialBlends.RandomizeBlends(mStats.AddStat, newSim, new Vector2(0f, 0f), true, Manager.GetValue <MutationUnsetRangeOption <TManager>, Vector2>(), true, Manager.GetValue <AllowAlienHouseholdOption <TManager>, bool>()); } List <OccultTypes> occults = new List <OccultTypes>(); occults.AddRange(OccultTypeHelper.CreateList(mom.OccultManager.CurrentOccultTypes, true)); occults.AddRange(OccultTypeHelper.CreateList(dad.OccultManager.CurrentOccultTypes, true)); if (updateGenealogy) { Manager.Sims.ApplyOccultChance(Manager, newSim, occults, Manager.GetValue <ChanceOfHybridOption <TManager>, int>(), Manager.GetValue <MaximumOccultOption <TManager>, int>()); } else if (species == CASAgeGenderFlags.Human) { int maxCelebrityLevel = Manager.GetValue <MaxCelebrityLevelOption <TManager>, int>(); if (maxCelebrityLevel >= 0) { newSim.CelebrityManager.mOwner = newSim; Skill scienceSkill = SkillManager.GetStaticSkill(SkillNames.Science); if (scienceSkill != null) { scienceSkill.mNonPersistableData.SkillCategory |= SkillCategory.Hidden; } try { newSim.CelebrityManager.ForceSetLevel((uint)RandomUtil.GetInt(maxCelebrityLevel)); } finally { if (scienceSkill != null) { scienceSkill.mNonPersistableData.SkillCategory &= ~SkillCategory.Hidden; } } } occults.AddRange(Manager.GetValue <ImmigrantOccultOption <TManager>, List <OccultTypes> >()); if (occults.Count > 0) { if (RandomUtil.RandomChance(Manager.GetValue <ChanceOfOccultOption <TManager>, int>())) { OccultTypeHelper.Add(newSim, RandomUtil.GetRandomObjectFromList(occults), false, false); } } } Manager.Sims.ApplyOccultChance(Manager, newSim, occults, Manager.GetValue <ChanceOfHybridOption <TManager>, int>(), Manager.GetValue <MaximumOccultOption <TManager>, int>()); OccultTypeHelper.ValidateOccult(newSim, null); OccultTypeHelper.TestAndRebuildWerewolfOutfit(newSim); newSim.FirstName = Manager.Sims.EnsureUniqueName(newSim); List <Trait> traits = new List <Trait>(newSim.TraitManager.List); foreach (Trait trait in traits) { if (trait.IsHidden) { newSim.TraitManager.RemoveElement(trait.Guid); } } List <Trait> choices = AgingManager.GetValidTraits(newSim, true, true, true); if (choices.Count > 0) { while (!newSim.TraitManager.TraitsMaxed()) { Trait choice = RandomUtil.GetRandomObjectFromList <Trait>(choices); if (!newSim.TraitManager.AddElement(choice.Guid)) { break; } } } if (SimFromBinEvents.OnGeneticSkinBlend != null) { SimFromBinEvents.OnGeneticSkinBlend(mStats, newSim, mom, dad, Manager); } FixInvisibleTask.Perform(newSim, true); if (SimFromBinEvents.OnSimFromBinUpdate != null) { SimFromBinEvents.OnSimFromBinUpdate(mStats, newSim, mom, dad, Manager); } INameTakeOption nameTake = Manager.GetOption <NameTakeOption <TManager> >(); if ((!updateGenealogy) && (nameTake != null)) { bool wasEither; newSim.LastName = Manager.Sims.HandleName(nameTake, mom, dad, out wasEither); } else if (mom != null) { newSim.LastName = mom.LastName; } else if (dad != null) { newSim.LastName = dad.LastName; } if (!updateGenealogy && Manager.GetValue <CustomNamesOnlyOption <TManager>, bool>()) { newSim.LastName = LastNameListBooter.GetRandomName(!Manager.GetValue <CustomNamesOnlyOption <TManager>, bool>(), newSim.Species, newSim.IsFemale); } return(newSim); }
protected static bool BumpUp(SimDescription a, SimDescription b, bool prompt, bool romantic) { Relationship relation = Relationship.Get(a, b, true); if (relation == null) { return(false); } LongTermRelationshipTypes currentState = relation.LTR.CurrentLTR; LongTermRelationshipTypes nextState = LongTermRelationshipTypes.Undefined; if (romantic) { nextState = NextPositiveRomanceState(currentState); } else { nextState = NextPositiveFriendState(currentState); } if (nextState == LongTermRelationshipTypes.Undefined) { if (prompt) { SimpleMessageDialog.Show(Common.Localize("Romance:BumpUpTitle"), Common.Localize("Romance:TooHigh")); } return(false); } /* * if (relation.LTR.RelationshipIsInappropriate(LTRData.Get(nextState))) * { * if (prompt) * { * SimpleMessageDialog.Show(Common.Localize("Romance:BumpUpTitle"), Common.Localize ("Romance:Improper", new object[] { Common.LocalizeStatus (a, b, nextState) })); * } * return false; * } */ if ((romantic) && (a.Genealogy.IsBloodRelated(b.Genealogy))) { if ((prompt) && (!AcceptCancelDialog.Show(Common.Localize("Romance:BloodPrompt", a.IsFemale, new object [] { a, b })))) { return(false); } } if ((currentState == LongTermRelationshipTypes.RomanticInterest) && (romantic)) { if ((a.Partner != null) && (a.Partner != b)) { if ((b.Partner != null) && (b.Partner != a)) { if ((prompt) && (!AcceptCancelDialog.Show(Common.Localize("Romance:DualPartnerPrompt", a.IsFemale, new object[] { a, b })))) { return(false); } } else { if ((prompt) && (!AcceptCancelDialog.Show(Common.Localize("Romance:PartnerPrompt", a.IsFemale, new object[] { a })))) { return(false); } } } else if ((b.Partner != null) && (b.Partner != a)) { if ((prompt) && (!AcceptCancelDialog.Show(Common.Localize("Romance:PartnerPrompt", b.IsFemale, new object[] { b })))) { return(false); } } if (a.Partner != null) { BumpDown(a, a.Partner, false, true); } if (b.Partner != null) { BumpDown(b, b.Partner, false, true); } if (a.TraitManager == null) { a.Fixup(); } if (b.TraitManager == null) { b.Fixup(); } Relationships.SetPartner(a, b); } ForceChangeState(relation, nextState); if (romantic) { if (prompt && relation.RomanceVisibilityState != null) { long time = 0; relation.TryGetActiveRomanceStartTime(out time); int days = 0; if (time != 0) { days = (int)SimClock.ElapsedTime(TimeUnit.Days, new DateAndTime(time)); } string text = StringInputDialog.Show(Common.Localize("Romance:StartTime"), Common.Localize("Romance:StartPrompt", a.IsFemale, new object[] { a, b, SimClock.ElapsedCalendarDays() }), days.ToString()); if (string.IsNullOrEmpty(text)) { return(false); } int mValue = 0; if (!int.TryParse(text, out mValue) || mValue > SimClock.ElapsedCalendarDays()) { SimpleMessageDialog.Show(Common.Localize("Romance:StartTime"), Common.Localize("Numeric:ErrorInputIgnored")); } else { relation.RomanceVisibilityState.mStartTime = SimClock.Subtract(SimClock.CurrentTime(), TimeUnit.Days, (float)mValue); } } } if (relation.LTR.CurrentLTR == LongTermRelationshipTypes.BestFriendsForever) { bool isPetBFF = ((!a.IsHuman) || (!b.IsHuman)); a.HasBFF = true; b.HasBFF = true; FindAndRemoveBFF(a, b, isPetBFF); FindAndRemoveBFF(b, a, isPetBFF); } if (currentState == relation.LTR.CurrentLTR) { return(false); } StyledNotification.Format format = new StyledNotification.Format(Common.Localize("Romance:Success", a.IsFemale, new object[] { a, b, LocalizeStatus(a, b, relation.LTR.CurrentLTR) }), StyledNotification.NotificationStyle.kGameMessagePositive); format.mTNSCategory = NotificationManager.TNSCategory.Lessons; StyledNotification.Show(format); return(true); }
protected override bool Run(SimDescription me, bool singleSelection) { if (!ApplyAll) { mAdoptionParams = AdoptionDialog.Show(Common.Localize(GetTitlePrefix() + ":Prompt", me.IsFemale, new object[] { me })); if (mAdoptionParams.mCancelled) { return(false); } } List <SimDescription> residents = new List <SimDescription>(); foreach (SimDescription sim in SimListing.GetResidents(true).Values) { if (!sim.IsHuman) { continue; } residents.Add(sim); } SimDescription dad = RandomUtil.GetRandomObjectFromList(residents); SimDescription mom = RandomUtil.GetRandomObjectFromList(residents); SimDescription newKid = null; if ((dad != null) && (mom != null)) { if (dad.CelebrityManager == null) { dad.Fixup(); } if (mom.CelebrityManager == null) { mom.Fixup(); } newKid = Genetics.MakeDescendant(dad, mom, mAdoptionParams.mAge, mAdoptionParams.mIsFemale ? CASAgeGenderFlags.Female : CASAgeGenderFlags.Male, 100, new Random(), false, false, true); } else { SimUtils.SimCreationSpec spec = new SimUtils.SimCreationSpec(); spec.Gender = mAdoptionParams.mIsFemale ? CASAgeGenderFlags.Female : CASAgeGenderFlags.Male; spec.Age = mAdoptionParams.mAge; spec.Normalize(); newKid = spec.Instantiate(); } if (newKid == null) { Common.Notify(Common.Localize(GetTitlePrefix() + ":Failure")); return(false); } string genderName = null; if (newKid.IsFemale) { genderName = Common.Localize("BabyGender:Female"); } else { genderName = Common.Localize("BabyGender:Male"); } string name = StringInputDialog.Show(Name, Common.Localize("InstaBaby:NamePrompt", newKid.IsFemale, new object[0]), newKid.FirstName); if (!string.IsNullOrEmpty(name)) { newKid.FirstName = name; } newKid.LastName = me.LastName; me.Household.Add(newKid); newKid.WasAdopted = true; Sim adoptedChild = Instantiation.Perform(newKid, null); if (adoptedChild != null) { ResetSimTask.UpdateInterface(adoptedChild); SocialWorkerAdoptionSituation.InstantiateNewKid instantiateNewKid = new SocialWorkerAdoptionSituation.InstantiateNewKid(); instantiateNewKid.AssignTraits(adoptedChild); instantiateNewKid.GiveImaginaryFriendDoll(newKid); me.Genealogy.AddChild(newKid.Genealogy); if (me.CreatedSim != null) { ActiveTopic.AddToSim(me.CreatedSim, "Recently Had Baby"); EventTracker.SendEvent(EventTypeId.kAdoptedChild, me.CreatedSim, adoptedChild); EventTracker.SendEvent(EventTypeId.kNewOffspring, me.CreatedSim, adoptedChild); EventTracker.SendEvent(EventTypeId.kParentAdded, adoptedChild, me.CreatedSim); } MidlifeCrisisManager.OnHadChild(me); Genealogy spouse = me.Genealogy.Spouse; if (spouse != null) { spouse.AddChild(newKid.Genealogy); SimDescription spouseDesc = spouse.SimDescription; if (spouseDesc != null) { MidlifeCrisisManager.OnHadChild(spouseDesc); if (spouseDesc.CreatedSim != null) { ActiveTopic.AddToSim(spouseDesc.CreatedSim, "Recently Had Baby"); EventTracker.SendEvent(EventTypeId.kAdoptedChild, spouseDesc.CreatedSim, adoptedChild); EventTracker.SendEvent(EventTypeId.kNewOffspring, spouseDesc.CreatedSim, adoptedChild); EventTracker.SendEvent(EventTypeId.kParentAdded, adoptedChild, spouseDesc.CreatedSim); } } } EventTracker.SendEvent(EventTypeId.kChildBornOrAdopted, null, adoptedChild); } return(true); }
public void PerformAction(bool prompt) { try { Overwatch.Log("Cleanup Genealogy"); Dictionary <IMiniSimDescription, IMiniSimDescription> duplicates = new Dictionary <IMiniSimDescription, IMiniSimDescription>(); Dictionary <ulong, IMiniSimDescription> lookup = new Dictionary <ulong, IMiniSimDescription>(); Dictionary <IMiniSimDescription, bool> urnstones = new Dictionary <IMiniSimDescription, bool>(); foreach (SimDescription sim in SimDescription.GetHomelessSimDescriptionsFromUrnstones()) { if (urnstones.ContainsKey(sim)) { continue; } urnstones.Add(sim, true); } Dictionary <IGenealogy, bool> allGenealogies = new Dictionary <IGenealogy, bool>(); List <IGenealogy> geneList = new List <IGenealogy>(); foreach (KeyValuePair <ulong, List <IMiniSimDescription> > ids in SimListing.AllSims <IMiniSimDescription>(null, true, false)) { List <IMiniSimDescription> list = ids.Value; foreach (IMiniSimDescription miniSim in list) { if (miniSim.CASGenealogy == null) { continue; } if (allGenealogies.ContainsKey(miniSim.CASGenealogy)) { continue; } allGenealogies.Add(miniSim.CASGenealogy, true); geneList.Add(miniSim.CASGenealogy); } IMiniSimDescription choice = null; if (list.Count == 1) { choice = list[0]; } else if (list.Count > 1) { List <IMiniSimDescription> choices = new List <IMiniSimDescription>(); foreach (IMiniSimDescription miniSim in list) { SimDescription sim = miniSim as SimDescription; if (sim == null) { continue; } if (sim.Household == Household.ActiveHousehold) { choices.Add(miniSim); } } if (choices.Count >= 1) { choice = choices[0]; Overwatch.Log("Doppleganger Active-Inactive (" + list.Count + "): " + Relationships.GetFullName(choice)); } else { choices.Clear(); foreach (IMiniSimDescription sim in list) { if (urnstones.ContainsKey(sim)) { choices.Add(sim); } } if (choices.Count == 1) { choice = choices[0]; Overwatch.Log("Doppleganger Urnstone (" + list.Count + "): " + Relationships.GetFullName(choice)); } else { choices.Clear(); foreach (IMiniSimDescription sim in list) { Genealogy genealogy = sim.CASGenealogy as Genealogy; if ((genealogy != null) && (object.ReferenceEquals(sim, genealogy.mSim))) { choices.Add(sim); } } if (choices.Count == 1) { choice = choices[0]; Overwatch.Log("Doppleganger Personal Genealogy (" + list.Count + "): " + Relationships.GetFullName(choice)); } else { choices.Clear(); MiniSimDescription miniSim = MiniSimDescription.Find(ids.Key); if ((miniSim != null) && (miniSim.Genealogy != null) && (miniSim.Genealogy.mSim != null)) { foreach (IMiniSimDescription sim in list) { if (object.ReferenceEquals(sim, miniSim.Genealogy.mSim)) { choices.Add(sim); } } } if (choices.Count == 1) { choice = choices[0]; Overwatch.Log("Doppleganger MiniSim Genealogy (" + list.Count + "): " + Relationships.GetFullName(choice)); } else { choices.Clear(); int maxLinks = 0; foreach (IMiniSimDescription sim in list) { if (choice == null) { choice = sim; } else { int numLinks = 0; Genealogy gene = sim.CASGenealogy as Genealogy; if (gene != null) { if (gene.mNaturalParents != null) { numLinks += gene.mNaturalParents.Count; } if (gene.mChildren != null) { numLinks += gene.mChildren.Count; } if (gene.mSiblings != null) { numLinks += gene.mSiblings.Count; } if (maxLinks < numLinks) { maxLinks = numLinks; choice = sim; } } } } Overwatch.Log("Doppleganger By Link Count (" + list.Count + "): " + Relationships.GetFullName(choice)); } } } } } if (choice != null) { lookup.Add(choice.SimDescriptionId, choice); foreach (IMiniSimDescription sim in list) { if (object.ReferenceEquals(sim, choice)) { continue; } duplicates.Add(sim, choice); Genealogy genealogy = ReconcileGenealogy(choice.CASGenealogy as Genealogy, sim.CASGenealogy as Genealogy); if (genealogy != null) { SetGenealogy(choice, genealogy); } } } } int index = 0; while (index < geneList.Count) { Genealogy genealogy = geneList[index] as Genealogy; index++; if (genealogy == null) { continue; } AddToList(geneList, allGenealogies, genealogy.mNaturalParents); AddToList(geneList, allGenealogies, genealogy.mChildren); AddToList(geneList, allGenealogies, genealogy.mSiblings); } Dictionary <string, List <Genealogy> > broken = new Dictionary <string, List <Genealogy> >(); foreach (IGenealogy iGene in geneList) { Genealogy gene = iGene as Genealogy; if (gene == null) { continue; } if ((gene.mMiniSim == null) && (gene.mSim == null)) { if (!string.IsNullOrEmpty(gene.Name)) { List <Genealogy> genes; if (!broken.TryGetValue(gene.Name, out genes)) { genes = new List <Genealogy>(); broken.Add(gene.Name, genes); } genes.Add(gene); } } MiniSimDescription miniSim = gene.mMiniSim as MiniSimDescription; if (miniSim == null) { continue; } if ((MiniSimDescription.sMiniSims != null) && (!MiniSimDescription.sMiniSims.ContainsKey(miniSim.SimDescriptionId))) { MiniSimDescription.sMiniSims.Add(miniSim.SimDescriptionId, miniSim); if (!lookup.ContainsKey(miniSim.SimDescriptionId)) { lookup.Add(miniSim.SimDescriptionId, miniSim); } Overwatch.Log("Genealogy Minisim Added " + Relationships.GetFullName(miniSim)); } } CleanupMiniSimGenealogy(lookup, broken); foreach (IMiniSimDescription sim in lookup.Values) { try { IMiniSimDescription lookupSim = Relationships.Find(sim.SimDescriptionId, lookup); Genealogy genealogy = null; if (lookupSim != null) { genealogy = lookupSim.CASGenealogy as Genealogy; if ((genealogy != null) && (sim.CASGenealogy != null) && (!object.ReferenceEquals(genealogy, sim.CASGenealogy))) { sim.CASGenealogy = genealogy; Overwatch.Log("Lookup Genealogy Replaced: " + Relationships.GetFullName(sim)); } } if (genealogy == null) { genealogy = sim.CASGenealogy as Genealogy; } if (genealogy == null) { MiniSimDescription miniSim = MiniSimDescription.Find(sim.SimDescriptionId); if (miniSim != null) { genealogy = miniSim.mGenealogy; if ((genealogy != null) && (sim.CASGenealogy != null) && (!object.ReferenceEquals(genealogy, sim.CASGenealogy))) { sim.CASGenealogy = genealogy; Overwatch.Log("MiniSim Genealogy Replaced: " + Relationships.GetFullName(sim)); } } } if (genealogy == null) { SimDescription trueSim = sim as SimDescription; if (trueSim != null) { trueSim.Fixup(); genealogy = sim.CASGenealogy as Genealogy; if (genealogy == null) { Overwatch.Log("No SimDesc Genealogy: " + Relationships.GetFullName(sim)); } else { Overwatch.Log("Genealogy Fixup Performed: " + Relationships.GetFullName(sim)); } } else { MiniSimDescription miniSim = sim as MiniSimDescription; if (miniSim != null) { // This minisim may be part of a family tree, so must be uncorrupted genealogy = new Genealogy(miniSim.FullName); Overwatch.Log("MiniSim Genealogy Created: " + Relationships.GetFullName(sim)); } else { Overwatch.Log("No MiniSim Genealogy: " + Relationships.GetFullName(sim)); } } } SetGenealogy(sim, genealogy); } catch (Exception e) { Common.Exception("Phase One: " + Relationships.GetFullName(sim), e); } } foreach (IMiniSimDescription sim in lookup.Values) { try { SimDescription trueSim = sim as SimDescription; if (trueSim != null) { MiniSimDescription miniSim = MiniSimDescription.Find(trueSim.SimDescriptionId); if (miniSim != null) { List <MiniRelationship> relationships = new List <MiniRelationship>(miniSim.MiniRelationships); foreach (MiniRelationship relationship in relationships) { IMiniSimDescription otherSim = MiniSimDescription.Find(relationship.GetOtherSimDescriptionId(sim)); if (otherSim == null) { miniSim.mMiniRelationships.Remove(relationship); } else { Genealogy gene = otherSim.CASGenealogy as Genealogy; if (gene == null) { miniSim.mMiniRelationships.Remove(relationship); } } } } Dictionary <ulong, bool> existingRelations = new Dictionary <ulong, bool>(); Dictionary <SimDescription, Relationship> oldRelations; if (Relationship.sAllRelationships.TryGetValue(trueSim, out oldRelations)) { Dictionary <SimDescription, Relationship> newRelations = new Dictionary <SimDescription, Relationship>(); foreach (KeyValuePair <SimDescription, Relationship> relation in new Dictionary <SimDescription, Relationship>(oldRelations)) { IMiniSimDescription townSim; if (lookup.TryGetValue(relation.Key.SimDescriptionId, out townSim)) { if (!object.ReferenceEquals(townSim, relation.Key)) { Overwatch.Log(Relationships.GetFullName(sim) + " Dropped bad relation for " + Relationships.GetFullName(relation.Key)); Relationships.SafeRemoveRelationship(relation.Value); continue; } } if (existingRelations.ContainsKey(relation.Key.SimDescriptionId)) { Overwatch.Log(Relationships.GetFullName(sim) + " Dropped duplicate relation for " + Relationships.GetFullName(relation.Key)); Relationships.SafeRemoveRelationship(relation.Value); continue; } existingRelations.Add(relation.Key.SimDescriptionId, true); Relationships.RepairRelationship(relation.Value, Overwatch.Log); newRelations.Add(relation.Key, relation.Value); } Relationship.sAllRelationships[trueSim] = newRelations; } /* * MiniSimDescription miniDesc = MiniSimDescription.Find(trueSim.SimDescriptionId); * if (miniDesc != null) * { * for (int i = miniDesc.mMiniRelationships.Count - 1; i >= 0; i--) * { * MiniRelationship relation = miniDesc.mMiniRelationships[i]; * * if (existingRelations.ContainsKey(relation.SimDescriptionId)) * { * miniDesc.mMiniRelationships.RemoveAt(i); * * Overwatch.Log(GetFullName(trueSim) + " Dropped duplicate mini relation"); * } * } * } */ RepairMissingPartner(trueSim); // Legacy repair for an issue with an earlier Phase of Overwatch List <Relationship> relations = new List <Relationship>(Relationship.GetRelationships(trueSim)); foreach (Relationship relation in relations) { if ((relation.LTR.HasInteractionBit(LongTermRelationship.InteractionBits.Divorce)) || (relation.LTR.HasInteractionBit(LongTermRelationship.InteractionBits.BreakUp)) || (relation.LTR.HasInteractionBit(LongTermRelationship.InteractionBits.BreakEngagement)) || (relation.LTR.HasInteractionBit(LongTermRelationship.InteractionBits.Marry)) || (relation.LTR.HasInteractionBit(LongTermRelationship.InteractionBits.Propose)) || (relation.LTR.HasInteractionBit(LongTermRelationship.InteractionBits.MakeCommitment))) { relation.LTR.AddInteractionBit(LongTermRelationship.InteractionBits.HaveBeenPartners); } } } Genealogy genealogy = sim.CASGenealogy as Genealogy; if (genealogy != null) { genealogy.ClearDerivedData(); new Relationships.RepairParents().Perform(sim, Overwatch.Log, lookup); new Relationships.RepairChildren().Perform(sim, Overwatch.Log, lookup); new Relationships.RepairSiblings().Perform(sim, Overwatch.Log, lookup); RepairSpouse(sim, lookup); if ((sim.IsMarried) && (genealogy.mPartnerType != PartnerType.Marriage)) { genealogy.mPartnerType = PartnerType.Marriage; if (genealogy.Spouse != null) { genealogy.Spouse.mPartnerType = PartnerType.Marriage; } Overwatch.Log(Relationships.GetFullName(sim) + " PartnerType Corrected"); } } RepairMiniSim(trueSim); } catch (Exception e) { Common.Exception("Phase Two: " + Relationships.GetFullName(sim), e); } } CleanupMiniSims(lookup); // Must be performed after repairing the genealogy as the mSim is wiped from the genealogy during deletion foreach (KeyValuePair <IMiniSimDescription, IMiniSimDescription> duplicate in duplicates) { CustomAnnihilation(duplicate.Key as SimDescription, duplicate.Value as SimDescription); } } catch (Exception e) { Common.Exception(Name, e); } }