public bool ___ReturnBonehildaToCoffin(BonehildaCoffin target) { if (target == null || target.mBonehildaSim == null) // custom { return(false); } InteractionQueue tInteractionQueue = target.mBonehildaSim.InteractionQueue; if (tInteractionQueue != null && !tInteractionQueue.HasInteractionOfType(BonehildaCoffin.BonehildaReturnToCoffin.Singleton)) { Sim targetsim = target.mBonehildaSim; try { tInteractionQueue.CancelAllInteractions(); } catch (Exception) { NFinalizeDeath.ForceCancelAllInteractionsWithoutCleanup(targetsim); NFinalizeDeath.ForceDestroyObject(targetsim); target.mBonehildaSim = null; return(true); } targetsim = target.mBonehildaSim; if (targetsim == null || targetsim.SimDescription == null || targetsim.HasBeenDestroyed) { target.mBonehildaSim = null; return(true); } var entry = BonehildaCoffin.BonehildaReturnToCoffin .Singleton.CreateInstance(target, targetsim, new InteractionPriority(InteractionPriorityLevel.RequiredNPCBehavior), isAutonomous: false, cancellableByPlayer: true) as BonehildaCoffin.BonehildaReturnToCoffin; tInteractionQueue.AddNext(entry); } if (tInteractionQueue == null) { target.mBonehildaSim = null; } return(true); }
public bool GardenInteractionLotValidityTest1(Sim sim) { if (sim == null) { return(false); } if (sim.LotHome != null && plant.LotCurrent.CanSimTreatAsHome(sim)) { return(true); } if (sim.SimDescription != null && sim.SimDescription.IsBonehilda) { var coffin = BonehildaCoffin.FindBonehildaCoffin(sim); if (coffin != null && coffin.LotCurrent == plant.LotCurrent) { return(true); } } return(false); }
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 } } }