public MeteorControl(Sim actor, Sim target) : base(15, TimeUnit.Minutes) { mActor = actor; mTarget = target; Vector3 empty = Vector3.Empty; Vector3 fwd = Vector3.Empty; Jig jig = GlobalFunctions.CreateObject("MeteorImpactJig", ProductVersion.EP2, Vector3.OutOfWorld, 0x0, Vector3.UnitZ, "Sims3.Gameplay.Core.Jig", null) as Jig; FindGoodLocationBooleans booleans = FindGoodLocationBooleans.AllowOnBridges | FindGoodLocationBooleans.AllowOnSideWalks | FindGoodLocationBooleans.AllowOnStreets | FindGoodLocationBooleans.TemporaryPlacement; World.FindGoodLocationParams fglParams = new World.FindGoodLocationParams(target.PositionOnFloor); fglParams.BooleanConstraints = booleans; fglParams.PlacementCheckFunc = Sims3.Gameplay.Objects.Miscellaneous.Meteor.IsValidMeteorPosition; if (GlobalFunctions.FindGoodLocation(jig, fglParams, out empty, out fwd)) { mMeteor = GlobalFunctions.CreateObject("MeteorImpactShadow", ProductVersion.EP2, empty, 0x0, fwd, "Sims3.Gameplay.Objects.Miscellaneous.Meteor", null) as Sims3.Gameplay.Objects.Miscellaneous.Meteor; mMeteor.SetHiddenFlags(HiddenFlags.Footprint); } jig.Destroy(); if ((actor != null) && (mMeteor != null)) { mTarget.InteractionQueue.AddNext(Sims3.Gameplay.Objects.Miscellaneous.Meteor.ReactToMeteor.Singleton.CreateInstance(mMeteor, mTarget, mTarget.InheritedPriority(), false, true)); mActor.InteractionQueue.CancelAllInteractions(); Vector3 position = actor.Position; Vector3 forwardVector = actor.ForwardVector; if (GlobalFunctions.FindGoodLocationNearby(actor, ref position, ref forwardVector, Sims3.Gameplay.Objects.Miscellaneous.Meteor.kMeteorBlastZoneRadius, GlobalFunctions.FindGoodLocationStrategies.All, FindGoodLocationBooleans.None)) { InteractionInstance interaction = Terrain.GoHere.GetSingleton(actor, position).CreateInstanceWithCallbacks(Terrain.Singleton, actor, new InteractionPriority(InteractionPriorityLevel.UserDirected), true, true, null, null, OnGoHereFailure); interaction.RequestWalkStyle(Sim.WalkStyle.Run); actor.InteractionQueue.AddNext(interaction); } else { mActor.InteractionQueue.AddNext(Sims3.Gameplay.Objects.Miscellaneous.Meteor.ReactToMeteor.Singleton.CreateInstance(mMeteor, mActor, mActor.InheritedPriority(), false, true)); } } }
private bool TryPlaceJigOnLot() { Vector3 position = SimToAbduct.Position; Vector3 randomDirXZ = RandomUtil.GetRandomDirXZ(); FindGoodLocationBooleans fglBools = FindGoodLocationBooleans.Routable | FindGoodLocationBooleans.AllowOnStreets | FindGoodLocationBooleans.AllowOnSideWalks | FindGoodLocationBooleans.AllowOffLot; if (!GlobalFunctions.FindGoodLocationNearby(mJig, ref position, ref randomDirXZ, 0f, GlobalFunctions.FindGoodLocationStrategies.All, fglBools)) { return(false); } mJig.SetPosition(position); mJig.SetForward(randomDirXZ); mJig.SetOpacity(0f, 0f); mJig.AddToWorld(); return(true); }
public override bool Run() { try { Definition interactionDefinition = InteractionDefinition as Definition; if (interactionDefinition == null) { return(false); } if (Autonomous && (interactionDefinition.mUsageType == BusinessPlanning.None)) { interactionDefinition.mUsageType = (BusinessPlanning)RandomUtil.GetInt(0, 1); } IInteractionNameCanBeOverriden overriden = this; if (overriden != null) { overriden.SetInteractionName(interactionDefinition.GetAutonomousInteractionName()); UpdateCaption = true; } if (this.mRunFromInventory && Actor.Inventory.Contains(Target)) { Vector3 vector; Vector3 vector2; FindGoodLocationBooleans constraints = FindGoodLocationBooleans.Routable | FindGoodLocationBooleans.PreferEmptyTiles; World.FindGoodLocationParams fglParams = new World.FindGoodLocationParams(Actor.Position, constraints); if (!GlobalFunctions.FindGoodLocation(Target, fglParams, out vector, out vector2)) { return(false); } Actor.Inventory.TryToRemove(Target); Target.SetPosition(vector); Target.SetForward(vector2); Target.AddToWorld(); Target.SetOpacity(0f, 0f); } if (!Target.Line.WaitForTurn(this, SimQueue.WaitBehavior.Default, ~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), AcademicBusinessPlanner.kTimeToWaitInLine)) { Actor.Inventory.TryToAdd(Target); return(false); } if (!Actor.RouteToSlotAndCheckInUse(Target, Slot.RoutingSlot_0)) { Actor.Inventory.TryToAdd(Target); return(false); } StandardEntry(); Target.EnableFootprintAndPushSims(AcademicBusinessPlanner.sFootprintHash, Actor); if (this.mRunFromInventory) { Actor.PlaySoloAnimation("a2o_object_genericSwipe_x", true); Target.SetOpacityTransition(0f, 1f, 1f); } AcquireStateMachine("BusinessPlanner"); SetActor("x", Actor); SetActor("planner", Target); List <AcademicDegreeNames> namesNeeded = new List <AcademicDegreeNames>(); namesNeeded.Add(AcademicDegreeNames.Business); BeginCommodityUpdatesAccountingForAcademicPerformance(namesNeeded); Target.mCurrentBusinessPlanningType = interactionDefinition.mUsageType; mCurrentStateMachine.EnterState("x", "Enter"); if (!Target.PlannerIsOpen) { AnimateSim("Open"); Target.PlannerIsOpen = true; } float kXPIncreasePerWorking = 0f; ReactionBroadcaster broadcaster = null; if (interactionDefinition.mUsageType == BusinessPlanning.WorkOnBusinessPlan) { AnimateSim("Work"); this.mWaitTime = RandomUtil.GetFloat(kMinWorkLength, kMaxWorkLength); kXPIncreasePerWorking = AcademicBusinessPlanner.UseBusinessPlanner.kXPIncreasePerWorking; } else { AnimateSim("Practice"); this.mWaitTime = RandomUtil.GetFloat(kMinPresentationLength, kMaxPresentationLength); kXPIncreasePerWorking = kXPIncreasePerPresentation; broadcaster = new ReactionBroadcaster(Target, kPresentationBroadcastParams, new ReactionBroadcaster.BroadcastCallback(this.BroadcastCallback)); } DoTimedLoop(this.mWaitTime, ~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached)); bool flag2 = false; foreach (InteractionInstance instance in Actor.InteractionQueue.InteractionList) { if ((instance != this) && (instance is AcademicBusinessPlanner.UseBusinessPlanner)) { flag2 = true; break; } } if (!flag2 && Target.PlannerIsOpen) { AnimateSim("Close"); Target.PlannerIsOpen = false; } AnimateSim("Exit"); Target.DisableFootprint(AcademicBusinessPlanner.sFootprintHash); EndCommodityUpdates(true); StandardExit(); if (!Actor.HasExitReason(ExitReason.Canceled)) { if (interactionDefinition.mUsageType == BusinessPlanning.PresentBusinessPlan) { EventTracker.SendEvent(EventTypeId.kPresentedBusinessPlan, Actor, Target.LotCurrent); } else if (interactionDefinition.mUsageType == BusinessPlanning.WorkOnBusinessPlan) { EventTracker.SendEvent(EventTypeId.kWorkedOnBusinessPlan, Actor, Target.LotCurrent); } } if (broadcaster != null) { broadcaster.EndBroadcast(); broadcaster.Dispose(); broadcaster = null; } // Custom, removed IsUniversityWorld() check Business occupationAsCareer = Actor.OccupationAsCareer as Business; if (occupationAsCareer != null) { occupationAsCareer.UpdatePerformanceOrExperience(kXPIncreasePerWorking); } AcademicCareer occupationAsAcademicCareer = Actor.OccupationAsAcademicCareer; if (((occupationAsAcademicCareer != null) && (occupationAsAcademicCareer.DegreeInformation != null)) && (occupationAsAcademicCareer.DegreeInformation.AcademicDegreeName == AcademicDegreeNames.Business)) { occupationAsAcademicCareer.UpdatePerformanceOrExperience(kXPIncreasePerWorking); } if (!Target.PlannerIsOpen) { Actor.WaitForExitReason(2f, ~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached)); if (!Actor.Inventory.Contains(Target)) { Actor.PlaySoloAnimation("a2o_object_genericSwipe_x", true); Actor.Inventory.TryToAdd(Target); } } return(true); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); 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 } } }