コード例 #1
0
        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));
        }
コード例 #2
0
        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);
        }