protected override void OnPerform() { if ((mSim.Posture != null) && (mSim.Posture.Container != null)) { mParent = mSim.Posture.Container as GameObject; mSim.Posture = null; } TerrainInteraction instance = new Terrain.TeleportMeHere.Definition(false).CreateInstanceWithCallbacks(Terrain.Singleton, mSim, new InteractionPriority(InteractionPriorityLevel.UserDirected), false, true, null, OnCompleted, OnFailed) as TerrainInteraction; Door frontDoor = mDestination.FindFrontDoor(); if (frontDoor != null) { Vector3 forward; World.FindGoodLocationParams fglParams = new World.FindGoodLocationParams(frontDoor.Position); fglParams.BooleanConstraints |= FindGoodLocationBooleans.StayInRoom; fglParams.InitialSearchDirection = RandomUtil.GetInt(0x0, 0x7); if (GlobalFunctions.FindGoodLocation(mSim, fglParams, out instance.Destination, out forward)) { mSim.InteractionQueue.Add(instance); } } }
public static bool ExternalAllowPush(SimDescription sim, Lot lot) { if (lot != null) { bool allowed = false; if (!lot.IsResidentialLot) { List <Door> portals = lot.GetObjectsInRoom <Door>(0); foreach (Door obj in portals) { DoorPortalComponentEx.DoorSettings settings = GoHere.Settings.GetDoorSettings(obj.ObjectId, false); if (settings != null && settings.IsSimAllowedThrough(sim.SimDescriptionId)) { allowed = true; break; } } } else { Door door = lot.FindFrontDoor(); if (door != null) { DoorPortalComponentEx.DoorSettings settings = GoHere.Settings.GetDoorSettings(door.ObjectId, false); if (settings != null) { allowed = settings.IsSimAllowedThrough(sim.SimDescriptionId); } } else { allowed = true; } } if (!allowed) { return(allowed); } } if (!sStoryProgressionAllowPushToLot.Valid) { return(true); } return(sStoryProgressionAllowPushToLot.Invoke <bool>(new object[] { sim, lot })); }
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 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 bool ExternalAllowPush(SimDescription sim, Lot lot) { if (lot != null) { bool allowed = false; if (!lot.IsResidentialLot) { List<Door> portals = lot.GetObjectsInRoom<Door>(0); foreach (Door obj in portals) { DoorPortalComponentEx.DoorSettings settings = GoHere.Settings.GetDoorSettings(obj.ObjectId, false); if (settings != null && settings.IsSimAllowedThrough(sim.SimDescriptionId)) { allowed = true; break; } } } else { Door door = lot.FindFrontDoor(); if (door != null) { DoorPortalComponentEx.DoorSettings settings = GoHere.Settings.GetDoorSettings(door.ObjectId, false); if (settings != null) { allowed = settings.IsSimAllowedThrough(sim.SimDescriptionId); } } else { allowed = true; } } if (!allowed) return allowed; } if (!sStoryProgressionAllowPushToLot.Valid) return true; return sStoryProgressionAllowPushToLot.Invoke<bool>(new object[] { sim, lot }); }
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 } } }