Ejemplo n.º 1
0
            protected override bool InitialPrep(CastFireBlastTerrainEx ths, bool twoPerson, IMagicalDefinition definition, MagicControl control, bool spellCastingSucceeded, bool spellCastingEpiclyFailed)
            {
                Vector3         targetPosition = ths.GetTargetPosition();
                Route           r      = ths.Actor.CreateRoute();
                RoutePlanResult result = r.PlanToPointRadius(targetPosition, kRoutingDistance, RouteOrientationPreference.TowardsObject, LotManager.GetLotAtPoint(targetPosition).LotId, new int[] { World.GetRoomId(targetPosition) });

                if (!result.Succeeded() || World.IsInPool(result.mDestination))
                {
                    ths.Actor.PlayRouteFailure();
                    return(false);
                }

                if (!ths.Actor.DoRoute(r))
                {
                    return(false);
                }

                return(true);
            }
Ejemplo n.º 2
0
        private static void Reroute(Route r, AncientPortal closest, AncientPortal destination)
        {
            Sim     target            = r.Follower.Target as Sim;
            Vector3 currentStartPoint = r.GetCurrentStartPoint();
            float   distanceRemaining = r.GetDistanceRemaining();

            Common.StringBuilder msg = new Common.StringBuilder();

            msg.Append("AncientPortal Reroute: " + target.FullName);

            Route routeToPortal = target.CreateRoute();

            routeToPortal.SetOption(Route.RouteOption.EnableSubwayPlanning, false);
            routeToPortal.SetOption2(Route.RouteOption2.EnableHoverTrainPlanning, false);
            routeToPortal.SetOption(Route.RouteOption.EnablePlanningAsCar, r.GetOption(Route.RouteOption.EnablePlanningAsCar));
            routeToPortal.SetOption(Route.RouteOption.PlanUsingStroller, r.GetOption(Route.RouteOption.PlanUsingStroller));
            routeToPortal.SetOption(Route.RouteOption.ReplanUsingStroller, r.GetOption(Route.RouteOption.ReplanUsingStroller));
            routeToPortal.SetOption(Route.RouteOption.BeginAsStroller, r.GetOption(Route.RouteOption.BeginAsStroller));

            Vector3 slotPosition = closest.GetSlotPosition(closest.GetRoutingSlots()[0]);
            Vector3 slotFoward   = closest.GetForwardOfSlot(closest.GetRoutingSlots()[0]);

            Vector3 farPosition = new Vector3(slotPosition);

            farPosition.x -= slotFoward.x / 4f;
            farPosition.y -= slotFoward.y / 4f;

            RoutePlanResult result = routeToPortal.PlanToPoint(farPosition);

            msg.Append(Common.NewLine + "Result: " + result);

            if (result.Succeeded())
            {
                msg.Append(Common.NewLine + "D" + Common.NewLine + Routes.RouteToString(routeToPortal));

                Route portalRoute = target.CreateRoute();
                portalRoute.SetOption(Route.RouteOption.EnableSubwayPlanning, false);
                portalRoute.SetOption2(Route.RouteOption2.EnableHoverTrainPlanning, false);
                portalRoute.SetOption(Route.RouteOption.EnablePlanningAsCar, r.GetOption(Route.RouteOption.EnablePlanningAsCar));
                portalRoute.SetOption(Route.RouteOption.PlanUsingStroller, r.GetOption(Route.RouteOption.PlanUsingStroller));
                portalRoute.SetOption(Route.RouteOption.ReplanUsingStroller, r.GetOption(Route.RouteOption.ReplanUsingStroller));
                portalRoute.SetOption(Route.RouteOption.BeginAsStroller, r.GetOption(Route.RouteOption.BeginAsStroller));

                result = portalRoute.PlanToPointFromPoint(slotPosition, farPosition);

                msg.Append(Common.NewLine + "Result: " + result);

                if (result.Succeeded())
                {
                    PathData portalData = new PathData();
                    portalData.PathType       = PathType.PortalPath;
                    portalData.ObjectId       = closest.ObjectId;
                    portalData.PortalStartPos = slotPosition;

                    portalRoute.SetPathData(ref portalData);

                    msg.Append(Common.NewLine + "A" + Common.NewLine + Routes.RouteToString(portalRoute));

                    slotPosition = destination.GetSlotPosition(destination.GetRoutingSlots()[0]);

                    r.SetOption(Route.RouteOption.EnableSubwayPlanning, false);
                    if (!r.ReplanFromPoint(slotPosition).Succeeded())
                    {
                        r.ReplanFromPoint(currentStartPoint);
                    }
                    else if ((routeToPortal.GetDistanceRemaining() + r.GetDistanceRemaining()) < (distanceRemaining + SimRoutingComponent.kDistanceMustSaveInOrderToUseSubway))
                    {
                        AncientPortalComponent.AddTargetPortal(target, destination);

                        msg.Append(Common.NewLine + "B" + Common.NewLine + Routes.RouteToString(r));

                        r.InsertRouteSubPathsAtIndex(0x0, portalRoute);
                        r.InsertRouteSubPathsAtIndex(0x0, routeToPortal);

                        msg.Append(Common.NewLine + "C" + Common.NewLine + Routes.RouteToString(r));

                        r.SetOption(Route.RouteOption.EnableSubwayPlanning, true);
                    }
                    else
                    {
                        r.ReplanFromPoint(currentStartPoint);
                    }
                }
            }

            Common.DebugNotify(msg, target);
            Common.DebugWriteLog(msg);
        }
