public static bool GhostSpawn(Urnstone me, Lot lot) { if (me.DeadSimsDescription == null) { return(false); } if (!me.DeadSimsDescription.IsValidDescription) { me.DeadSimsDescription.Fixup(); } Vector3 position; if (me.DeadSimsDescription.ToddlerOrBelow) { position = lot.EntryPoint(); } else if (!me.InInventory) { position = me.Position; } else { position = Service.GetPositionInRandomLot(lot); } Household.NpcHousehold.Add(me.DeadSimsDescription); Sim sim = Instantiation.Perform(me.DeadSimsDescription, position, null, null); sim.SetOpacity(0f, 0f); ActiveTopic.AddToSim(sim, "Ghost"); me.GhostSetup(sim, true); if (!me.InInventory) { sim.GreetSimOnLot(me.LotCurrent); Audio.StartObjectSound(me.ObjectId, "sting_ghost_appear", false); } sim.FadeIn(); me.CreateAlarmReturnToGrave(false); return(true); }
public static Sim Perform(SimDescription ths, Lot lot, OnReset reset) { Vector3 result = Vector3.Invalid; if (lot != null) { result = AttemptToFindSafeLocation(lot, ths.IsHorse); if (result == Vector3.Invalid) { result = lot.EntryPoint(); } } else { result = GetPositionInRandomLot(lot); } return(Perform(ths, result, null, reset)); }
public static Vector3 AttemptToFindSafeLocation(Lot lot, bool isHorse) { if (lot == null) { return(Vector3.Invalid); } if (isHorse) { Mailbox mailbox = lot.FindMailbox(); if (mailbox != null) { return(mailbox.Position); } else { Door frontDoor = lot.FindFrontDoor(); if (frontDoor != null) { int roomId = frontDoor.GetRoomIdOfDoorSide(CommonDoor.tSide.Front); if (roomId != 0) { roomId = frontDoor.GetRoomIdOfDoorSide(CommonDoor.tSide.Back); } if (roomId == 0) { List <GameObject> objects = lot.GetObjectsInRoom <GameObject>(roomId); if (objects.Count > 0) { return(RandomUtil.GetRandomObjectFromList(objects).Position); } } } } } return(lot.EntryPoint()); }
public static Sim Perform(SimDescription ths, Lot lot, OnReset reset) { Vector3 result = Vector3.Invalid; if (lot != null) { result = AttemptToFindSafeLocation(lot, ths.IsHorse); if (result == Vector3.Invalid) { result = lot.EntryPoint(); } } else { result = GetPositionInRandomLot(lot); } return Perform(ths, result, null, reset); }
public static Vector3 AttemptToFindSafeLocation(Lot lot, bool isHorse) { if (lot == null) return Vector3.Invalid; if (isHorse) { Mailbox mailbox = lot.FindMailbox(); if (mailbox != null) { return mailbox.Position; } else { Door frontDoor = lot.FindFrontDoor(); if (frontDoor != null) { int roomId = frontDoor.GetRoomIdOfDoorSide(CommonDoor.tSide.Front); if (roomId != 0) { roomId = frontDoor.GetRoomIdOfDoorSide(CommonDoor.tSide.Back); } if (roomId == 0) { List<GameObject> objects = lot.GetObjectsInRoom<GameObject>(roomId); if (objects.Count > 0) { return RandomUtil.GetRandomObjectFromList(objects).Position; } } } } } return lot.EntryPoint(); }
protected override OptionResult Run(GameHitParameters <GameObject> parameters) { Lot lot = Porter.GetLot(parameters.mTarget); if (lot == null) { return(OptionResult.Failure); } List <SimDescription> selection = null; List <HouseholdItem> allHouses = new List <HouseholdItem>(); foreach (Household house in Household.sHouseholdList) { allHouses.Add(new HouseholdItem(house, house == lot.Household)); } string houseName = null; while (selection == null) { List <Household> houses = HouseholdSelection.Perform(lot.Household.Name, allHouses); if ((houses == null) || (houses.Count == 0)) { return(OptionResult.Failure); } houseName = houses[0].Name; selection = GetSimSelection(houses); } if ((selection == null) || (selection.Count == 0)) { return(OptionResult.Failure); } Dictionary <Household, int> finalHouses = new Dictionary <Household, int>(); int nextID = 1; foreach (SimDescription sim in selection) { if (sim.Household == null) { continue; } if (sim.Household.IsServiceNpcHousehold) { continue; } if (!finalHouses.ContainsKey(sim.Household)) { finalHouses.Add(sim.Household, nextID); nextID++; } } string name = StringInputDialog.Show(Common.Localize("Title"), Common.Localize("Pack:NamePrompt", false, new object[] { finalHouses.Count, selection.Count }), houseName); if (string.IsNullOrEmpty(name)) { return(OptionResult.Failure); } Household export = Household.Create(); SpeedTrap.Sleep(); foreach (Household house in finalHouses.Keys) { if (house.LotHome != null) { export.SetFamilyFunds(export.FamilyFunds + house.FamilyFunds + house.LotHome.Cost); } else { export.SetFamilyFunds(export.FamilyFunds + house.NetWorth()); } } Dictionary <SimDescription, Household> saveHouses = new Dictionary <SimDescription, Household>(); Dictionary <Sim, bool> resetDNP = new Dictionary <Sim, bool>(); Dictionary <Household, bool> inventoried = new Dictionary <Household, bool>(); foreach (SimDescription sim in selection) { if (sim.CreatedSim != null) { sim.CreatedSim.SetReservedVehicle(null); if (sim.CreatedSim.DreamsAndPromisesManager != null) { sim.CreatedSim.NullDnPManager(); if (!resetDNP.ContainsKey(sim.CreatedSim)) { resetDNP.Add(sim.CreatedSim, true); } } if ((sim.Household != null) && (!inventoried.ContainsKey(sim.Household))) { inventoried.Add(sim.Household, true); if ((sim.Household.SharedFamilyInventory != null) && (sim.Household.SharedFamilyInventory.Inventory != null)) { foreach (GameObject obj in Inventories.QuickFind <GameObject>(sim.Household.SharedFamilyInventory.Inventory)) { if (Inventories.TryToMove(obj, sim.CreatedSim.Inventory, false)) { continue; } Inventories.TryToMove(obj.Clone(), export.SharedFamilyInventory.Inventory); } } if ((sim.Household.SharedFridgeInventory != null) && (sim.Household.SharedFridgeInventory.Inventory != null)) { foreach (GameObject obj in Inventories.QuickFind <GameObject>(sim.Household.SharedFridgeInventory.Inventory)) { if (Inventories.TryToMove(obj, sim.CreatedSim.Inventory, false)) { continue; } Inventories.TryToMove(obj.Clone(), export.SharedFridgeInventory.Inventory); } } } } int id = 0; if ((sim.Household != null) && (finalHouses.ContainsKey(sim.Household))) { id = finalHouses[sim.Household]; } else { Urnstone grave = Urnstones.CreateGrave(sim, false); if (grave == null) { continue; } SpeedTrap.Sleep(); bool success = false; try { success = Urnstones.GhostToPlayableGhost(grave, Household.NpcHousehold, lot.EntryPoint()); } catch (Exception exception) { Common.DebugException(grave.DeadSimsDescription, exception); } if (!success) { Porter.Notify(Common.Localize("Pack:SimFailure", sim.IsFemale, new object[] { sim })); Porter.PlaceGraveTask.Perform(sim); //export.SharedFamilyInventory.Inventory.TryToMove(grave); continue; } } HouseData data = new HouseData(id, sim); sim.mBio = data.ToString(); saveHouses.Add(sim, sim.Household); sim.OnHouseholdChanged(export, false); export.mMembers.Add(sim, null); Porter.AddExport(sim); } string packageName = null; try { try { ProgressDialog.Show(Responder.Instance.LocalizationModel.LocalizeString("Ui/Caption/Global:Processing", new object[0x0]), false); if (export.mMembers.Count > 0) { export.Name = "NRaas.Porter:" + name; ThumbnailHelper.CacheSimAtlasesForHousehold(export); ThumbnailManager.GenerateHouseholdThumbnail(export.HouseholdId, export.HouseholdId, ThumbnailSizeMask.Large); packageName = BinEx.ExportHousehold(Bin.Singleton, export, false); if (packageName != null) { BinModel.Singleton.AddToExportBin(packageName); } } foreach (Sim sim in resetDNP.Keys) { try { sim.ResetDnP(); } catch (Exception e) { Common.DebugException(sim, e); } } List <Urnstone> graves = Inventories.QuickFind <Urnstone>(export.SharedFamilyInventory.Inventory); foreach (Urnstone grave in graves) { Porter.PlaceGraveTask.Perform(grave.DeadSimsDescription); } while (export.mMembers.Count > 0) { SimDescription sim = export.mMembers.SimDescriptionList[0]; if (sim != null) { sim.OnHouseholdChanged(saveHouses[sim], false); if ((sim.Household == null) || (sim.Household.IsServiceNpcHousehold)) { Porter.PlaceGraveTask.Perform(sim); } } export.mMembers.RemoveAt(0); } export.Destroy(); export.Dispose(); } finally { ProgressDialog.Close(); } } catch (ExecutionEngineException) { // Ignored } catch (Exception e) { Common.Exception(name, e); packageName = null; } if (packageName != null) { SimpleMessageDialog.Show(Common.Localize("Title"), Common.Localize("Pack:Success", false, new object[] { export.Name })); } else { SimpleMessageDialog.Show(Common.Localize("Title"), Common.Localize("Pack:Failure")); } return(OptionResult.SuccessClose); }
public static Vector3 get_non_world_lot_pos(Sim actor_obj = null, Sim target_obj = null, bool safe = true) { bool is_t_null = false; if (target_obj == null) { is_t_null = true; target_obj = actor_obj; } if (target_obj != null) { var lotC = target_obj.LotCurrent; Lot lotHome; if (lotC != null) { if (lotC.IsWorldLot) { lotHome = target_obj.LotHome; if (lotHome != null && !(lotHome is WorldLot)) { return(lotHome.EntryPoint()); } } else { return(target_obj.Position); } } if (is_t_null) { actor_obj = null; } var other_obj = actor_obj ?? NFinalizeDeath.ActiveActor_AAndChildAndTeen;// ?? NFinalizeDeath.GetRandomSim(); if (other_obj != null) { lotC = other_obj.LotCurrent; if (lotC != null) { if (lotC.IsWorldLot) { lotHome = other_obj.LotHome; if (lotHome != null && !(lotHome is WorldLot)) { return(lotHome.EntryPoint()); } } else { var other_obj_pos = NFinalizeDeath.GetPositionBase (other_obj.ObjectId.mValue); other_obj_pos += (NFinalizeDeath.Random_CoinFlip() ? 1.8f : 2.7f) * NFinalizeDeath.GetForwardBase(other_obj.ObjectId.mValue); if (!(GetPostionTargetLot(other_obj_pos) is WorldLot)) { return(other_obj_pos); } } } } } var t = GetCameraTargetLot(); if (t is WorldLot) { var lots = LotManager.sLots; if (lots != null && lots.Count > 0) { foreach (var item in lots) { Lot item_lot = item.value; if (item_lot == null || item_lot.IsWorldLot) { continue; } return(item_lot.EntryPoint()); } } if (!safe) { var p = ScriptCore.CameraController.Camera_GetTarget(); if (NFinalizeDeath.Vector3_IsUnsafe(p)) { return(snwlot_return_failed); } else { return(p); } } else { return(snwlot_return_failed); } } else { return(t.EntryPoint()); } }
protected static void ResetStuckSim(Sim sim, Vector3 destination, string suffix, bool deep = false) { if (sim != null && !sim.HasBeenDestroyed && sim.SimDescription != null) { //Alive.WriteLog("sim_is_stuck:reset_sim_in_progress:sim:"+sim.Name+";destination:"+destination); Lot lot = null; if (sim.SimDescription.IsBonehilda) { lot = BonehildaCoffin.FindBonehildaCoffin(sim)?.LotCurrent; if (lot == null) { lot = sim.LotHome; } } else { lot = sim.LotHome; } if (lot == null) { lot = sim.VirtualLotHome; } if (lot == null) { lot = Sim.ActiveActor?.LotHome; } bool addToWorld = (true); Vector3 resetRawDest = destination; StuckSims.TryGetValue(sim.SimDescription.SimDescriptionId, out StuckSimData stuckSim); if (stuckSim != null) { //------------------------- if (stuckSim.Detections <= 2) { Daycare daycare; if ((sim.Household == null || (!sim.Household.InWorld && !sim.Household.IsSpecialHousehold)) && (!Passport.IsHostedPassportSim(sim) && sim.SimDescription.AssignedRole == null) && (LunarCycleManager.sFullMoonZombies == null || !LunarCycleManager.sFullMoonZombies.Contains(sim.SimDescription)) && ((daycare = sim.SimDescription.Occupation as Daycare) == null || !daycare.IsDaycareChild(sim.SimDescription)) && !sim.SimDescription.IsBonehilda && sim.Service == null) { addToWorld = (false); } if (destination != Vector3.Invalid) { goto DestSet; } } //------------------------- if (stuckSim.Detections <= 3) { if (lot == null) { lot = RandomUtil.GetRandomObjectFromList(Sims3.Gameplay.Queries.GetObjects <Lot>()); } if (lot != null) { resetRawDest = lot.EntryPoint(); goto DestSet; } } //------------------------- if (stuckSim.Detections <= 4) { if (lot == null) { lot = RandomUtil.GetRandomObjectFromList(Sims3.Gameplay.Queries.GetObjects <Lot>()); } if (lot != null) { Mailbox mailbox = lot.FindMailbox(); if (mailbox != null) { resetRawDest = mailbox.Position; goto DestSet; } } } //------------------------- if (stuckSim.Detections <= 5 || sim.SimDescription.IsBonehilda) { if (lot == null) { lot = RandomUtil.GetRandomObjectFromList(Sims3.Gameplay.Queries.GetObjects <Lot>()); } if (lot != null) { Door frontDoor = lot.FindFrontDoor(); if (frontDoor != null) { int roomId = frontDoor.GetRoomIdOfDoorSide(CommonDoor.tSide.Front); if (roomId != 0) { roomId = frontDoor.GetRoomIdOfDoorSide(CommonDoor.tSide.Back); } if (roomId == 0) { List <GameObject> objects = lot.GetObjectsInRoom <GameObject>(roomId); if (objects.Count > 0) { resetRawDest = RandomUtil.GetRandomObjectFromList(objects).Position; goto DestSet; } } } } } //------------------------- if (stuckSim.Detections <= 6) { lot = RandomUtil.GetRandomObjectFromList(Sims3.Gameplay.Queries.GetObjects <Lot>()); if (lot != null) { resetRawDest = lot.EntryPoint(); goto DestSet; } } //------------------------- if (stuckSim.Detections <= 7) { lot = RandomUtil.GetRandomObjectFromList(Sims3.Gameplay.Queries.GetObjects <Lot>()); if (lot != null) { Mailbox mailbox = lot.FindMailbox(); if (mailbox != null) { resetRawDest = mailbox.Position; goto DestSet; } } } //------------------------- if (stuckSim.Detections <= 8) { lot = RandomUtil.GetRandomObjectFromList(Sims3.Gameplay.Queries.GetObjects <Lot>()); if (lot != null) { Door frontDoor = lot.FindFrontDoor(); if (frontDoor != null) { int roomId = frontDoor.GetRoomIdOfDoorSide(CommonDoor.tSide.Front); if (roomId != 0) { roomId = frontDoor.GetRoomIdOfDoorSide(CommonDoor.tSide.Back); } if (roomId == 0) { List <GameObject> objects = lot.GetObjectsInRoom <GameObject>(roomId); if (objects.Count > 0) { resetRawDest = RandomUtil.GetRandomObjectFromList(objects).Position; goto DestSet; } } } } } //------------------------- if (stuckSim.Detections <= 9) { resetRawDest = Sim.ActiveActor.Position; stuckSim.Detections = (1); goto DestSet; } //------------------------- DestSet : {} } Vector3 resetValidatedDest; Vector3 forward = sim.ForwardVector; if (sim.SimDescription.IsHorse) { FindGoodLocationBooleans fglBooleans = FindGoodLocationBooleans.Routable | FindGoodLocationBooleans.PreferEmptyTiles | FindGoodLocationBooleans.AllowOnSlopes | //FindGoodLocationBooleans.AllowIntersectionWithPlatformWalls| //FindGoodLocationBooleans.AllowInFrontOfDoors | //FindGoodLocationBooleans.AllowOnStairTopAndBottomTiles| FindGoodLocationBooleans.AllowOffLot | FindGoodLocationBooleans.AllowOnStreets | FindGoodLocationBooleans.AllowOnBridges | FindGoodLocationBooleans.AllowOnSideWalks; if (stuckSim != null) { if (stuckSim.Detections <= 5) { if (!GlobalFunctions.FindGoodLocationNearbyOnLevel(sim, sim.Level, ref resetRawDest, ref forward, fglBooleans)) { GlobalFunctions.FindGoodLocationNearbyOnLevel(sim, sim.Level, ref resetRawDest, ref forward, FindGoodLocationBooleans.None); } } } World.FindGoodLocationParams fglParams = new World.FindGoodLocationParams(resetRawDest); fglParams.BooleanConstraints = fglBooleans; if (!GlobalFunctions.FindGoodLocation(sim, fglParams, out resetValidatedDest, out forward)) { fglParams.BooleanConstraints = FindGoodLocationBooleans.None; GlobalFunctions.FindGoodLocation(sim, fglParams, out resetValidatedDest, out forward); } } else { World.FindGoodLocationParams fglParams = new World.FindGoodLocationParams(resetRawDest); fglParams.BooleanConstraints = FindGoodLocationBooleans.Routable | FindGoodLocationBooleans.PreferEmptyTiles | FindGoodLocationBooleans.AllowOnSlopes | FindGoodLocationBooleans.AllowIntersectionWithPlatformWalls | FindGoodLocationBooleans.AllowInFrontOfDoors | FindGoodLocationBooleans.AllowOnStairTopAndBottomTiles | FindGoodLocationBooleans.AllowOffLot | FindGoodLocationBooleans.AllowOnStreets | FindGoodLocationBooleans.AllowOnBridges | FindGoodLocationBooleans.AllowOnSideWalks; if (!GlobalFunctions.FindGoodLocation(sim, fglParams, out resetValidatedDest, out forward)) { fglParams.BooleanConstraints = FindGoodLocationBooleans.None; GlobalFunctions.FindGoodLocation(sim, fglParams, out resetValidatedDest, out forward); } } if (!deep) { if (sim.InteractionQueue != null && sim.InteractionQueue.mInteractionList != null) { InteractionInstance currentInteraction; if ((currentInteraction = sim.InteractionQueue.GetCurrentInteraction()) != null) { // sim.InteractionQueue.CancelInteraction(currentInteraction.Id, ExitReason.CanceledByScript); } } } sim.SetPosition(resetValidatedDest); sim.SetForward(forward); sim.RemoveFromWorld(); if (addToWorld || deep) { if (!deep) { try{ sim.Posture?.CancelPosture(sim); }catch (Exception exception) { Alive.WriteLog(exception.Message + "\n\n" + exception.StackTrace + "\n\n" + exception.Source); } } sim.AddToWorld(); sim.SetHiddenFlags(HiddenFlags.Nothing); sim.SetOpacity(1f, 0f); } else { sim.SetHiddenFlags(HiddenFlags.Everything); sim.SetOpacity(0f, 0f); } sim.SimRoutingComponent?.ForceUpdateDynamicFootprint(); if (stuckSim != null) { stuckSim.Resetting = (false); // Pode detectar novos eventos Stuck } } }
public static bool GhostSpawn(Urnstone me, Lot lot) { if (me.DeadSimsDescription == null) { return false; } if (!me.DeadSimsDescription.IsValidDescription) { me.DeadSimsDescription.Fixup(); } Vector3 position; if (me.DeadSimsDescription.ToddlerOrBelow) { position = lot.EntryPoint(); } else if (!me.InInventory) { position = me.Position; } else { position = Service.GetPositionInRandomLot(lot); } Household.NpcHousehold.Add(me.DeadSimsDescription); Sim sim = Instantiation.Perform(me.DeadSimsDescription, position, null, null); sim.SetOpacity(0f, 0f); ActiveTopic.AddToSim(sim, "Ghost"); me.GhostSetup(sim, true); if (!me.InInventory) { sim.GreetSimOnLot(me.LotCurrent); Audio.StartObjectSound(me.ObjectId, "sting_ghost_appear", false); } sim.FadeIn(); me.CreateAlarmReturnToGrave(false); return true; }