public override bool Run() { try { Definition definition = InteractionDefinition as Definition; if (definition.mSimToIgnore == null) { return(Actor.RouteToSlotAndCheckInUse(Target, Slot.RoutingSlot_0)); } Route r = Actor.CreateRoute(); r.AddObjectToIgnoreForRoute(definition.mSimToIgnore.ObjectId); r.PlanToSlot(Target, Slot.RoutingSlot_0); return(Actor.DoRoute(r)); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); return(false); } }
public static bool DoRouteWithFollowers(SimRoutingComponent ths, Route r, List<Sim> followers, GoHereWithSituation.OnFailBehavior failBehavior, Vector3 teleportLocation) { if ((followers != null) && (followers.Count != 0)) { if (ths.OwnerSim.Autonomy.SituationComponent.InSituationOfType(typeof(GoHereWithSituation))) { return false; } bool flag = r.PlanResult.Succeeded(); if (!flag) { RidingPosture ridingPosture = ths.OwnerSim.RidingPosture; if (ridingPosture != null) { ObjectGuid objectId = ridingPosture.Mount.ObjectId; r.AddObjectToIgnoreForRoute(objectId); r.Replan(); r.RemoveObjectToIgnoreForRoute(objectId); flag = r.PlanResult.Succeeded(); } } if (flag) { InteractionInstance instance; bool flag2 = false; InteractionPriority priority = ths.OwnerSim.InheritedPriority(); // Custom InteractionInstance entry = CreateGoHereWithInteractionInstance(ths, r, followers, priority, true, out instance, failBehavior, teleportLocation); try { ths.mbAllowBikes = false; if (instance != null) { entry.InstanceActor.InteractionQueue.Add(entry); } else { instance = entry; } InteractionInstance currentInteraction = ths.OwnerSim.CurrentInteraction; currentInteraction.PartOfGoHereSituation = true; instance.GroupId = currentInteraction.GroupId; flag2 = instance.RunInteractionWithoutCleanup(); flag2 = flag2 && !entry.InstanceActor.HasExitReason(ExitReason.RouteFailed); } finally { ths.mbAllowBikes = true; instance.Cleanup(); } return flag2; } if ((ths.OwnerSim.IsInRidingPosture && (r.Follower.Target == ths.OwnerSim)) && (r.DoRouteFail && ths.mOwnerSim.CheckPlayRouteFailFrequency())) { ths.PlayRouteFailureIfAppropriate(null); return false; } } return ths.DoRoute(r); }
protected override OptionResult Run(GameHitParameters <GameObject> parameters) { Common.StringBuilder msg = new Common.StringBuilder("Run"); try { Terrain terrain = parameters.mTarget as Terrain; if (terrain != null) { foreach (Sim sim in LotManager.Actors) { Common.TestSpan span = Common.TestSpan.CreateSimple(); Route r = null; uint simFlags = sim.SimDescription.SimFlags; try { r = Route.Create(sim.Proxy, simFlags); } finally { msg += Common.NewLine + sim.FullName; msg += Common.NewLine + " " + sim.SimDescription.mSimFlags; msg += Common.NewLine + " " + span.Duration; } SimDescription simDescription = sim.SimDescription; Posture previousPosture = sim.Posture; SimRoutingComponent routingComponent = sim.RoutingComponent as SimRoutingComponent; bool flag = false; span = Common.TestSpan.CreateSimple(); try { //routingComponent.SetRouteOptions(route, simFlags); if (!(sim.CurrentInteraction is IHasCustomRouteOptions)) { r.SetOption(Route.RouteOption.BeginAsCar, (sim.Parent is Vehicle) && !(sim.Parent is IBoat)); r.SetOption(Route.RouteOption.EnablePlanningAsCar, simDescription.ChildOrAbove); r.SetOption(Route.RouteOption.DisablePlanningAsPedestrian, false); r.SetOption(Route.RouteOption.PushSimsAtDestination, true); r.SetOption(Route.RouteOption.UseAutoSlotFootprintLocking, true); r.SetOption(Route.RouteOption.ReplanToFindObstacleWhenPathPlanFails, true); r.SetOption(Route.RouteOption.IgnoreParent, false); r.SetOption(Route.RouteOption.IgnoreChildren, false); r.SetOption(Route.RouteOption.CreateSubPaths, true); r.SetOption(Route.RouteOption.CheckForFootprintsNearGoals, true); r.SetOption(Route.RouteOption.PenalizeGoalsOnDifferentLevels, true); if (GameUtils.IsInstalled(ProductVersion.EP10)) { IBoat parent = sim.Parent as IBoat; if (parent != null) { flag = true; r.Follower = parent.Proxy; r.FollowerAgeGenderSpecies = (uint)parent.GetBoatSpecies(); r.SetOption2(Route.RouteOption2.EnablePlanningAsBoat, true); r.SetOption2(Route.RouteOption2.BeginAsBoat, true); r.SetOption2(Route.RouteOption2.UseFollowerStartOrientation, true); r.SetOption(Route.RouteOption.OffsetDestinationForLongAnimals, true); r.AddObjectToIgnoreForRoute(sim.ObjectId); } bool flag2 = OccultMermaid.IsEveryOneGroupedWithMeATeenOrAboveMermaid(sim); bool flag3 = false; if (!flag2) { flag3 = ((previousPosture is CarryingChildPosture) || (previousPosture is CarryingPetPosture)) || sim.Autonomy.SituationComponent.InSituationOfType(typeof(GoHereWithSituation)); } bool flag4 = simDescription.ChildOrAbove & !(previousPosture is ScubaDiving); flag4 &= !(sim.InteractionQueue.GetHeadInteraction() is Lifeguard.GiveCPR); flag4 &= !(sim.InteractionQueue.GetHeadInteraction() is Lifeguard.FakeInjury); flag4 &= !(simDescription.CreatedByService is GrimReaper); flag4 &= !flag2 || flag3; flag4 &= !(previousPosture is BeingRiddenPosture) && !(previousPosture is RidingPosture); bool flag5 = simDescription.ChildOrAbove && simDescription.IsHuman; flag5 &= !(previousPosture is CarryingChildPosture) && !(previousPosture is CarryingPetPosture); r.SetOption(Route.RouteOption.EnableWaterPlanning, flag5); r.SetOption2(Route.RouteOption2.DestinationMustBeOnLand, !flag5); r.SetOption2(Route.RouteOption2.EnablePlanningAsBoat, (parent != null) || flag4); if (flag2 && flag5) { r.SetOption2(Route.RouteOption2.RouteAsMermaid, true); } else { r.SetOption2(Route.RouteOption2.RouteAsLifeguard, Lifeguard.ShouldUseRescueSwimWade(sim)); } } // Cut if (GameUtils.IsInstalled(ProductVersion.Undefined | ProductVersion.EP3)) { r.SetOption(Route.RouteOption.EnableSubwayPlanning, true); } if (GameUtils.IsInstalled(ProductVersion.Undefined | ProductVersion.EP5) && ((sim.IsWildAnimal || sim.IsStray) || (sim.IsUnicorn || WildHorses.IsWildHorse(sim)))) { r.SetOption2(Route.RouteOption2.EnablePlanningAsBoat, false); r.SetOption2(Route.RouteOption2.DestinationMustBeOnLand, true); } if (routingComponent.SimSatisfiesSpecialConditions()) { r.SetOption(Route.RouteOption.PassThroughObjects, true); r.SetOption(Route.RouteOption.PassThroughWalls, true); } if (sim.HasGhostBuff && !flag) { r.SetOption(Route.RouteOption.RouteAsGhost, true); } if ((GameUtils.IsInstalled(ProductVersion.Undefined | ProductVersion.EP4) && (sim.CarryingChildPosture != null)) && (Stroller.GetStroller(sim, sim.LotCurrent) != null)) { r.SetOption(Route.RouteOption.PlanUsingStroller, true); } if (sim.IsHuman) { SwimmingInPool pool = previousPosture as SwimmingInPool; if (pool != null) { if (pool.ContainerIsOcean) { r.SetOption(Route.RouteOption.EnableWaterPlanning, true); } } else { Ocean.PondAndOceanRoutingPosture posture2 = previousPosture as Ocean.PondAndOceanRoutingPosture; if ((posture2 != null) && (posture2.WalkStyleToUse == Sim.WalkStyle.Wade)) { r.SetOption(Route.RouteOption.EnableWaterPlanning, true); } } } // Cut if (GameUtils.IsInstalled(ProductVersion.EP8)) { if (SimEx.GetOwnedAndUsableVehicle(sim, sim.LotHome, false, false, false, true) is CarUFO) { r.SetOption(Route.RouteOption.EnableUFOPlanning, true); } if ((sim.IsHuman && sim.SimDescription.ChildOrAbove) && PondManager.ArePondsFrozen()) { bool flag6 = true; while (previousPosture != null) { if (previousPosture.Satisfaction(CommodityKind.Standing, null) <= 0f) { flag6 = false; break; } previousPosture = previousPosture.PreviousPosture; } if (flag6) { r.SetOption(Route.RouteOption.EnablePondPlanning, true); } } } } } finally { msg += Common.NewLine + " B " + span.Duration; } span = Common.TestSpan.CreateSimple(); try { if (!(sim.CurrentInteraction is IHasCustomRouteOptions)) { r.ExitReasonsInterrupt = unchecked ((int)0xffa9bfff); if ((0x0 != (simFlags & 0x3)) && !sim.LotCurrent.IsWorldLot) { r.SetValidRooms(sim.LotCurrent.LotId, null); } if ((sim.IsHorse && sim.SimDescription.AdultOrAbove) && !sim.SimDescription.IsGhost) { r.SetOption(Route.RouteOption.RouteAsLargeAnimal, true); } if (((sim.IsHorse || sim.IsDeer) || (sim.IsFullSizeDog && sim.SimDescription.AdultOrAbove)) && !sim.SimDescription.IsGhost) { r.SetOption(Route.RouteOption.OffsetDestinationForLongAnimals, true); } if (sim.IsHorse && sim.IsInBeingRiddenPosture) { r.SetOption(Route.RouteOption.RouteWhileMounted, true); } if (previousPosture is LeadingHorsePosture) { r.SetOption(Route.RouteOption.EnablePlanningAsCar, false); r.SetOption(Route.RouteOption.RouteAsLargeAnimal, true); r.SetOption(Route.RouteOption.RouteAsSimLeadingHorse, true); } if (sim.IsPet && !sim.IsInBeingRiddenPosture) { r.SetOption(Route.RouteOption.IgnoreSidewalkAndLotRestrictions, true); } } //route = sim.CreateRoute(); } finally { msg += Common.NewLine + " C " + span.Duration; } } } AcademicTextBook book = parameters.mTarget as AcademicTextBook; if (book != null) { Sim a = parameters.mActor as Sim; GreyedOutTooltipCallback greyedOutTooltipCallback = null; if ((a.OccupationAsAcademicCareer != null) || !book.mRequireAcademics) { if (book.TestRockAndRead(a, false, ref greyedOutTooltipCallback)) { msg += Common.NewLine + "A"; } if (a.Inventory.Contains(parameters.mTarget) && !(a.Posture is Sim.StandingPosture)) { if (book.TestReadBook(a, false, ref greyedOutTooltipCallback)) { msg += Common.NewLine + "B"; } } if (a.GetObjectInRightHand() == parameters.mTarget) { if (book.TestReadBook(a, false, ref greyedOutTooltipCallback)) { msg += Common.NewLine + "C"; } } msg += Common.NewLine + "D"; } msg += Common.NewLine + "E"; } CommonDoor door = parameters.mTarget as CommonDoor; if (door != null) { if (door.mObjComponents != null) { msg += Common.NewLine + "Count: " + door.mObjComponents.Count; for (int i = 0x0; i < door.mObjComponents.Count; i++) { msg += Common.NewLine + door.mObjComponents[i].BaseType; if (door.mObjComponents[i].BaseType == typeof(PortalComponent)) { msg += Common.NewLine + " Found"; door.mObjComponents[i].Dispose(); door.mObjComponents.RemoveAt(i); break; } } if (door.mObjComponents.Count == 0x0) { door.mObjComponents = null; } } } HarvestPlant plant = parameters.mTarget as HarvestPlant; if (plant != null) { msg += Common.NewLine + "mBarren: " + plant.mBarren; msg += Common.NewLine + "mGrowthState: " + plant.mGrowthState; msg += Common.NewLine + "mDormant: " + plant.mDormant; msg += Common.NewLine + "mLeaflessState: " + plant.mLeaflessState; msg += Common.NewLine + "mLifetimeHarvestablesYielded: " + plant.mLifetimeHarvestablesYielded; msg += Common.NewLine + "NumLifetimeHarvestables: " + plant.PlantDef.NumLifetimeHarvestables; msg += Common.NewLine + "Yield: " + plant.GetYield(); } } catch (Exception e) { GameHitParameters <GameObject> .Exception(parameters, msg, e); } finally { Common.DebugWriteLog(msg); } return(OptionResult.SuccessClose); }
public static bool DoRouteWithFollowers(SimRoutingComponent ths, Route r, List <Sim> followers, GoHereWithSituation.OnFailBehavior failBehavior, Vector3 teleportLocation) { if ((followers != null) && (followers.Count != 0)) { if (ths.OwnerSim.Autonomy.SituationComponent.InSituationOfType(typeof(GoHereWithSituation))) { return(false); } bool flag = r.PlanResult.Succeeded(); if (!flag) { RidingPosture ridingPosture = ths.OwnerSim.RidingPosture; if (ridingPosture != null) { ObjectGuid objectId = ridingPosture.Mount.ObjectId; r.AddObjectToIgnoreForRoute(objectId); r.Replan(); r.RemoveObjectToIgnoreForRoute(objectId); flag = r.PlanResult.Succeeded(); } } if (flag) { InteractionInstance instance; bool flag2 = false; InteractionPriority priority = ths.OwnerSim.InheritedPriority(); // Custom InteractionInstance entry = CreateGoHereWithInteractionInstance(ths, r, followers, priority, true, out instance, failBehavior, teleportLocation); try { ths.mbAllowBikes = false; if (instance != null) { entry.InstanceActor.InteractionQueue.Add(entry); } else { instance = entry; } InteractionInstance currentInteraction = ths.OwnerSim.CurrentInteraction; currentInteraction.PartOfGoHereSituation = true; instance.GroupId = currentInteraction.GroupId; flag2 = instance.RunInteractionWithoutCleanup(); flag2 = flag2 && !entry.InstanceActor.HasExitReason(ExitReason.RouteFailed); } finally { ths.mbAllowBikes = true; instance.Cleanup(); } return(flag2); } if ((ths.OwnerSim.IsInRidingPosture && (r.Follower.Target == ths.OwnerSim)) && (r.DoRouteFail && ths.mOwnerSim.CheckPlayRouteFailFrequency())) { ths.PlayRouteFailureIfAppropriate(null); return(false); } } return(ths.DoRoute(r)); }
private static void Reroute(Route r, IStation closest, IStation destination) { Sim target = r.Follower.Target as Sim; Vector3 currentStartPoint = r.GetCurrentStartPoint(); float distanceRemaining = r.GetDistanceRemaining(); Route route = target.CreateRoute(); route.SetOption(Route.RouteOption.EnableSubwayPlanning, false); route.SetOption2(Route.RouteOption2.EnableHoverTrainPlanning, false); route.SetOption(Route.RouteOption.EnablePlanningAsCar, r.GetOption(Route.RouteOption.EnablePlanningAsCar)); route.SetOption(Route.RouteOption.PlanUsingStroller, r.GetOption(Route.RouteOption.PlanUsingStroller)); route.SetOption(Route.RouteOption.ReplanUsingStroller, r.GetOption(Route.RouteOption.ReplanUsingStroller)); route.SetOption(Route.RouteOption.BeginAsStroller, r.GetOption(Route.RouteOption.BeginAsStroller)); Slot routeEnterEndSlot = closest.RouteEnterEndSlot; if (routeEnterEndSlot != Slot.None) { GameObject routingSlotEnterFootprint = closest.RoutingSlotEnterFootprint; if (routingSlotEnterFootprint != null) { route.AddObjectToIgnoreForRoute(routingSlotEnterFootprint.ObjectId); } if (route.PlanToSlot(closest, routeEnterEndSlot).Succeeded()) { Slot routeExitBeginSlot = destination.RouteExitBeginSlot; Vector3 slotPosition = destination.GetSlotPosition(routeExitBeginSlot); GameObject routingSlotExitFootprint = destination.RoutingSlotExitFootprint; if (routingSlotExitFootprint != null) { r.AddObjectToIgnoreForRoute(routingSlotExitFootprint.ObjectId); } r.SetOption(Route.RouteOption.EnableSubwayPlanning, false); r.SetOption2(Route.RouteOption2.EnableHoverTrainPlanning, false); if (!r.ReplanFromPoint(slotPosition).Succeeded()) { r.ReplanFromPoint(currentStartPoint); } else if ((route.GetDistanceRemaining() + r.GetDistanceRemaining()) < (distanceRemaining + SimRoutingComponent.kDistanceMustSaveInOrderToUseSubway)) { if (closest is IHoverTrainStation) { r.ReplanAllowed = false; Route route2 = target.CreateRoute(); PathType elevatedTrainPath = PathType.ElevatedTrainPath; List<Vector3> list = new List<Vector3>(); list.Add(closest.GetSlotPosition(closest.RouteEnterEndSlot)); list.Add(destination.GetSlotPosition(destination.RouteExitBeginSlot)); if (list.Count > 0) { route2.InsertCustomPathAtIndex(0, list.ToArray(), false, true, elevatedTrainPath); route2.ReplanAllowed = false; RoutePlanResult planResult = route2.PlanResult; planResult.mType = RoutePlanResultType.Succeeded; route2.PlanResult = planResult; PathData pathData = route2.GetPathData(0); pathData.ObjectId = destination.ObjectId; pathData.PathType = PathType.ElevatedTrainPath; route2.SetPathData(ref pathData); r.InsertRouteSubPathsAtIndex(0, route2); } } r.InsertRouteSubPathsAtIndex(0x0, route); r.SetOption(Route.RouteOption.EnableSubwayPlanning, true); r.SetOption2(Route.RouteOption2.EnableHoverTrainPlanning, true); } else { r.ReplanFromPoint(currentStartPoint); } } } }
// replaces the method from RabbitHole class - identical except for new slot reassignment code public bool RouteNearEntranceAndEnterRabbitHole(Sim a, RabbitHole.IRabbitHoleFollowers inst, RabbitHole.BeforeEnteringRabbitHoleDelegate beforeEntering, bool canUseCar, Route.RouteMetaType routeMetaType, bool playRouteFailure) { if ((Target.RabbitHoleProxy.EnterSlots.Count == 0) || (Target.RabbitHoleProxy.ExitSlots.Count == 0)) { return(false); } if (a.IsInRidingPosture && ((Target.RabbitHoleProxy.MountedEnterSlots.Count == 0) || (Target.RabbitHoleProxy.MountedExitSlots.Count == 0))) { return(false); } List <Sim> list = new List <Sim>(); CarryingChildPosture posture = a.Posture as CarryingChildPosture; if (posture != null) { list.Add(posture.Child); } if (inst != null) { if (inst.SimFollowers != null) { foreach (Sim sim in inst.SimFollowers) { posture = sim.Posture as CarryingChildPosture; if (posture != null) { list.Add(posture.Child); } } foreach (Sim sim2 in list) { inst.AddFollower(sim2); } } else if (list.Count > 0) { inst.AddFollower(list[0]); } } bool flag = false; Route item = null; Sim parent = null; if (a.IsInRidingPosture) { if (a.Parent is Sim) { parent = a.Parent as Sim; } item = parent.CreateRoute(); item.ExecutionFromNonSimTaskIsSafe = true; } else { item = a.CreateRoute(); } bool flag2 = false; int kRouteAttemptsToEnterRabbitHole = RabbitHole.kRouteAttemptsToEnterRabbitHole; Slot slotToUse = Slot.None; while ((kRouteAttemptsToEnterRabbitHole > 0) && !flag2) { kRouteAttemptsToEnterRabbitHole--; try { Target.RabbitHoleProxy.ActiveEntryRoutes.Add(item); if (playRouteFailure) { item.DoRouteFail = kRouteAttemptsToEnterRabbitHole == 0; } item.SetOption(Route.RouteOption.EnablePlanningAsCar, canUseCar); if (Target.mGuid == RabbitHoleType.Subway) { item.SetOption(Route.RouteOption.EnableSubwayPlanning, false); } if (Target.mGuid == RabbitHoleType.HoverTrainStation) { item.SetOption2(Route.RouteOption2.EnableHoverTrainPlanning, false); } item.SetRouteMetaType(routeMetaType); foreach (Slot slot2 in Target.RabbitHoleProxy.EnterSlots) { item.AddObjectToIgnoreForRoute(Target.RabbitHoleProxy.SlotToSlotInfo[slot2].Footprint.ObjectId); } foreach (Slot slot3 in Target.RabbitHoleProxy.MountedEnterSlots) { item.AddObjectToIgnoreForRoute(Target.RabbitHoleProxy.SlotToSlotInfo[slot3].Footprint.ObjectId); } item.PlanToSlot(Target.RabbitHoleProxy, (a.IsInRidingPosture ? Target.RabbitHoleProxy.MountedEnterSlots : Target.RabbitHoleProxy.EnterSlots).ToArray()); if (!item.PlanResult.Succeeded()) { item.DoRouteFail = playRouteFailure; if (a.IsInRidingPosture) { return(parent.DoRoute(item)); } return(a.DoRoute(item)); } slotToUse = (Slot)item.PlanResult.mDestSlotNameHash; // Slot Reassignment if ((Target.RabbitHoleProxy.EnterSlots.Count > 1) && (Target.RabbitHoleProxy.EnterSlots.Count <= 5)) { slotToUse = ReassignSlot(Target.RabbitHoleProxy.EnterSlots.Count); } List <Sim> followers = (inst == null) ? null : inst.SimFollowers; if ((!flag && (followers != null)) && ((followers.Count > 1) || ((followers.Count == 1) && (followers[0].Posture.Container != a)))) { //if (RouteOutside(a, followers, this.RabbitHoleProxy.EnterSlots[0x0], false, true, true, false)) if (Target.RouteOutside(a, followers, Target.RabbitHoleProxy.EnterSlots[0], false, true, true, false)) { flag = true; flag2 = true; } } else { //flag2 = RouteOutside(a, followers, none, false, true, false, false); flag2 = Target.RouteOutside(a, followers, slotToUse, false, true, false, false); } if (!flag2 && (kRouteAttemptsToEnterRabbitHole > 0)) { if (IntroTutorial.TutorialSim == a) { break; } a.RemoveExitReason(ExitReason.RouteFailed); if (a.HasExitReason(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached))) { break; } a.LoopIdle(); Simulator.Sleep((uint)SimClock.ConvertToTicks(RandomUtil.GetFloat(RabbitHole.kMinSimMinutesToSleepOnFailedRouteAttempt, RabbitHole.kMaxSimMinutesToSleepOnFailedRouteAttempt), TimeUnit.Minutes)); } continue; } finally { Target.RabbitHoleProxy.ActiveEntryRoutes.Remove(item); } } item = null; if (((a.ExitReason & ExitReason.HigherPriorityNext) == ExitReason.None) && ((a.ExitReason & ExitReason.UserCanceled) == ExitReason.None)) { if (flag2) { RabbitHole.NumSuccess++; } else { RabbitHole.NumFail++; } } if (!flag2) { return(flag2); } if ((beforeEntering != null) && !beforeEntering()) { List <Sim> simFollowers = null; if (inst != null) { simFollowers = inst.SimFollowers; } //RouteOutside(a, simFollowers, RandomUtil.GetRandomObjectFromList<Slot>(a.IsInRidingPosture ? this.RabbitHoleProxy.MountedEnterSlots : this.RabbitHoleProxy.EnterSlots), false, false, true, true); Target.RouteOutside(a, simFollowers, RandomUtil.GetRandomObjectFromList <Slot>(a.IsInRidingPosture ? Target.RabbitHoleProxy.MountedEnterSlots : Target.RabbitHoleProxy.EnterSlots), false, false, true, true); return(false); } LeadingHorsePosture posture2 = a.Posture as LeadingHorsePosture; if (posture2 != null) { Sim container = posture2.Container as Sim; LeadingHorsePosture.ReleaseHorseFromLeadingPosture(a, container, false); Target.AnimateEnterRabbitHole(a, slotToUse, true, routeMetaType); Target.AnimateEnterRabbitHole(container, slotToUse, true, routeMetaType); return(flag2); } return(Target.AnimateEnterRabbitHole(a, slotToUse, true, routeMetaType)); }
public override bool Run() { try { mLinkedActor = LinkedInteractionInstance.InstanceActor; IWooHooDefinition definition = InteractionDefinition as IWooHooDefinition; bool succeeded = true; if (mIsMaster) { Target.mRoutingSims.Add(Actor); Target.mRoutingSims.Add(mLinkedActor); } if (!mIsMaster) { bool success = false; Actor.RouteToObjectRadialRange(Target, 1.5f, 4f); while (Target.mRoutingSims.Contains(mLinkedActor)) { AncientPortalWooHoo interaction = LinkedInteractionInstance as AncientPortalWooHoo; if (interaction == null) { break; } if (mLinkedActor.HasExitReason(ExitReason.Canceled)) { break; } if (interaction.mNowWaiting) { success = true; break; } SpeedTrap.Sleep(0xa); } if (!success) { Actor.AddExitReason(ExitReason.RouteFailed); return(false); } } bool routeSuccess = false; Route r = Actor.CreateRoute(); r.AddObjectToIgnoreForRoute(mLinkedActor.ObjectId); r.PlanToSlot(Target, Target.GetRoutingSlots()); routeSuccess = Actor.DoRoute(r); if ((mIsMaster) && (routeSuccess)) { routeSuccess = !Actor.InUse; } if (!routeSuccess) { Actor.AddExitReason(ExitReason.RouteFailed); return(false); } CommonWoohoo.TestNakedOutfit(Woohooer.Settings.mNakedOutfitAncientPortal, Actor); StandardEntry(); EnterStateMachine("AncientPortal", "Enter", "x", "portal"); AddOneShotScriptEventHandler(0x65, HideSim); AddOneShotScriptEventHandler(0x66, ShowSim); AnimateSim("InsidePortal"); if (mIsMaster) { Target.RemoveFromUseList(Actor); mNowWaiting = true; RockGemMetalBase.HandleNearbyWoohoo(Actor, RockGemMetalBase.HowMuchWooHoo.MoreWoohoo); } BeginCommodityUpdates(); if (mReactToSocialBroadcaster == null) { mReactToSocialBroadcaster = new ReactionBroadcaster(Actor, Conversation.ReactToSocialParams, SocialComponentEx.ReactToJealousEventHigh); CommonWoohoo.CheckForWitnessedCheating(Actor, mLinkedActor, !Rejected); } if ((Target.BoobyTrapComponent != null) ? Target.BoobyTrapComponent.CanTriggerTrap(Actor.SimDescription) : false) { Target.TriggerTrap(Actor); } int count = 0; while (Target.mRoutingSims.Contains(mLinkedActor)) { AncientPortalWooHoo interaction = LinkedInteractionInstance as AncientPortalWooHoo; if (interaction == null) { break; } if (mLinkedActor.HasExitReason(ExitReason.Canceled)) { break; } if (!mIsMaster) { interaction.mWasSuccess = true; if (count > 30) { break; } count++; Target.SetOpacity(RandomUtil.GetFloat(0f, 1f), 0.25f); } SpeedTrap.Sleep(10); } if (!mIsMaster) { Target.SetOpacity(1f, 1f); } AnimateSim("Exit"); for (int i = 0; i < AncientPortal.CatchABeam.kPotentialTravelBuffs.Length; i++) { if (RandomUtil.RandomChance(AncientPortal.CatchABeam.kChanceForEachBuff)) { Actor.BuffManager.AddElement(AncientPortal.CatchABeam.kPotentialTravelBuffs[i], Origin.FromAncientPortal); } } if (mIsMaster) { RockGemMetalBase.HandleNearbyWoohoo(Actor, RockGemMetalBase.HowMuchWooHoo.LessWoohoo); } EndCommodityUpdates(succeeded); StandardExit(); if ((mWasSuccess) && (mIsMaster)) { CommonWoohoo.RunPostWoohoo(Actor, mLinkedActor, Target, definition.GetStyle(this), definition.GetLocation(Target), true); if (CommonPregnancy.IsSuccess(Actor, mLinkedActor, Autonomous, definition.GetStyle(this))) { CommonPregnancy.Impregnate(Actor, mLinkedActor, Autonomous, definition.GetStyle(this)); } } Actor.Wander(1f, 2f, false, RouteDistancePreference.PreferNearestToRouteOrigin, false); return(succeeded); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); return(false); } finally { Target.mRoutingSims.Remove(Actor); } }
public override bool Run() { try { if ((mWardrobe == null) || (mOtherWooHoo == null)) { return(false); } if (!mWardrobe.SimLine.WaitForTurn(this, SimQueue.WaitBehavior.Default, ~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), 10f)) { return(false); } mWardrobe.SimLine.RemoveFromQueue(Actor); OutfitCategories currentOutfitCategory = Actor.CurrentOutfitCategory; int currentOutfitIndex = Actor.CurrentOutfitIndex; Actor.RouteToObjectRadius(mWardrobe, 1.5f); while (!mOtherWooHoo.mIsInWardrobe) { if (((Target.InteractionQueue.GetCurrentInteraction() != mOtherWooHoo) || Target.HasExitReason(ExitReason.Canceled)) || Actor.HasExitReason()) { return(false); } SpeedTrap.Sleep(0xa); } Route r = Actor.CreateRoute(); r.AddObjectToIgnoreForRoute(Target.ObjectId); r.PlanToSlot(mWardrobe, Slot.RoutingSlot_0); if (!Actor.DoRoute(r)) { return(false); } mWardrobe.UpdateFootprint(true, Actor, new Sim[] { Target }); mWardrobe.AddToUseList(Actor); StandardEntry(); BeginCommodityUpdates(); mCurrentStateMachine = mOtherWooHoo.mCurrentStateMachine; SetActorAndEnter("x", Actor, "Enter"); Animate("x", "GetInX"); mIsInWardrobe = true; if (((Actor.OccultManager != null) && !Actor.OccultManager.DisallowClothesChange()) && !Actor.DoesSimHaveTransformationBuff()) { List <OutfitCategories> randomList = new List <OutfitCategories>(Wardrobe.kPossibleOutfitsAfterWooHoo); randomList.Remove(Actor.CurrentOutfitCategory); if (Woohooer.Settings.mNakedOutfitWardrobe) { randomList.Add(OutfitCategories.Naked); } Actor.SwitchToOutfitWithSpin(Sim.ClothesChangeReason.Force, RandomUtil.GetRandomObjectFromList(randomList)); } while (mOtherWooHoo.mIsInWardrobe) { if (Target.InteractionQueue.GetCurrentInteraction() != mOtherWooHoo) { Actor.SetOpacity(1f, 0f); mWardrobe.RemoveFromUseList(Actor); EndCommodityUpdates(true); StandardExit(); mWardrobe.UpdateFootprint(false, Actor, new Sim[0x0]); return(false); } SpeedTrap.Sleep(0xa); } IWooHooDefinition otherDefinition = mOtherWooHoo.InteractionDefinition as IWooHooDefinition; EventTracker.SendEvent(EventTypeId.kWoohooInWardrobe, Actor, Target); CommonWoohoo.RunPostWoohoo(Actor, Target, mWardrobe, otherDefinition.GetStyle(this), otherDefinition.GetLocation(mWardrobe), true); mWardrobe.UpdateFootprint(false, Actor, new Sim[0x0]); mWardrobe.RemoveFromUseList(Actor); EndCommodityUpdates(true); StandardExit(); return(true); } catch (ResetException) { throw; } catch (Exception exception) { Common.Exception(Actor, Target, exception); return(false); } }
private static void Reroute(Route r, IStation closest, IStation destination) { Sim target = r.Follower.Target as Sim; Vector3 currentStartPoint = r.GetCurrentStartPoint(); float distanceRemaining = r.GetDistanceRemaining(); Route route = target.CreateRoute(); route.SetOption(Route.RouteOption.EnableSubwayPlanning, false); route.SetOption2(Route.RouteOption2.EnableHoverTrainPlanning, false); route.SetOption(Route.RouteOption.EnablePlanningAsCar, r.GetOption(Route.RouteOption.EnablePlanningAsCar)); route.SetOption(Route.RouteOption.PlanUsingStroller, r.GetOption(Route.RouteOption.PlanUsingStroller)); route.SetOption(Route.RouteOption.ReplanUsingStroller, r.GetOption(Route.RouteOption.ReplanUsingStroller)); route.SetOption(Route.RouteOption.BeginAsStroller, r.GetOption(Route.RouteOption.BeginAsStroller)); Slot routeEnterEndSlot = closest.RouteEnterEndSlot; if (routeEnterEndSlot != Slot.None) { GameObject routingSlotEnterFootprint = closest.RoutingSlotEnterFootprint; if (routingSlotEnterFootprint != null) { route.AddObjectToIgnoreForRoute(routingSlotEnterFootprint.ObjectId); } if (route.PlanToSlot(closest, routeEnterEndSlot).Succeeded()) { Slot routeExitBeginSlot = destination.RouteExitBeginSlot; Vector3 slotPosition = destination.GetSlotPosition(routeExitBeginSlot); GameObject routingSlotExitFootprint = destination.RoutingSlotExitFootprint; if (routingSlotExitFootprint != null) { r.AddObjectToIgnoreForRoute(routingSlotExitFootprint.ObjectId); } r.SetOption(Route.RouteOption.EnableSubwayPlanning, false); r.SetOption2(Route.RouteOption2.EnableHoverTrainPlanning, false); if (!r.ReplanFromPoint(slotPosition).Succeeded()) { r.ReplanFromPoint(currentStartPoint); } else if ((route.GetDistanceRemaining() + r.GetDistanceRemaining()) < (distanceRemaining + SimRoutingComponent.kDistanceMustSaveInOrderToUseSubway)) { if (closest is IHoverTrainStation) { r.ReplanAllowed = false; Route route2 = target.CreateRoute(); PathType elevatedTrainPath = PathType.ElevatedTrainPath; List <Vector3> list = new List <Vector3>(); list.Add(closest.GetSlotPosition(closest.RouteEnterEndSlot)); list.Add(destination.GetSlotPosition(destination.RouteExitBeginSlot)); if (list.Count > 0) { route2.InsertCustomPathAtIndex(0, list.ToArray(), false, true, elevatedTrainPath); route2.ReplanAllowed = false; RoutePlanResult planResult = route2.PlanResult; planResult.mType = RoutePlanResultType.Succeeded; route2.PlanResult = planResult; PathData pathData = route2.GetPathData(0); pathData.ObjectId = destination.ObjectId; pathData.PathType = PathType.ElevatedTrainPath; route2.SetPathData(ref pathData); r.InsertRouteSubPathsAtIndex(0, route2); } } r.InsertRouteSubPathsAtIndex(0x0, route); r.SetOption(Route.RouteOption.EnableSubwayPlanning, true); r.SetOption2(Route.RouteOption2.EnableHoverTrainPlanning, true); } else { r.ReplanFromPoint(currentStartPoint); } } } }
public override bool Run() { try { IWooHooDefinition definition = InteractionDefinition as IWooHooDefinition; bool flag2 = false; if (mIsMaster) { flag2 = Actor.RouteToSlotAndCheckInUse(Target, Slot.RoutingSlot_1); mFail = RandomUtil.RandomChance(BoxOfMystery.kChanceToFailWooHoo); } else { Route r = Actor.CreateRoute(); r.AddObjectToIgnoreForRoute(mWooHooer.ObjectId); r.PlanToSlot(Target, Slot.RoutingSlot_1); flag2 = Actor.DoRoute(r); } if (!flag2) { Actor.AddExitReason(ExitReason.RouteFailed); return(false); } mRouteComplete = flag2; if (mIsMaster && Target.ActorsUsingMe.Contains(mWooHooee)) { return(false); } if (mIsMaster && !Actor.HasExitReason()) { mLinkedInstance = definition.ProxyClone(mWooHooer).CreateInstance(Target, mWooHooee, new InteractionPriority(InteractionPriorityLevel.UserDirected), false, true) as BoxOfMystery.WooHooInBoxOfMystery; mLinkedInstance.LinkedInteractionInstance = this; mLinkedInstance.mWooHooer = mWooHooer; mLinkedInstance.mWooHooee = mWooHooee; mLinkedInstance.mFail = mFail; mWooHooee.InteractionQueue.AddNext(mLinkedInstance); } StandardEntry(); EnterStateMachine("BoxOfMystery", "Enter", "x"); SetActor("box", Target); AnimateSim("GetInBox"); if (mIsMaster) { Actor.SetOpacity(0f, 0f); } while ((mIsMaster && !mLinkedInstance.mRouteComplete) && (!mWooHooee.HasExitReason(ExitReason.RouteFailed) && mWooHooee.InteractionQueue.HasInteraction(mLinkedInstance))) { SpeedTrap.Sleep(0x0); } if (mIsMaster && (mWooHooee.HasExitReason(ExitReason.RouteFailed) || !mWooHooee.InteractionQueue.HasInteraction(mLinkedInstance))) { Actor.SetOpacity(1f, 0f); AnimateSim("Exit"); StandardExit(); return(false); } if (mIsMaster) { List <Sim> exceptions = new List <Sim>(); exceptions.Add(mWooHooee); Target.EnableFootprintAndPushSims(BoxOfMystery.sFootprintPathingHash, Actor, exceptions, false); } if (!StartSync(mIsMaster)) { if (mIsMaster) { if (LinkedInteractionInstance != null) { LinkedInteractionInstance.InstanceActor.AddExitReason(ExitReason.CanceledByScript); Actor.AddExitReason(ExitReason.CanceledByScript); } do { SpeedTrap.Sleep(0xa); }while (Target.UseCount > 0x1); } } else { if (mIsMaster) { mLinkedInstance.mAnimating = true; } Actor.SetOpacity(0f, 0f); BeginCommodityUpdates(); if (!mIsMaster) { while (mAnimating) { SpeedTrap.Sleep(0x1); } } else { AnimateSim("TryForWooHoo"); mLinkedInstance.mAnimating = false; } EndCommodityUpdates(true); if (mIsMaster) { CommonWoohoo.RunPostWoohoo(Actor, mWooHooee, Target, definition.GetStyle(this), definition.GetLocation(Target), true); if (CommonPregnancy.IsSuccess(Actor, mWooHooee, Autonomous, definition.GetStyle(this))) { CommonPregnancy.Impregnate(Actor, mWooHooee, Autonomous, definition.GetStyle(this)); } if (mFail) { Actor.SetOpacity(1f, 0f); AnimateSim("FailExit"); Route route2 = Actor.CreateRouteTurnToFace(Target.Position); route2.AddObjectToIgnoreForRoute(mWooHooee.ObjectId); Actor.DoRoute(route2); AnimateSim("Panic"); Actor.RouteAway(1f, 3f, false, GetPriority(), Autonomous, false, true, RouteDistancePreference.PreferNearestToRouteOrigin); } else { do { SpeedTrap.Sleep(0xa); }while (Target.UseCount > 0x1); } } else if (mFail) { do { SpeedTrap.Sleep(0xa); }while (Target.UseCount > 0x1); Actor.SetOpacity(1f, 0f); AnimateSim("SuprisedExit"); } } Actor.SetOpacity(1f, 0f); AnimateSim("Exit"); StandardExit(); if (!mIsMaster) { Actor.RouteAway(1f, 3f, false, GetPriority(), Autonomous, false, true, RouteDistancePreference.PreferNearestToRouteOrigin); } return(true); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); return(false); } }
public static void SetRouteOptions(SimRoutingComponent ths, Route r, uint ageGenderFlags) { SimDescription simDescription = ths.OwnerSim.SimDescription; Posture previousPosture = ths.OwnerSim.Posture; if (!(ths.OwnerSim.CurrentInteraction is IHasCustomRouteOptions)) { r.SetOption(Route.RouteOption.BeginAsCar, (ths.OwnerSim.Parent is Vehicle) && !(ths.OwnerSim.Parent is IBoat)); r.SetOption(Route.RouteOption.EnablePlanningAsCar, simDescription.ChildOrAbove); r.SetOption(Route.RouteOption.DisablePlanningAsPedestrian, false); r.SetOption(Route.RouteOption.PushSimsAtDestination, true); r.SetOption(Route.RouteOption.UseAutoSlotFootprintLocking, true); r.SetOption(Route.RouteOption.ReplanToFindObstacleWhenPathPlanFails, true); r.SetOption(Route.RouteOption.IgnoreParent, false); r.SetOption(Route.RouteOption.IgnoreChildren, false); r.SetOption(Route.RouteOption.CreateSubPaths, true); r.SetOption(Route.RouteOption.CheckForFootprintsNearGoals, true); r.SetOption(Route.RouteOption.PenalizeGoalsOnDifferentLevels, true); bool flag = false; if (GameUtils.IsInstalled(ProductVersion.EP10)) { IBoat parent = ths.OwnerSim.Parent as IBoat; if (parent != null) { flag = true; r.Follower = parent.Proxy; r.FollowerAgeGenderSpecies = (uint)parent.GetBoatSpecies(); r.SetOption2(Route.RouteOption2.EnablePlanningAsBoat, true); r.SetOption2(Route.RouteOption2.BeginAsBoat, true); r.SetOption2(Route.RouteOption2.UseFollowerStartOrientation, true); r.SetOption(Route.RouteOption.OffsetDestinationForLongAnimals, true); r.AddObjectToIgnoreForRoute(ths.OwnerSim.ObjectId); } bool flag2 = OccultMermaid.IsEveryOneGroupedWithMeATeenOrAboveMermaid(ths.OwnerSim); bool flag3 = false; if (!flag2) { flag3 = ((previousPosture is CarryingChildPosture) || (previousPosture is CarryingPetPosture)) || ths.OwnerSim.Autonomy.SituationComponent.InSituationOfType(typeof(GoHereWithSituation)); } bool flag4 = simDescription.ChildOrAbove & !(previousPosture is ScubaDiving); flag4 &= !(ths.OwnerSim.InteractionQueue.GetHeadInteraction() is Lifeguard.GiveCPR); flag4 &= !(ths.OwnerSim.InteractionQueue.GetHeadInteraction() is Lifeguard.FakeInjury); flag4 &= !(simDescription.CreatedByService is GrimReaper); flag4 &= !flag2 || flag3; flag4 &= !(previousPosture is BeingRiddenPosture) && !(previousPosture is RidingPosture); bool flag5 = simDescription.ChildOrAbove && simDescription.IsHuman; flag5 &= !(previousPosture is CarryingChildPosture) && !(previousPosture is CarryingPetPosture); r.SetOption(Route.RouteOption.EnableWaterPlanning, flag5); r.SetOption2(Route.RouteOption2.DestinationMustBeOnLand, !flag5); r.SetOption2(Route.RouteOption2.EnablePlanningAsBoat, (parent != null) || flag4); if (flag2 && flag5) { r.SetOption2(Route.RouteOption2.RouteAsMermaid, true); } else { r.SetOption2(Route.RouteOption2.RouteAsLifeguard, Lifeguard.ShouldUseRescueSwimWade(ths.OwnerSim)); } } if (GameUtils.IsInstalled(ProductVersion.EP3)) { r.SetOption(Route.RouteOption.EnableSubwayPlanning, true); } if (GameUtils.IsInstalled(ProductVersion.EP11)) /*&& GameUtils.IsFutureWorld())*/ { r.SetOption2(Route.RouteOption2.EnableHoverTrainPlanning, true); } if (GameUtils.IsInstalled(ProductVersion.EP5) && ((ths.OwnerSim.IsWildAnimal || ths.OwnerSim.IsStray) || (ths.OwnerSim.IsUnicorn || WildHorses.IsWildHorse(ths.OwnerSim)))) { r.SetOption2(Route.RouteOption2.EnablePlanningAsBoat, false); r.SetOption2(Route.RouteOption2.DestinationMustBeOnLand, true); } if (ths.SimSatisfiesSpecialConditions()) { r.SetOption(Route.RouteOption.PassThroughObjects, true); r.SetOption(Route.RouteOption.PassThroughWalls, true); } if (ths.OwnerSim.HasGhostBuff && !flag) { r.SetOption(Route.RouteOption.RouteAsGhost, true); } if ((GameUtils.IsInstalled(ProductVersion.EP4) && (ths.OwnerSim.CarryingChildPosture != null)) && (Stroller.GetStroller(ths.OwnerSim, ths.OwnerSim.LotCurrent) != null)) { r.SetOption(Route.RouteOption.PlanUsingStroller, true); } if (ths.OwnerSim.IsHuman) { SwimmingInPool pool = previousPosture as SwimmingInPool; if (pool != null) { if (pool.ContainerIsOcean) { r.SetOption(Route.RouteOption.EnableWaterPlanning, true); } } else { Ocean.PondAndOceanRoutingPosture posture2 = previousPosture as Ocean.PondAndOceanRoutingPosture; if ((posture2 != null) && (posture2.WalkStyleToUse == Sim.WalkStyle.Wade)) { r.SetOption(Route.RouteOption.EnableWaterPlanning, true); } } } if (GameUtils.IsInstalled(ProductVersion.EP8)) { // Custom if (SimEx.GetOwnedAndUsableVehicle(ths.OwnerSim, ths.OwnerSim.LotHome, false, false, false, true) is CarUFO) //if (OwnerSim.GetOwnedAndUsableVehicle(OwnerSim.LotHome, false, false, false, true) is CarUFO) { r.SetOption(Route.RouteOption.EnableUFOPlanning, true); } if ((ths.OwnerSim.IsHuman && ths.OwnerSim.SimDescription.ChildOrAbove) && PondManager.ArePondsFrozen()) { bool flag6 = true; while (previousPosture != null) { if (previousPosture.Satisfaction(CommodityKind.Standing, null) <= 0f) { flag6 = false; break; } previousPosture = previousPosture.PreviousPosture; } if (flag6) { r.SetOption(Route.RouteOption.EnablePondPlanning, true); } } } r.ExitReasonsInterrupt = unchecked((int)0xffa9bfff); if ((0x0 != (ageGenderFlags & 0x3)) && !ths.OwnerSim.LotCurrent.IsWorldLot) { r.SetValidRooms(ths.OwnerSim.LotCurrent.LotId, null); } if ((ths.OwnerSim.IsHorse && ths.OwnerSim.SimDescription.AdultOrAbove) && !ths.OwnerSim.SimDescription.IsGhost) { r.SetOption(Route.RouteOption.RouteAsLargeAnimal, true); } if (((ths.OwnerSim.IsHorse || ths.OwnerSim.IsDeer) || (ths.OwnerSim.IsFullSizeDog && ths.OwnerSim.SimDescription.AdultOrAbove)) && !ths.OwnerSim.SimDescription.IsGhost) { r.SetOption(Route.RouteOption.OffsetDestinationForLongAnimals, true); } if (ths.OwnerSim.IsHorse && ths.OwnerSim.IsInBeingRiddenPosture) { r.SetOption(Route.RouteOption.RouteWhileMounted, true); } if (previousPosture is LeadingHorsePosture) { r.SetOption(Route.RouteOption.EnablePlanningAsCar, false); r.SetOption(Route.RouteOption.RouteAsLargeAnimal, true); r.SetOption(Route.RouteOption.RouteAsSimLeadingHorse, true); } if (ths.OwnerSim.IsPet && !ths.OwnerSim.IsInBeingRiddenPosture) { r.SetOption(Route.RouteOption.IgnoreSidewalkAndLotRestrictions, true); } } }
public override bool Run() { try { IWooHooDefinition definition = InteractionDefinition as IWooHooDefinition; if (mWoohooer == null) { mMaster = true; mWoohooer = Actor; mWoohooee = GetSelectedObject() as Sim; if (mWoohooee == null) { return(false); } } if (mMaster) { UnderwaterCave.WoohooInCave entry = definition.ProxyClone(mWoohooer).CreateInstance(Target, mWoohooee, mPriority, Autonomous, true) as UnderwaterCave.WoohooInCave; entry.mWoohooer = Actor; entry.mWoohooee = mWoohooee; entry.LinkedInteractionInstance = this; mWoohooee.InteractionQueue.AddNext(entry); if (Target.mIsTentacleWaving) { Target.TentacleWaveUpdate(); } if (!Actor.RouteToSlot(Target, Slot.RoutingSlot_0)) { mWoohooee.AddExitReason(ExitReason.SynchronizationFailed); return(false); } Target.WaitForTentacle(Actor); StandardEntry(); EnterStateMachine("UnderwaterCaveWooHoo", "enter", "x"); SetParameter("IsMermaidX", Actor.SimDescription.IsMatureMermaid); SetActor("cave", Target); AnimateSim("xEnterCave"); mRouteComplete = true; } UnderwaterCave.WoohooInCave linkedInteractionInstance = LinkedInteractionInstance as UnderwaterCave.WoohooInCave; while (((linkedInteractionInstance != null) && !linkedInteractionInstance.mRouteComplete) && !Actor.HasExitReason(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached))) { SpeedTrap.Sleep(); } if ((linkedInteractionInstance == null) || !linkedInteractionInstance.mRouteComplete) { return(false); } if (!mMaster) { Route r = Actor.CreateRoute(); r.AddObjectToIgnoreForRoute(mWoohooer.ObjectId); r.PlanToSlot(Target, Slot.RoutingSlot_0); mRouteComplete = Actor.DoRoute(r); if (!mRouteComplete) { mWoohooer.AddExitReason(ExitReason.SynchronizationFailed); return(false); } StandardEntry(); } BeginCommodityUpdates(); if (mMaster) { if (Actor.HasExitReason(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached))) { AnimateSim("xExit"); return(false); } Target.WaitForTentacle(mWoohooee); SetActor("y", mWoohooee); SetParameter("IsMermaidY", mWoohooee.SimDescription.IsMatureMermaid); AddOneShotScriptEventHandler(0xc9, FireVFX); if (definition.GetStyle(this) != CommonWoohoo.WoohooStyle.Safe) { // Custom AddOneShotScriptEventHandler(0x3e9, FirePreggoEx); } CommonWoohoo.RunPostWoohoo(mWoohooer, mWoohooee, Target, definition.GetStyle(this), definition.GetLocation(Target), true); mCurrentStateMachine.EnterState("y", "enter"); mCurrentStateMachine.RequestState("y", "yEnterCave"); AnimateJoinSims("woohoo"); mWoohooer.BuffManager.AddElement(BuffNames.MileLowClub, Origin.FromWooHooUnderwaterCave); mWoohooee.BuffManager.AddElement(BuffNames.MileLowClub, Origin.FromWooHooUnderwaterCave); mWoohooer.GetRelationship(mWoohooee, true).LTR.UpdateLiking(kLTRBump); if (mVfxone != null) { mVfxone.Stop(VisualEffect.TransitionType.SoftTransition); mVfxone = null; } if (mVfxtwo != null) { mVfxtwo.Stop(VisualEffect.TransitionType.SoftTransition); mVfxtwo = null; } AnimateSim("xExit"); Actor.RouteToObjectRadius(Target, kRouteRadiusRange); Actor.LoopIdle(); mCurrentStateMachine.RequestState("y", "yExit"); mWoohooee.AddExitReason(ExitReason.Finished); } else { DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached)); Actor.RouteToObjectRadius(Target, kRouteRadiusRange); } EventTracker.SendEvent(EventTypeId.kWooHooInUnderwaterCave, Actor, Target); EndCommodityUpdates(true); StandardExit(); return(true); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); return(false); } }
public override bool Run() { try { Sim linkedActor = GetSelectedObject() as Sim; if (linkedActor == Actor) { linkedActor = null; } if (linkedActor != null) { HotAirBalloonSit entry = Singleton.CreateInstance(Target, linkedActor, GetPriority(), Autonomous, CancellableByPlayer) as HotAirBalloonSit; entry.LinkedInteractionInstance = this; linkedActor.InteractionQueue.Add(entry); } HotAirBalloonSit linked = LinkedInteractionInstance as HotAirBalloonSit; if (linked != null) { linkedActor = linked.Actor; } bool isXActor = Target.mLeftActorId == 0x0L; if (!isXActor && (Target.mRightActorId != 0x0L)) { return(false); } if (isXActor) { Target.mLeftActorId = Actor.SimDescription.SimDescriptionId; } else { Target.mRightActorId = Actor.SimDescription.SimDescriptionId; } Route r = Actor.CreateRoute(); if (linkedActor != null) { r.AddObjectToIgnoreForRoute(linkedActor.ObjectId); } if (!r.PlanToSlot(Target, Slot.RoutingSlot_7).Succeeded()) { if (isXActor) { Target.mLeftActorId = 0x0L; } else { Target.mRightActorId = 0x0L; } return(false); } if ((Target.mTargetHeight != HotairBalloon.BalloonHeight.OnGround) || (Target.mCurrentHeight != HotairBalloon.BalloonHeight.OnGround)) { Actor.PlayRouteFailure(); if (isXActor) { Target.mLeftActorId = 0x0L; } else { Target.mRightActorId = 0x0L; } return(false); } r = Actor.CreateRoute(); if (linkedActor != null) { r.AddObjectToIgnoreForRoute(linkedActor.ObjectId); } r.AddObjectToIgnoreForRoute(Target.ObjectId); if (!r.PlanToSlot(Target, isXActor ? Slot.RoutingSlot_5 : Slot.RoutingSlot_2).Succeeded()) { Target.ResetParentingHierarchy(true); r.PlanToSlot(Target, isXActor ? Slot.RoutingSlot_5 : Slot.RoutingSlot_2); } if (!Actor.DoRoute(r)) { if (isXActor) { Target.mLeftActorId = 0x0L; } else { Target.mRightActorId = 0x0L; } return(false); } StandardEntry(); BeginCommodityUpdates(); Animation.ForceAnimation(Actor.ObjectId, true); if (Target.mFlyStateMachine == null) { Target.mFlyStateMachine = StateMachineClient.Acquire(Target, "hotairballoon_store", AnimationPriority.kAPDefault); Target.mFlyStateMachine.SetActor("hotairBalloonX", Target); Target.mFlyStateMachine.EnterState("hotairBalloonX", "BalloonLiftOff"); } AcquireStateMachine("hotairballoon_store"); mCurrentStateMachine.SetActor("x", Actor); mCurrentStateMachine.SetActor("hotairBalloonX", Target); mCurrentStateMachine.SetParameter("XSimR", isXActor ? YesOrNo.no : YesOrNo.yes); mCurrentStateMachine.EnterState("x", "EnterBalloon"); Slot slotName = isXActor ? ((Slot)(0xa820f8a5)) : ((Slot)(0xa820f8a2)); float f = (float)Math.Acos((double)(Target.ForwardVector * Actor.ForwardVector)); if (float.IsNaN(f)) { f = 3.141593f; } Actor.ParentToSlot(Target, slotName, f, false); mCurrentStateMachine.RequestState("x", "IdleStand"); EndCommodityUpdates(true); HotairBalloon.InBalloonPosture posture = new HotairBalloon.InBalloonPosture(Actor, Target, isXActor, mCurrentStateMachine); Actor.Posture = posture; if ((Autonomous) && (RandomUtil.RandomChance(HotairBalloon.kChanceToCallOverRomanticInterest))) { Sim actor = Target.FindRomanticSimToRideWith(Actor); if ((actor != null) && !actor.InteractionQueue.HasInteractionOfType(Singleton)) { InteractionInstance entry = Singleton.CreateInstance(Target, actor, new InteractionPriority(InteractionPriorityLevel.Autonomous), true, true); actor.InteractionQueue.Add(entry); mCurrentStateMachine.RequestState("x", "CallOver"); mCurrentStateMachine.RequestState("x", "IdleStand"); mCurrentStateMachine.RequestState("x", "CallOver"); mCurrentStateMachine.RequestState("x", "IdleStand"); } } StandardExit(); return(true); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); return(false); } }
public static void SetRouteOptions(SimRoutingComponent ths, Route r, uint ageGenderFlags) { SimDescription simDescription = ths.OwnerSim.SimDescription; Posture previousPosture = ths.OwnerSim.Posture; if (!(ths.OwnerSim.CurrentInteraction is IHasCustomRouteOptions)) { r.SetOption(Route.RouteOption.BeginAsCar, (ths.OwnerSim.Parent is Vehicle) && !(ths.OwnerSim.Parent is IBoat)); r.SetOption(Route.RouteOption.EnablePlanningAsCar, simDescription.ChildOrAbove); r.SetOption(Route.RouteOption.DisablePlanningAsPedestrian, false); r.SetOption(Route.RouteOption.PushSimsAtDestination, true); r.SetOption(Route.RouteOption.UseAutoSlotFootprintLocking, true); r.SetOption(Route.RouteOption.ReplanToFindObstacleWhenPathPlanFails, true); r.SetOption(Route.RouteOption.IgnoreParent, false); r.SetOption(Route.RouteOption.IgnoreChildren, false); r.SetOption(Route.RouteOption.CreateSubPaths, true); r.SetOption(Route.RouteOption.CheckForFootprintsNearGoals, true); r.SetOption(Route.RouteOption.PenalizeGoalsOnDifferentLevels, true); bool flag = false; if (GameUtils.IsInstalled(ProductVersion.EP10)) { IBoat parent = ths.OwnerSim.Parent as IBoat; if (parent != null) { flag = true; r.Follower = parent.Proxy; r.FollowerAgeGenderSpecies = (uint)parent.GetBoatSpecies(); r.SetOption2(Route.RouteOption2.EnablePlanningAsBoat, true); r.SetOption2(Route.RouteOption2.BeginAsBoat, true); r.SetOption2(Route.RouteOption2.UseFollowerStartOrientation, true); r.SetOption(Route.RouteOption.OffsetDestinationForLongAnimals, true); r.AddObjectToIgnoreForRoute(ths.OwnerSim.ObjectId); } bool flag2 = OccultMermaid.IsEveryOneGroupedWithMeATeenOrAboveMermaid(ths.OwnerSim); bool flag3 = false; if (!flag2) { flag3 = ((previousPosture is CarryingChildPosture) || (previousPosture is CarryingPetPosture)) || ths.OwnerSim.Autonomy.SituationComponent.InSituationOfType(typeof(GoHereWithSituation)); } bool flag4 = simDescription.ChildOrAbove & !(previousPosture is ScubaDiving); flag4 &= !(ths.OwnerSim.InteractionQueue.GetHeadInteraction() is Lifeguard.GiveCPR); flag4 &= !(ths.OwnerSim.InteractionQueue.GetHeadInteraction() is Lifeguard.FakeInjury); flag4 &= !(simDescription.CreatedByService is GrimReaper); flag4 &= !flag2 || flag3; flag4 &= !(previousPosture is BeingRiddenPosture) && !(previousPosture is RidingPosture); bool flag5 = simDescription.ChildOrAbove && simDescription.IsHuman; flag5 &= !(previousPosture is CarryingChildPosture) && !(previousPosture is CarryingPetPosture); r.SetOption(Route.RouteOption.EnableWaterPlanning, flag5); r.SetOption2(Route.RouteOption2.DestinationMustBeOnLand, !flag5); r.SetOption2(Route.RouteOption2.EnablePlanningAsBoat, (parent != null) || flag4); if (flag2 && flag5) { r.SetOption2(Route.RouteOption2.RouteAsMermaid, true); } else { r.SetOption2(Route.RouteOption2.RouteAsLifeguard, Lifeguard.ShouldUseRescueSwimWade(ths.OwnerSim)); } } if (GameUtils.IsInstalled(ProductVersion.EP3)) { r.SetOption(Route.RouteOption.EnableSubwayPlanning, true); } if (GameUtils.IsInstalled(ProductVersion.EP11)) /*&& GameUtils.IsFutureWorld())*/ { r.SetOption2(Route.RouteOption2.EnableHoverTrainPlanning, true); } if (GameUtils.IsInstalled(ProductVersion.EP5) && ((ths.OwnerSim.IsWildAnimal || ths.OwnerSim.IsStray) || (ths.OwnerSim.IsUnicorn || WildHorses.IsWildHorse(ths.OwnerSim)))) { r.SetOption2(Route.RouteOption2.EnablePlanningAsBoat, false); r.SetOption2(Route.RouteOption2.DestinationMustBeOnLand, true); } if (ths.SimSatisfiesSpecialConditions()) { r.SetOption(Route.RouteOption.PassThroughObjects, true); r.SetOption(Route.RouteOption.PassThroughWalls, true); } if (ths.OwnerSim.HasGhostBuff && !flag) { r.SetOption(Route.RouteOption.RouteAsGhost, true); } if ((GameUtils.IsInstalled(ProductVersion.EP4) && (ths.OwnerSim.CarryingChildPosture != null)) && (Stroller.GetStroller(ths.OwnerSim, ths.OwnerSim.LotCurrent) != null)) { r.SetOption(Route.RouteOption.PlanUsingStroller, true); } if (ths.OwnerSim.IsHuman) { SwimmingInPool pool = previousPosture as SwimmingInPool; if (pool != null) { if (pool.ContainerIsOcean) { r.SetOption(Route.RouteOption.EnableWaterPlanning, true); } } else { Ocean.PondAndOceanRoutingPosture posture2 = previousPosture as Ocean.PondAndOceanRoutingPosture; if ((posture2 != null) && (posture2.WalkStyleToUse == Sim.WalkStyle.Wade)) { r.SetOption(Route.RouteOption.EnableWaterPlanning, true); } } } if (GameUtils.IsInstalled(ProductVersion.EP8)) { // Custom if (SimEx.GetOwnedAndUsableVehicle(ths.OwnerSim, ths.OwnerSim.LotHome, false, false, false, true) is CarUFO) //if (OwnerSim.GetOwnedAndUsableVehicle(OwnerSim.LotHome, false, false, false, true) is CarUFO) { r.SetOption(Route.RouteOption.EnableUFOPlanning, true); } if ((ths.OwnerSim.IsHuman && ths.OwnerSim.SimDescription.ChildOrAbove) && PondManager.ArePondsFrozen()) { bool flag6 = true; while (previousPosture != null) { if (previousPosture.Satisfaction(CommodityKind.Standing, null) <= 0f) { flag6 = false; break; } previousPosture = previousPosture.PreviousPosture; } if (flag6) { r.SetOption(Route.RouteOption.EnablePondPlanning, true); } } } r.ExitReasonsInterrupt = unchecked ((int)0xffa9bfff); if ((0x0 != (ageGenderFlags & 0x3)) && !ths.OwnerSim.LotCurrent.IsWorldLot) { r.SetValidRooms(ths.OwnerSim.LotCurrent.LotId, null); } if ((ths.OwnerSim.IsHorse && ths.OwnerSim.SimDescription.AdultOrAbove) && !ths.OwnerSim.SimDescription.IsGhost) { r.SetOption(Route.RouteOption.RouteAsLargeAnimal, true); } if (((ths.OwnerSim.IsHorse || ths.OwnerSim.IsDeer) || (ths.OwnerSim.IsFullSizeDog && ths.OwnerSim.SimDescription.AdultOrAbove)) && !ths.OwnerSim.SimDescription.IsGhost) { r.SetOption(Route.RouteOption.OffsetDestinationForLongAnimals, true); } if (ths.OwnerSim.IsHorse && ths.OwnerSim.IsInBeingRiddenPosture) { r.SetOption(Route.RouteOption.RouteWhileMounted, true); } if (previousPosture is LeadingHorsePosture) { r.SetOption(Route.RouteOption.EnablePlanningAsCar, false); r.SetOption(Route.RouteOption.RouteAsLargeAnimal, true); r.SetOption(Route.RouteOption.RouteAsSimLeadingHorse, true); } if (ths.OwnerSim.IsPet && !ths.OwnerSim.IsInBeingRiddenPosture) { r.SetOption(Route.RouteOption.IgnoreSidewalkAndLotRestrictions, true); } } }