public override bool InRabbitHole() { try { SimDescription male; int num; if (!PetAdoption.BreedMare(Actor, Target, Horse.FullName, out male, out num)) { return(false); } CancellableByPlayer = false; Pregnancies.Start(Horse, male, false); Actor.ModifyFunds(-num); EventTracker.SendEvent(new WooHooEvent(EventTypeId.kWooHooed, Horse, null, Target)); StartStages(); BeginCommodityUpdates(); bool succeeded = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached)); AssignHorseAndPosture(Horse, RabbitHole.SimRabbitHoleState.Leading); EndCommodityUpdates(succeeded); return(succeeded); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); return(false); } }
public static void Stop(Logger log) { try { PetAdoption.ResetNeighborAdoption(); if (PetAdoption.sPetFromNeighborAddingAlarm != AlarmHandle.kInvalidHandle) { AlarmManager.Global.RemoveAlarm(PetAdoption.sPetFromNeighborAddingAlarm); PetAdoption.sPetFromNeighborAddingAlarm = AlarmHandle.kInvalidHandle; if (log != null) { log(" Alarm Disabled"); } } } catch (Exception e) { Common.Exception("Stop", e); } }
protected override bool Run(SimDescription me, bool singleSelection) { SimDescription pet = PetAdoption.ShowAdoptPetPicker(true); if (pet == null) { Common.Notify(Common.Localize("AdoptPet:Failure")); return(false); } string titleText = Common.LocalizeEAString(pet.IsFemale, "Gameplay/Actors/Sim/StrayPets:AdoptStrayNameTitle"); string promptText = Common.LocalizeEAString(pet.IsFemale, "Gameplay/Actors/Sim/StrayPets:AdoptStrayNameDescription"); pet.FirstName = StringInputDialog.Show(titleText, promptText, pet.FirstName, 256, StringInputDialog.Validation.SimNameText); pet.LastName = me.LastName; PetAdoption.GetPetOutOfPool(pet); if (pet.Household != null) { pet.Household.Remove(pet, false); } me.Household.Add(pet); pet.IsNeverSelectable = false; pet.WasAdopted = true; Relationships.CheckAddHumanParentFlagOnAdoption(me, pet); if (me.Partner != null) { Relationships.CheckAddHumanParentFlagOnAdoption(me.Partner, pet); } Instantiation.Perform(pet, null); return(true); }
public static bool PerformImmediate(Sim sim, bool allowHouseholdSwitch, bool catchDreams, bool forceFull) { bool success = false; Common.StringBuilder msg = new Common.StringBuilder("DreamCatcher: " + sim.FullName + Common.NewLine); try { msg += "A"; if ((!forceFull) && (PlumbBob.sCurrentNonNullHousehold != null) && (PlumbBob.sCurrentNonNullHousehold == sim.Household)) { msg += "B"; if (PlumbBob.SelectedActor == sim) { return(true); } msg += "C"; using (SafeStore store = new SafeStore(sim.SimDescription, SafeStore.Flag.Selectable | SafeStore.Flag.Unselectable | SafeStore.Flag.StoreOpportunities)) { if (PlumbBob.SelectActor(sim)) { return(true); } msg += "C2"; return(false); } } msg += "D"; if (!allowHouseholdSwitch) { return(false); } msg += "E"; if (GameUtils.IsInstalled(ProductVersion.EP5)) { PetAdoption.RemoveNeighborAdoptionOnHousehold(sim.Household.LotHome); } if (sim.Posture == null) { sim.Posture = null; // Resets to Standing } using (HouseholdStore store = new HouseholdStore(sim.Household, catchDreams)) { if (sim.Household.LotHome != null) { PrepareToBecomeActiveHousehold(sim.Household); } foreach (SimDescription member in sim.Household.AllSimDescriptions) { if (member.GetMiniSimForProtection() == null) { MiniSimDescription miniSim; if (MiniSimDescription.sMiniSims.TryGetValue(member.SimDescriptionId, out miniSim)) { miniSim.mHomeWorld = WorldName.UserCreated; } } } Sim previousSim = Sim.ActiveActor; try { success = PlumbBob.ForceSelectActor(sim); } catch (Exception exception) { Common.Exception(sim, exception); if (previousSim != null) { PlumbBob.ForceSelectActor(previousSim); } } } msg += "F " + success; if ((MapTagManager.ActiveMapTagManager != null) && (sim.LotHome != null)) { MapTagManager.ActiveMapTagManager.Reset(); } } catch (Exception e) { Common.Exception(sim, e); } finally { //Common.DebugNotify(msg); } return(success); }
public static bool Perform(SimDescription sim, bool cleanse) { if (sim == null) { return(false); } Common.StringBuilder msg = new Common.StringBuilder("Perform" + Common.NewLine); Household house = sim.Household; try { Sim createdSim = sim.CreatedSim; if (createdSim != null) { createdSim.ReservedVehicle = null; } if (PetAdoption.sNeighborAdoption != null) { if (PetAdoption.sNeighborAdoption.mMother == sim) { try { PetAdoption.ResetNeighborAdoption(); } catch (Exception e) { Common.Exception(sim, e); } finally { PetAdoption.sNeighborAdoption = null; } } else { PetAdoption.sNeighborAdoption.mPetsToAdopt.Remove(sim); } } foreach (Service service in Services.AllServices) { try { if (service == null) { continue; } msg += Common.NewLine + "Service: " + service.GetType(); if (sim.CreatedSim != null) { service.RemoveAssignment(sim.CreatedSim); } service.RemovePreferredSim(sim); service.mPool.Remove(sim); ResortWorker resortWorker = service as ResortWorker; if (resortWorker != null) { if (resortWorker.mWorkerInfo != null) { List <ObjectGuid> remove = new List <ObjectGuid>(); foreach (KeyValuePair <ObjectGuid, ResortWorker.WorkerInfo> info in resortWorker.mWorkerInfo) { if ((info.Value.CurrentSimDescriptionID == sim.SimDescriptionId) || (info.Value.DesiredSimDescriptionID == sim.SimDescriptionId)) { remove.Add(info.Key); } } foreach (ObjectGuid rem in remove) { resortWorker.mWorkerInfo[rem] = new ResortWorker.WorkerInfo(); } } } } catch (Exception e) { Common.Exception(sim, null, msg, e); } } msg += Common.NewLine + "A"; List <Household> houses = new List <Household>(); if (house != null) { houses.Add(house); } foreach (Household check in Household.sHouseholdList) { if (check == house) { continue; } if (check.Contains(sim)) { houses.Add(check); } } foreach (Household remove in houses) { Household.HouseholdSimsChangedCallback changedCallback = null; try { changedCallback = remove.HouseholdSimsChanged; remove.HouseholdSimsChanged = null; remove.Remove(sim, !remove.IsSpecialHousehold); } finally { remove.HouseholdSimsChanged = changedCallback; } } msg += Common.NewLine + "B"; try { if (cleanse) { if (sim.LifeEventManager != null) { sim.LifeEventManager.Purge(); } } } catch (Exception e) { Common.Exception(sim, null, msg, e); } msg += Common.NewLine + "C"; RemoveSimDescriptionRelationships(sim); msg += Common.NewLine + "D"; PetPoolManager.RemoveIdFromPool(sim.SimDescriptionId); msg += Common.NewLine + "E"; try { if (sim.CareerManager != null) { sim.CareerManager.LeaveAllJobs(Career.LeaveJobReason.kDied); } } catch (Exception e) { sim.CareerManager.mJob = null; sim.CareerManager.mSchool = null; Common.Exception(sim, null, msg, e); } msg += Common.NewLine + "F"; if (sim.CASGenealogy == null) { // Necessary to stop an error in MidLifeCrisisManager sim.mGenealogy = new Genealogy(sim); } msg += Common.NewLine + "G"; try { if (sim.Partner != null) { sim.Partner.Partner = null; } sim.Partner = null; } catch (Exception e) { Common.Exception(sim, null, msg, e); } msg += Common.NewLine + "H"; if (sim.DeathStyle != SimDescription.DeathType.None) { // Passing in a household can invoke the social worker, so don't bother Urnstone.FinalizeSimDeath(sim, null /*house*/); } msg += Common.NewLine + "I"; Urnstone urnstone = Urnstones.FindGhostsGrave(sim); msg += Common.NewLine + "J"; if ((cleanse) && (urnstone != null)) { if (urnstone.InInventory) { Inventory inventory = Inventories.ParentInventory(urnstone); if (inventory != null) { inventory.RemoveByForce(urnstone); } } if (urnstone.DeadSimsDescription != null) { urnstone.DeadSimsDescription.Fixup(); } try { urnstone.Dispose(); } catch (Exception e) { Common.DebugException(sim, null, msg, e); } urnstone.Destroy(); } msg += Common.NewLine + "K"; if ((FakeMetaAutonomy.Instance != null) && (FakeMetaAutonomy.Instance.mPool != null)) { FakeMetaAutonomy.Instance.mPool.Remove(sim); } msg += Common.NewLine + "L"; if (Sims3.Gameplay.Services.FakeMetaAutonomy.mToDestroy != null) { Sims3.Gameplay.Services.FakeMetaAutonomy.mToDestroy.Remove(sim); } msg += Common.NewLine + "M"; if ((houses.Contains(Household.ActiveHousehold)) && (sim.CreatedSim != null)) { HudModel model = HudController.Instance.Model as HudModel; foreach (SimInfo info in model.mSimList) { if (info.mGuid == sim.CreatedSim.ObjectId) { model.RemoveSimInfo(info); model.mSimList.Remove(info); break; } } } msg += Common.NewLine + "N"; try { if (sim.AssignedRole != null) { sim.AssignedRole.RemoveSimFromRole(); } } catch (Exception e) { Common.DebugException(sim, null, msg, e); sim.AssignedRole = null; } msg += Common.NewLine + "O1"; if ((CarNpcManager.Singleton != null) && (CarNpcManager.Singleton.NpcDriversManager != null)) { foreach (Stack <SimDescription> stack in CarNpcManager.Singleton.NpcDriversManager.mDescPools) { if (stack == null) { continue; } List <SimDescription> sims = new List <SimDescription>(); bool found = false; foreach (SimDescription stackSim in stack) { if (stackSim == sim) { found = true; } else { sims.Add(stackSim); } } if (found) { stack.Clear(); foreach (SimDescription stackSim in sims) { stack.Push(stackSim); } } } } msg += Common.NewLine + "O2"; if (cleanse) { sim.Dispose(); } msg += Common.NewLine + "P"; if ((house != null) && (createdSim != null)) { house.OnMemberChanged(sim, createdSim); } return(true); } catch (Exception e) { Common.Exception(sim, null, msg, e); if (house != null) { Household.HouseholdSimsChangedCallback changedCallback = null; try { changedCallback = house.HouseholdSimsChanged; house.HouseholdSimsChanged = null; house.Add(sim); } finally { house.HouseholdSimsChanged = changedCallback; } } return(false); } }
public override bool Test(Sim a, EquestrianCenter target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { PetPool pool; if (!PetPoolManager.TryGetPetPool(PetPoolType.BuySellHorse, out pool, false)) { greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(EquestrianCenter.BuyHorse.LocalizeString(a.IsFemale, "PoolEmpty", new object[0x0])); return(false); } /* * if (!a.Household.CanAddSpeciesToHousehold(CASAgeGenderFlags.Horse, 0x1, true)) * { * greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(EquestrianCenter.BuyHorse.LocalizeString(a.IsFemale, "TooManyPetsInHousehold", new object[0x0])); * return false; * } */ Lot lotHome = a.LotHome; if ((lotHome != null) && lotHome.HasVirtualResidentialSlots) { greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(PetAdoption.LocalizeString(a.IsFemale, "CannotAdoptHorse", new object[0])); return(false); } return(true); }