Ejemplo n.º 3
0
        public static RouteAction.ActionResult PerformAction(ObstacleEncounteredRouteInterruptAction ths)
        {
            try
            {
                ths.mRoutingSim.SimRoutingComponent.EnableDynamicFootprint();
                ths.mRoutingSim.SimRoutingComponent.StopPushImmunity();
                if ((ths.mRoutingSim.SimRoutingComponent.UsingStroller && (ths.mRoutingSim.CarryingChildPosture != null)) && (ths.mRoutingSim.CarryingChildPosture.Stroller != null))
                {
                    ths.mRoutingSim.CarryingChildPosture.Stroller.SetPosition(ths.mRoutingSim.CarryingChildPosture.Stroller.Position);
                }

                bool option = ths.mInterruptedPath.GetOption(Route.RouteOption.BlockedByPeople);
                ths.mInterruptedPath.SetOption(Route.RouteOption.BlockedByPeople, true);
                if (ths.mbForceInitialReplan)
                {
                    RoutePlanResult result = ths.mInterruptedPath.Replan();
                    if (!result.Succeeded())
                    {
                        GameObject obj2 = new ObjectGuid(result.mBlockerObjectId).ObjectFromId <GameObject>();
                        ths.mRoutingSim.SimRoutingComponent.PlayRouteFailureIfAppropriate(obj2);
                        return(RouteAction.ActionResult.Terminate);
                    }
                }

                /* This is duplicated in StandAndWaitController, I believe it is an EA error since there is no "Exit"
                 * StateMachineClient client = StateMachineClient.Acquire(ths.mRoutingSim, "StandAndWait");
                 * client.SetActor("x", ths.mRoutingSim);
                 * client.SetParameter("isMermaid", OccultMermaid.IsMatureMermaidAndWearingTail(base.mRoutingSim));
                 * client.EnterState("x", "Enter");
                 */

                SpeedTrap.Sleep();
                ths.mnCheckFrequency = 0x1;
                ths.mnCheckOffset    = 0x0;
                try
                {
                    StandAndWaitController controller = new StandAndWaitController();
                    controller.AllowZeroCycle = ths.mbAllowZeroCycle;
                    controller.Duration       = SimRoutingComponent.DefaultStandAndWaitDuration;
                    controller.OnCycle        = ths.StandAndWaitCycleHandler;
                    controller.Run(ths.mRoutingSim);
                }
                catch (SacsErrorException e)
                {
                    Common.DebugException("ObstacleEncounteredRouteInterruptActionEx:PerformAction", e);
                }

                ths.mRoutingSim.SimRoutingComponent.DisableDynamicFootprint();
                if (!ths.mbElectedToExit)
                {
                    ths.mReturnValue = RouteAction.ActionResult.Terminate;
                }

                if (ths.mReturnValue == RouteAction.ActionResult.Terminate)
                {
                    int          numObstacles            = 0x0;
                    int          numPushableObstacles    = 0x0;
                    int          numWorldObstacles       = 0x0;
                    int          numStaticObstacles      = 0x0;
                    int          numReplannableObstacles = 0x0;
                    ObjectGuid[] guidArray = ths.CollectObstacles(ths.mRoutingSim, ref numObstacles, ref numPushableObstacles, ref numReplannableObstacles, ref numStaticObstacles, ref numWorldObstacles);
                    int          num6      = numObstacles - numWorldObstacles;
                    if (numObstacles > 0x0)
                    {
                        if ((ths.mRoutingSim.LotCurrent != null) && !ths.mRoutingSim.LotCurrent.IsWorldLot)
                        {
                            if ((num6 == 0x0) && (numWorldObstacles > 0x0))
                            {
                                ths.mRoutingSim.SimRoutingComponent.StartIgnoringObstacles();
                                return(RouteAction.ActionResult.ContinueAndFollowPath);
                            }
                            else if ((num6 >= 0x3) && (Sims3.Gameplay.Queries.CountObjects <Sim>(ths.mRoutingSim.Position, 1f) >= 0x4))
                            {
                                ths.mRoutingSim.SimRoutingComponent.StartIgnoringObstacles();
                                return(RouteAction.ActionResult.ContinueAndFollowPath);
                            }
                        }
                        else if (numWorldObstacles > 0x0)
                        {
                            ths.mRoutingSim.SimRoutingComponent.StartIgnoringObstacles();
                            return(RouteAction.ActionResult.ContinueAndFollowPath);
                        }
                    }
                    else
                    {
                        ths.mRoutingSim.SimRoutingComponent.StartPushImmunity(SimRoutingComponent.OnRouteStartedImmuneToPushesDuration);
                    }

                    if ((!ths.mRoutingSim.HasExitReason(ExitReason.CancelExternal | ExitReason.MidRoutePushRequested) && ths.mInterruptedPath.DoRouteFail) && !ths.mInterruptedPath.PlanResult.Succeeded())
                    {
                        foreach (ObjectGuid guid in guidArray)
                        {
                            GameObject obj3 = guid.ObjectFromId <GameObject>();
                            if (ths.mRoutingSim.SimRoutingComponent.PlayRouteFailureIfAppropriate(obj3))
                            {
                                break;
                            }
                        }
                    }
                }

                ths.mInterruptedPath.SetOption(Route.RouteOption.BlockedByPeople, option);
                return(ths.mReturnValue);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception("ObstacleEncounteredRouteInterruptActionEx:PerformAction", e);
                throw;
            }
        }
