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; }