public override void Perform() { if (sSims != null) { foreach (KeyValuePair <Sim, InteractionInstance> pair in sSims) { if (pair.Key.Service != null && pair.Key.Service is Butler) { continue; } SimRoutingComponent component = pair.Key.SimRoutingComponent; if (component != null) { if (component.GetDistanceRemainingOnRoute() == 0f) { component.mRouteActions.Clear(); continue; } } new DelayedResetTask(pair.Key, pair.Value); } sSims.Clear(); } sSims = null; base.Perform(); }
public static void ResetRouting(Sim sim) { if (sim == null) { return; } SimRoutingComponent component = sim.SimRoutingComponent; if (component != null) { if (component.LockedDoorsDuringPlan != null && component.LockedDoorsDuringPlan.Count > 0) { foreach (Door door in component.LockedDoorsDuringPlan) { if (door == null) { continue; } PortalComponent portalComponent = door.PortalComponent; if (portalComponent != null) { portalComponent.FreeAllRoutingLanes(); } door.SetObjectToReset(); } } component.LockedDoorsDuringPlan = new List <Door>(); } }
public static Route CreateRoute(SimRoutingComponent ths, CASAgeGenderFlags ageGenderFlags) { Route r = null; uint num = (uint)ageGenderFlags; r = Route.Create(ths.Owner.Proxy, num); ths.SetRouteOptions(r, num); return r; }
public static Route CreateRoute(SimRoutingComponent ths) { Route r = null; uint simFlags = ths.OwnerSim.SimDescription.SimFlags; r = Route.Create(ths.Owner.Proxy, simFlags); SetRouteOptions(ths, r, simFlags); return r; }
public static Route CreateRoute(SimRoutingComponent ths, CASAgeGenderFlags ageGenderFlags) { Route r = null; uint num = (uint)ageGenderFlags; r = Route.Create(ths.Owner.Proxy, num); ths.SetRouteOptions(r, num); return(r); }
public static Route CreateRouteAsAdult(SimRoutingComponent ths) { Route r = null; uint ageGenderFlags = ths.OwnerSim.SimDescription.SimFlags & 0xffffff80; ageGenderFlags |= 0x20; r = Route.Create(ths.Owner.Proxy, ageGenderFlags); SetRouteOptions(ths, r, ageGenderFlags); return r; }
public static Route CreateRoute(SimRoutingComponent ths) { Route r = null; uint simFlags = ths.OwnerSim.SimDescription.SimFlags; r = Route.Create(ths.Owner.Proxy, simFlags); SetRouteOptions(ths, r, simFlags); return(r); }
public static Route CreateRouteAsAdult(SimRoutingComponent ths) { Route r = null; uint ageGenderFlags = ths.OwnerSim.SimDescription.SimFlags & 0xffffff80; ageGenderFlags |= 0x20; r = Route.Create(ths.Owner.Proxy, ageGenderFlags); SetRouteOptions(ths, r, ageGenderFlags); return(r); }
public static void ShowHumanAndHideTrueForm(OccultFairy ths) { string msg = null; try { SimRoutingComponent simRoutingComponent = ths.mOwningSim.SimRoutingComponent; if (simRoutingComponent != null) { simRoutingComponent.EnableDynamicFootprint(); } ths.mOwningSim.SetHiddenFlags(HiddenFlags.Nothing); msg += "A"; // Custom if (ths.mWings != null) { ths.mWings.Start(); } else { ths.GrantWings(); } msg += "B"; if (ths.mOwningSim.TraitManager.HasElement(TraitNames.FairyQueen)) { ths.AddHoveringFairies(); } msg += "C"; if (ths.mOwningSim.IsActiveSim) { PlumbBob.ShowPlumbBob(); } msg += "D"; if (ths.mVfxTrueFairyForm != null) { ths.mVfxTrueFairyForm.Stop(); } msg += "E"; ths.CleanupFairyTrueFormFx(); } catch (Exception e) { Common.Exception(ths.mOwningSim, null, msg, e); } }
private static InteractionInstance CreateGoHereWithInteractionInstance(SimRoutingComponent ths, Route r, List <Sim> followers, InteractionPriority priority, bool cancellableByPlayer, out InteractionInstance ownerInteraction, GoHereWithSituation.OnFailBehavior failureBehavior, Vector3 teleportLocation) { Sim properLeader = ths.GetProperLeader(ths.OwnerSim, followers); InteractionInstanceParameters parameters = new InteractionInstanceParameters(new InteractionObjectPair(LeaderGoHereWith.Singleton, Terrain.Singleton), properLeader, priority, false, cancellableByPlayer); LeaderGoHereWith with = LeaderGoHereWith.Singleton.CreateInstanceFromParameters(ref parameters) as LeaderGoHereWith; with.SetOwner(ths.OwnerSim); with.OnFailBehavior = failureBehavior; if (teleportLocation != Vector3.Invalid) { with.TeleportDestination = teleportLocation; } else if (failureBehavior == GoHereWithSituation.OnFailBehavior.Teleport) { with.TeleportDestination = r.GetDestPoint(); } if (properLeader != ths.OwnerSim) { followers = new List <Sim>(followers); followers.Remove(properLeader); Route route = r.ShallowCopy(); route.ExitReasonsInterrupt = r.ExitReasonsInterrupt; ths.UpdateRoutingOptionsFromLeader(properLeader, route); route.Follower = properLeader.Proxy; route.Replan(); with.SetRouteToFollow(route); } else { with.SetRouteToFollow(r); } with.SetFollowers(followers); GoHereWithSituationEx.CreateSituation(with); if (properLeader != ths.OwnerSim) { ownerInteraction = new SlaveLeaderGoHereWith.Definition(with.Situation).CreateInstance(Terrain.Singleton, ths.OwnerSim, priority, false, cancellableByPlayer); } else { ownerInteraction = null; } return(with); }
private static InteractionInstance CreateGoHereWithInteractionInstance(SimRoutingComponent ths, Route r, List<Sim> followers, InteractionPriority priority, bool cancellableByPlayer, out InteractionInstance ownerInteraction, GoHereWithSituation.OnFailBehavior failureBehavior, Vector3 teleportLocation) { Sim properLeader = ths.GetProperLeader(ths.OwnerSim, followers); InteractionInstanceParameters parameters = new InteractionInstanceParameters(new InteractionObjectPair(LeaderGoHereWith.Singleton, Terrain.Singleton), properLeader, priority, false, cancellableByPlayer); LeaderGoHereWith with = LeaderGoHereWith.Singleton.CreateInstanceFromParameters(ref parameters) as LeaderGoHereWith; with.SetOwner(ths.OwnerSim); with.OnFailBehavior = failureBehavior; if (teleportLocation != Vector3.Invalid) { with.TeleportDestination = teleportLocation; } else if (failureBehavior == GoHereWithSituation.OnFailBehavior.Teleport) { with.TeleportDestination = r.GetDestPoint(); } if (properLeader != ths.OwnerSim) { followers = new List<Sim>(followers); followers.Remove(properLeader); Route route = r.ShallowCopy(); route.ExitReasonsInterrupt = r.ExitReasonsInterrupt; ths.UpdateRoutingOptionsFromLeader(properLeader, route); route.Follower = properLeader.Proxy; route.Replan(); with.SetRouteToFollow(route); } else { with.SetRouteToFollow(r); } with.SetFollowers(followers); GoHereWithSituationEx.CreateSituation(with); if (properLeader != ths.OwnerSim) { ownerInteraction = new SlaveLeaderGoHereWith.Definition(with.Situation).CreateInstance(Terrain.Singleton, ths.OwnerSim, priority, false, cancellableByPlayer); } else { ownerInteraction = null; } return with; }
protected override void PreProcess(FollowRouteAction obj, object parent, FieldInfo field) { IScriptProxy proxy = Simulator.GetProxy(obj.mRoutingObjectId); if (proxy == null) { return; } Sim sim = proxy.Target as Sim; if (sim == null) { return; } SimRoutingComponent component = sim.RoutingComponent as SimRoutingComponent; if (component == null) { return; } if (component.mRouteActions.Contains(obj)) { return; } if (sSims == null) { sSims = new Dictionary <Sim, InteractionInstance>(); } if (!sSims.ContainsKey(sim)) { sSims.Add(sim, sim.CurrentInteraction); ErrorTrap.DebugLogCorrection("Potential Follow Route Action Reset: " + sim.FullName); } }
protected static void ReplaceComponent(Sim sim) { if (sim.GetComponent <SimRoutingComponentEx>() != null) { return; } SimRoutingComponent oldComponent = sim.SimRoutingComponent; sim.RemoveComponent <SimRoutingComponent>(); ObjectComponents.AddComponent <SimRoutingComponentEx>(sim, new object[0]); if (oldComponent != null) { SimRoutingComponent newComponent = sim.SimRoutingComponent; if (newComponent != null) { newComponent.mWalkStyleRequests = oldComponent.mWalkStyleRequests; newComponent.mSimWalkStyle = oldComponent.mSimWalkStyle; } } }
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); }
public static bool DoRouteWithFollowers(SimRoutingComponent ths, Route r, List<Sim> followers) { return DoRouteWithFollowers(ths, r, followers, GoHereWithSituation.OnFailBehavior.None, Vector3.Invalid); }
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 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); } } }
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)); }
public static bool DoRouteWithFollowers(SimRoutingComponent ths, Route r, List <Sim> followers) { return(DoRouteWithFollowers(ths, r, followers, GoHereWithSituation.OnFailBehavior.None, Vector3.Invalid)); }