public override string GetInteractionName(Sim actor, AncientPortal target, InteractionObjectPair iop) { if (GameUtils.IsFutureWorld()) { return(TimePortal.LocalizeString("TravelHome", new object[0x0])); } return(TimePortal.LocalizeString("TravelWith", new object[0x0]) + Localization.Ellipsis); }
protected override bool Satisfies(Sim actor, Sim target, AncientPortal obj, bool isAutonomous, ref GreyedOutTooltipCallback callback) { if (!base.Satisfies(actor, target, obj, isAutonomous, ref callback)) { return(false); } return(CommonPregnancy.SatisfiesTryForBaby(actor, target, "AncientPortalTryForBaby", isAutonomous, true, ref callback)); }
protected override bool Satisfies(Sim actor, Sim target, AncientPortal obj, bool isAutonomous, ref GreyedOutTooltipCallback callback) { if (!base.Satisfies(actor, target, obj, isAutonomous, ref callback)) { return(false); } return(CommonWoohoo.SatisfiesWoohoo(actor, target, "AncientPortalWoohoo", isAutonomous, true, true, ref callback)); }
public bool TestUse(AncientPortal obj) { if (!TestRepaired(obj)) { return(false); } return(obj.mRoutingSims.Count == 0 && obj.InWorld); }
public override bool Test(Sim actor, AncientPortal target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { if (!GameUtils.IsInstalled(ProductVersion.EP11)) { greyedOutTooltipCallback = Common.DebugTooltip("Pack Fail"); return(false); } return(TimePortalTravelWithEx.Definition.PublicTest(actor, target, isAutonomous, ref greyedOutTooltipCallback)); }
public override void OnReset() { try { if (mSMC != null) { mSMC.Dispose(); mSMC = null; } if (mPortal != null) { if (mCurrentlyRoutingSim != null) { mPortal.RemoveFromUseList(mCurrentlyRoutingSim); } } if ((mCurrentlyRoutingSim != null) && (!mCurrentlyRoutingSim.HasBeenDestroyed)) { mCurrentlyRoutingSim.SetHiddenFlags(HiddenFlags.Nothing); AncientPortal targetPortal = null; if (sTargetPortals.TryGetValue(mCurrentlyRoutingSim, out targetPortal)) { targetPortal.RemoveFromUseList(mCurrentlyRoutingSim); targetPortal.DisableFootprint(AncientPortal.CatchABeam.FootprintPlacementHash); } } mCurrentlyRoutingSim = null; base.OnReset(); } catch (Exception e) { Common.Exception(Owner, e); } }
public override bool OnPortalStop(Sim sim) { try { AncientPortal targetPortal = null; if (!sTargetPortals.TryGetValue(sim, out targetPortal)) { sim.PlayRouteFailure(mPortal); return(false); } mSMC.SetActor("portal", targetPortal); Slot slotName = targetPortal.GetRoutingSlots()[0x0]; Vector3 positionOfSlot = targetPortal.GetPositionOfSlot(slotName); Vector3 forwardOfSlot = targetPortal.GetForwardOfSlot(slotName); sim.SetPosition(positionOfSlot); sim.SetForward(forwardOfSlot); targetPortal.DisableFootprint(AncientPortal.CatchABeam.FootprintPlacementHash); mSMC.RequestState("x", "Exit"); if (SimTypes.IsSelectable(sim)) { for (int i = 0x0; i < AncientPortal.CatchABeam.kPotentialTravelBuffs.Length; i++) { if (RandomUtil.RandomChance(AncientPortal.CatchABeam.kChanceForEachBuff)) { sim.BuffManager.AddElement(AncientPortal.CatchABeam.kPotentialTravelBuffs[i], Origin.FromAncientPortal); } } } targetPortal.RemoveFromUseList(sim); if (targetPortal.LotCurrent.IsResidentialLot && !sim.IsGreetedOnLot(targetPortal.LotCurrent)) { sim.GreetSimOnLot(targetPortal.LotCurrent); } if (mSMC != null) { mSMC.Dispose(); mSMC = null; } mCurrentlyRoutingSim = null; return(true); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(sim, Owner, e); return(false); } finally { if (mCurrentlyRoutingSim != null) { mCurrentlyRoutingSim.SetHiddenFlags(HiddenFlags.Nothing); } } }
public override bool OnPortalStart(Sim sim) { try { if ((mCurrentlyRoutingSim != null) && (mCurrentlyRoutingSim.HasBeenDestroyed)) { if (mSMC != null) { mSMC.Dispose(); mSMC = null; } } mCurrentlyRoutingSim = sim; if (mSMC != null) { sim.PlayRouteFailure(mPortal); return(false); } AncientPortal targetPortal = null; if (!sTargetPortals.TryGetValue(sim, out targetPortal)) { sim.PlayRouteFailure(mPortal); return(false); } if (targetPortal == mPortal) { return(false); } mPortal.AddToUseList(sim); sim.SimRoutingComponent.OnRouteActionsFinished -= OnPortalApproachCancelledAndFinished; sim.SetExitReasonsInterruptForMultiPortalRoute(); sim.SimRoutingComponent.StartIgnoringObstacles(); targetPortal.AddToUseList(sim); targetPortal.EnableFootprint(AncientPortal.CatchABeam.FootprintPlacementHash); targetPortal.PushSimsFromFootprint(AncientPortal.CatchABeam.FootprintPlacementHash, sim, null, false); Vector3 slotFoward = mPortal.GetForwardOfSlot(mPortal.GetRoutingSlots()[0]); sim.SetForward(slotFoward); mSMC = StateMachineClient.Acquire(sim, "AncientPortal", AnimationPriority.kAPDefault); mSMC.SetActor("x", sim); mSMC.SetActor("portal", mPortal); mSMC.EnterState("x", "Enter"); mSMC.EnterState("portal", "Enter"); mSMC.AddOneShotScriptEventHandler(0x65, HideSim); mSMC.AddOneShotScriptEventHandler(0x66, ShowSim); mSMC.RequestState("x", "InsidePortal"); mPortal.RemoveFromUseList(sim); return(true); } catch (ResetException) { if (mCurrentlyRoutingSim != null) { mCurrentlyRoutingSim.SetHiddenFlags(HiddenFlags.Nothing); } throw; } catch (Exception e) { if (mCurrentlyRoutingSim != null) { mCurrentlyRoutingSim.SetHiddenFlags(HiddenFlags.Nothing); } Common.Exception(sim, Owner, e); return(false); } }
public static void AddTargetPortal(Sim sim, AncientPortal portal) { sTargetPortals[sim] = portal; }
public AncientPortalComponent(GameObject owner) : base(owner) { mPortal = owner as AncientPortal; mAddPortalsCallback = AddAncientPortal; }
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); }
public override bool Test(Sim actor, AncientPortal target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { if (!GameUtils.IsInstalled(ProductVersion.EP11)) { greyedOutTooltipCallback = Common.DebugTooltip("Pack Fail"); return false; } return TimePortalTravelWithEx.Definition.PublicTest(actor, target, isAutonomous, ref greyedOutTooltipCallback); }
public override string GetInteractionName(Sim actor, AncientPortal target, InteractionObjectPair iop) { return(Common.LocalizeEAString(actor.IsFemale, "Gameplay/Excel/Socializing/Action:NRaasTryForBaby", new object[0])); }
public override string GetInteractionName(Sim actor, AncientPortal target, InteractionObjectPair iop) { return(Common.LocalizeEAString(actor.IsFemale, "Gameplay/Excel/Socializing/Action:NRaasRiskyWooHoo", new object[0]) + Common.LocalizeEAString(false, "NRaas.Woohooer:RiskyChance", new object[] { Woohooer.Settings.GetRiskyBabyMadeChance(actor) })); }
private static void CheckAndUpdateRouteForPortals(Route r) { if (r.PlanResult.Succeeded()) { Sim target = r.Follower.Target as Sim; if (target != null) { // Subways and Ancient portals do not work for ghosts if (target.SimDescription.DeathStyle != SimDescription.DeathType.None) { return; } bool usingHoverTrain = target.CurrentInteraction is IHoverTrainStationInteraction; if (!usingHoverTrain) { if (Routes.Contains(r, PathType.VehiclePath)) { Vehicle ownedAndUsableVehicle = SimEx.GetOwnedAndUsableVehicle(target, target.LotCurrent); if (ownedAndUsableVehicle != null) { if (ownedAndUsableVehicle.DestroyOnRelease) { ownedAndUsableVehicle.Destroy(); ownedAndUsableVehicle = null; } return; } } } if (target.IsSelectable || RandomUtil.RandomChance01(SimRoutingComponent.kNPCSubwayUseChance) || usingHoverTrain) { bool found = false; for (uint i = 0; i < r.GetNumPaths(); i++) { PathData data = r.GetPathData(i); if (data.PathType != PathType.PortalPath) { continue; } AncientPortal portal = GameObject.GetObject <AncientPortal>(data.ObjectId); if (portal != null) { found = true; break; } else { IStation station = GameObject.GetObject <IStation>(data.ObjectId); if (station != null) { found = true; break; } } } if (found) { return; } LotLocation startLotLocation = LotLocation.Invalid; LotLocation endLotLocation = LotLocation.Invalid; Vector3 currentStartPoint = r.GetCurrentStartPoint(); Vector3 destPoint = r.GetDestPoint(); ulong startLot = World.GetLotLocation(currentStartPoint, ref startLotLocation); ulong endLot = World.GetLotLocation(destPoint, ref endLotLocation); if (((startLot != ulong.MaxValue) && (endLot != ulong.MaxValue)) && ((startLot != endLot) || (startLot == 0x0L))) { AncientPortal closestAP = null; float closestDistAP = float.MaxValue; AncientPortal destinationAP = null; float destDistanceAP = float.MaxValue; if (target.IsHuman) { foreach (AncientPortal choice in Sims3.Gameplay.Queries.GetObjects <AncientPortal>()) { Vector3 vector3 = choice.Position - currentStartPoint; if (vector3.Length() < closestDistAP) { closestDistAP = vector3.Length(); closestAP = choice; } Vector3 vector4 = choice.Position - destPoint; if (vector4.Length() < destDistanceAP) { destDistanceAP = vector4.Length(); destinationAP = choice; } } } IStation closestSW = null; float closestDistSW = float.MaxValue; IStation destinationSW = null; float destDistanceSW = float.MaxValue; foreach (IStation subway3 in Sims3.Gameplay.Queries.GetObjects <IStation>()) { Vector3 vector3 = subway3.Position - currentStartPoint; if (vector3.Length() < closestDistSW) { closestDistSW = vector3.Length(); closestSW = subway3; } Vector3 vector4 = subway3.Position - destPoint; if (vector4.Length() < destDistanceSW) { destDistanceSW = vector4.Length(); destinationSW = subway3; } } float distanceRemaining = r.GetDistanceRemaining(); float lengthAP = float.MaxValue; if (((closestAP != null) && (destinationAP != null)) && ((closestAP != destinationAP) && ((closestDistAP + destDistanceAP) <= (distanceRemaining + SimRoutingComponent.kDistanceMustSaveInOrderToUseSubway)))) { lengthAP = closestDistAP + destDistanceAP; } float lengthSW = float.MaxValue; if (((closestSW != null) && (destinationSW != null)) && ((closestSW != destinationSW) && ((closestDistSW + destDistanceSW) <= (distanceRemaining + SimRoutingComponent.kDistanceMustSaveInOrderToUseSubway)))) { lengthSW = closestDistSW + destDistanceSW; } if (lengthAP < lengthSW) { if (lengthAP != float.MaxValue) { Reroute(r, closestAP, destinationAP); } } else { if (lengthSW != float.MaxValue) { Reroute(r, closestSW, destinationSW); } } } } } } }
public override string GetInteractionName(Sim actor, AncientPortal target, InteractionObjectPair iop) { if (GameUtils.IsFutureWorld()) { return TimePortal.LocalizeString("TravelHome", new object[0x0]); } return (TimePortal.LocalizeString("TravelWith", new object[0x0]) + Localization.Ellipsis); }