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; } }
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; } }
public ActionResult NM_PerformAction() { if (dontCall) { return(ActionResult.Continue); } Boat boat = null; try { mRoutingSim.SimRoutingComponent.DisallowBeingPushed = true; if (mRoutingSim.HasExitReason((ExitReason)mOriginalRoute.ExitReasonsInterrupt)) { AddFailureExplanation(FailureExplanation.CancelledByScript); return(ActionResult.Terminate); } Lot lot = (mOriginalRoute == null) ? mRoutingSim.LotCurrent : LotManager.GetLotAtPoint(mOriginalRoute.GetOriginalStartPoint()); boat = Sim_GetBoatForGetInBoatRouteAction(mRoutingSim, lot); if (boat == null) { AddFailureExplanation(FailureExplanation.VehicleSequenceFailure); return(ActionResult.Terminate); } mLastFoundBoatId = boat.ObjectId; Vector3 pt; mOriginalRoute.GetSegmentStartPoint(0u, out pt); Vector3 dir; mOriginalRoute.GetSegmentStartDirection(0u, out dir); mBoatAppearingPt = pt; mnReplanFrequency = RandomUtil.GetInt(SimRoutingComponent.AvoidanceReplanCheckFrequencyMin, SimRoutingComponent.AvoidanceReplanCheckFrequencyMax); mnReplanOffset = RandomUtil.GetInt(SimRoutingComponent.AvoidanceReplanCheckOffsetMin, SimRoutingComponent.AvoidanceReplanCheckOffsetMax); StandAndWaitController standAndWaitController = new StandAndWaitController(); standAndWaitController.AllowZeroCycle = true; standAndWaitController.Duration = SimRoutingComponent.DefaultStandAndWaitDuration; standAndWaitController.OnCycle = base.StandAndWaitCycleHandler; standAndWaitController.Run(mRoutingSim); if (mStandAndWaitResult == ActionResult.Terminate) { if (mLastFoundObstruction.IsValid && mOriginalRoute.DoRouteFail) { mRoutingSim.SimRoutingComponent.PlayRouteFailureIfAppropriate(mLastFoundObstruction.ObjectFromId <GameObject>()); } return(mStandAndWaitResult); } if (mStandAndWaitResult == ActionResult.ContinueAndFollowPath) { return(mStandAndWaitResult); } ItemComponent itemComp = boat.ItemComp; if (itemComp != null && itemComp.InventoryParent != null) { itemComp.InventoryParent.RemoveByForce(boat); } MooringPost mooringPost = boat.Parent as MooringPost; if (mooringPost != null) { mooringPost.UnReserveSpot(boat); } boat.PlaceAt(pt, dir, mRoutingSim); BoatRoutingComponent boatRoutingComponent = boat.RoutingComponent as BoatRoutingComponent; if (boatRoutingComponent != null) { boatRoutingComponent.ForceUpdateDynamicFootprint(); boatRoutingComponent.EnableDynamicFootprint(); } mRoutingSim.FadeOut(true, 0.5f, null); if (!boat.HaveSimWaitBeforeGettingIn(mRoutingSim)) { mRoutingSim.FadeIn(false, 0f); return(ActionResult.Terminate); } boat.SimIsGettingIn = true; if (boat.Driver == null) { boat.PutInDriver(mRoutingSim); } else { boat.PutInPassenger(mRoutingSim); } boat.SimIsGettingIn = false; if (!(boat is BoatTaxi)) { mRoutingSim.FadeIn(true, 0.5f); } GameObject objectInRightHand = mRoutingSim.GetObjectInRightHand(); if (objectInRightHand != null && !(objectInRightHand is Sim)) { objectInRightHand.SetHiddenFlags(HiddenFlags.Model); } mRoutingSim.SimRoutingComponent.ClearPush(); mOriginalRoute.FollowerAgeGenderSpecies = (uint)boat.GetBoatSpecies(); mOriginalRoute.Follower = boat.Proxy; mOriginalRoute.SetOption2(Route.RouteOption2.BeginAsBoat, true); mOriginalRoute.SetOption2(Route.RouteOption2.UseFollowerStartOrientation, boat.UsesTurnHelperFootprint()); mOriginalRoute.SetOption(Route.RouteOption.RouteAsGhost, false); return(ActionResult.ContinueAndPopPathAndReplan); } catch { if (boat != null && boat.DestroyOnRelease) { boat.Destroy(); } throw; } finally { mRoutingSim.SimRoutingComponent.DisallowBeingPushed = false; } }