Ejemplo n.º 4
0
        public override bool Run()
        {
            try
            {
                RoutePlanResult result = Actor.CreateRoute().PlanToSlot(Target, Target.UseableSlots(Actor, true, true));
                if (!result.Succeeded())
                {
                    return(false);
                }

                mSlotIndex = FairyHouse.kSlotToIndex[(Slot)result.mDestSlotNameHash];
                Target.SetRoutingSlotInUse(mSlotIndex);
                if (Actor.IsActiveSim)
                {
                    PlumbBob.HidePlumbBob();
                }

                StandardEntry(false);
                BeginCommodityUpdates();
                mActorFairy = Actor.SimDescription.OccultManager.GetOccultType(OccultTypes.Fairy) as OccultFairy;

                mCurrentStateMachine = Actor.Posture.CurrentStateMachine;
                AddOneShotScriptEventHandler(0x66, OnShowActorEx);
                SetParameter("Slot", FairyHouse.kSlotToCompass[mSlotIndex]);

                if (mActorFairy != null)
                {
                    mActorFairy.FairyTrueForm.SetPosition(Target.GetPositionOfSlot((Slot)result.mDestSlotNameHash));
                    mActorFairy.FairyTrueForm.SetForward(Target.GetForwardOfSlot((Slot)result.mDestSlotNameHash));
                }

                if (mActorFairy != null)
                {
                    mActorFairy.AttachTrueFairyFormToAnimation(mCurrentStateMachine);
                }

                AnimateSim("Fly Out");
                AnimateSim("Exit");
                EndCommodityUpdates(true);
                StandardExit();

                if (Target.IsLightOn() && (Target.ActorsUsingMe.Count == 0x0))
                {
                    Target.TurnOffLight();
                }

                FairyHouse.FairyHousePosture posture = Actor.Posture as FairyHouse.FairyHousePosture;
                if (posture != null)
                {
                    posture.CancelPosture(Actor);
                }

                Actor.PopPosture();
                Actor.BridgeOrigin = Actor.Posture.Idle();
                PlumbBob.Reparent();
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }