public void GetSimToLotEx(SimDescription simDesc, Lot actorHome, bool random) { bool success = SimEx.GetSimToSimHome(simDesc, base.Actor, new Callback(KamaSimtraSettings.ServiceData.GoToLotSuccessEx)); if (success) { if (random) { // someone will be over Common.Notify(Common.Localize("OrderServices:Success", Actor.IsFemale)); } else { // selected sim will be over Common.Notify(Common.Localize("OrderServices:SuccessSpecific", Actor.IsFemale, new object[] { "\"" + KamaSimtra.Settings.GetAlias(simDesc) + "\"" })); } } else { if (base.Actor.IsSelectable) { Phone.CallInviteOver.ShowInviteFailedDialog(this.GetInteractionName()); } return; } KamaSimtraSettings.ServiceData data = KamaSimtra.Settings.GetServiceData(base.Actor.SimDescription.SimDescriptionId, true); data.mRequester = base.Actor.SimDescription.SimDescriptionId; data.mProfessional = simDesc.SimDescriptionId; data.mWasRandom = random; KamaSimtra.Settings.SetServiceData(base.Actor.SimDescription.SimDescriptionId, data); }
public void CheckArrival() { if (this.mLotPushAttempts >= 5) { this.Dispose(); return; } if (this.mProfessional != 0) { SimDescription desc = SimDescription.Find(this.mProfessional); if (desc != null) { if (desc.CreatedSim == null) { Instantiation.Perform(desc, null); } if (desc.CreatedSim != null) { SimDescription descClient = SimDescription.Find(this.mRequester); if (descClient != null && descClient.LotHome != null && desc.CreatedSim.LotCurrent != descClient.LotHome) { SimEx.GetSimToSimHome(desc, descClient.CreatedSim, new Callback(GoToLotSuccessEx)); this.mLotPushAttempts++; } } } else { this.Dispose(); return; } } }
public void GetSimToLotEx(SimDescription simDesc, Lot actorHome) { bool flag = SimEx.GetSimToSimHome(simDesc, base.Actor, new Callback(this.GoToLotSuccessEx)); if (!flag && base.Actor.IsSelectable && simDesc.CreatedSim != null) { ShowInviteFailedDialog(this.GetInteractionName(), simDesc.CreatedSim); } }
public override bool Run() { try { if (Actor.LotCurrent != Target) { Vector3 point = World.LotGetPtInside(Target.LotId); if (point == Vector3.Invalid) { return(false); } if (!Actor.RouteToPointRadius(point, 3f) && (!GlobalFunctions.PlaceAtGoodLocation(Actor, new World.FindGoodLocationParams(point), false) || !SimEx.IsPointInLotSafelyRoutable(Actor, Target, Actor.Position))) { Actor.AttemptToPutInSafeLocation(true); } } Sim destObj = null; float negativeInfinity = float.NegativeInfinity; foreach (Sim sim2 in Actor.Household.Sims) { if ((sim2.IsHuman && sim2.IsAtHome) && !sim2.IsSleeping) { Relationship relationship = Relationship.Get(Actor, sim2, false); if ((relationship != null) && (relationship.LTR.Liking > negativeInfinity)) { destObj = sim2; negativeInfinity = relationship.LTR.Liking; } } } if (destObj != null) { Actor.RouteToDynamicObjectRadius(destObj, kRouteToHighRelSimRange[0x0], kRouteToHighRelSimRange[0x1], null, new Route.RouteOption[] { Route.RouteOption.DoLineOfSightCheckUserOverride }); } string instanceName = null; switch (Actor.SimDescription.Species) { case CASAgeGenderFlags.Dog: instanceName = "dogPregnantJig"; break; case CASAgeGenderFlags.LittleDog: instanceName = "smallDogPregnantJig"; break; case CASAgeGenderFlags.Horse: instanceName = "horsePregnantJig"; break; case CASAgeGenderFlags.Cat: instanceName = "catPregnantJig"; break; } if (instanceName != null) { mPetPregnancyJig = GlobalFunctions.CreateObjectOutOfWorld(instanceName, ProductVersion.EP5) as SocialJigOnePerson; if (mPetPregnancyJig != null) { mPetPregnancyJig.RegisterParticipants(Actor, null); Vector3 position = Actor.Position; Vector3 forwardVector = Actor.ForwardVector; if (GlobalFunctions.FindGoodLocationNearby(mPetPregnancyJig, ref position, ref forwardVector)) { mPetPregnancyJig.SetPosition(position); mPetPregnancyJig.SetForward(forwardVector); mPetPregnancyJig.AddToWorld(); Route r = mPetPregnancyJig.RouteToJigA(Actor); if (!Actor.DoRoute(r)) { mPetPregnancyJig.Destroy(); mPetPregnancyJig = null; } } else { mPetPregnancyJig.Destroy(); mPetPregnancyJig = null; } } } StandardEntry(); BeginCommodityUpdates(); EnterStateMachine("GiveBirth", "Enter", "x"); AnimateSim("LieDown"); if (Actor.IsSelectable) { try { Sims3.Gameplay.Gameflow.Singleton.DisableSave(this, "Gameplay/ActorSystems/PetPregnancy:DisableSave"); // Custom HaveBabyHomeEx.EnsureForeignFather(Actor.SimDescription.Pregnancy); mOffspring = new Proxies.PetPregnancyProxy(Actor.SimDescription.Pregnancy).CreateNewborns(0f, true, true); int num2 = 0x0; foreach (Sim sim3 in mOffspring) { sim3.SimDescription.IsNeverSelectable = true; if (mPetPregnancyJig != null) { Slot slotName = kPregnancyJigContainmentSlots[num2++]; sim3.SetPosition(mPetPregnancyJig.GetPositionOfSlot(slotName)); sim3.SetForward(mPetPregnancyJig.GetForwardOfSlot(slotName)); InteractionInstance entry = Pregnancy.BabyPetLieDown.Singleton.CreateInstance(sim3, sim3, new InteractionPriority(InteractionPriorityLevel.Autonomous), true, true); entry.Hidden = true; sim3.InteractionQueue.AddNext(entry); } else { World.FindGoodLocationParams fglParams = new World.FindGoodLocationParams(Actor.Position); fglParams.RequiredRoomID = Actor.RoomId; if ((!GlobalFunctions.PlaceAtGoodLocation(sim3, fglParams, false) || !sim3.IsPointInLotSafelyRoutable(sim3.LotCurrent, sim3.Position)) && !sim3.AttemptToPutInSafeLocation(true)) { sim3.SetPosition(Actor.Position); } } } } finally { Sims3.Gameplay.Gameflow.Singleton.EnableSave(this); } } // Custom call bool flag = DoLoop(ExitReason.Finished, GiveBirthLoopFunc, mCurrentStateMachine); AnimateSim("Exit"); StandardExit(); return(flag); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); return(false); } }
protected override OptionResult Run(GameHitParameters <GameObject> parameters) { Common.StringBuilder msg = new Common.StringBuilder("Run"); try { Terrain terrain = parameters.mTarget as Terrain; if (terrain != null) { foreach (Sim sim in LotManager.Actors) { Common.TestSpan span = Common.TestSpan.CreateSimple(); Route r = null; uint simFlags = sim.SimDescription.SimFlags; try { r = Route.Create(sim.Proxy, simFlags); } finally { msg += Common.NewLine + sim.FullName; msg += Common.NewLine + " " + sim.SimDescription.mSimFlags; msg += Common.NewLine + " " + span.Duration; } SimDescription simDescription = sim.SimDescription; Posture previousPosture = sim.Posture; SimRoutingComponent routingComponent = sim.RoutingComponent as SimRoutingComponent; bool flag = false; span = Common.TestSpan.CreateSimple(); try { //routingComponent.SetRouteOptions(route, simFlags); if (!(sim.CurrentInteraction is IHasCustomRouteOptions)) { r.SetOption(Route.RouteOption.BeginAsCar, (sim.Parent is Vehicle) && !(sim.Parent is IBoat)); r.SetOption(Route.RouteOption.EnablePlanningAsCar, simDescription.ChildOrAbove); r.SetOption(Route.RouteOption.DisablePlanningAsPedestrian, false); r.SetOption(Route.RouteOption.PushSimsAtDestination, true); r.SetOption(Route.RouteOption.UseAutoSlotFootprintLocking, true); r.SetOption(Route.RouteOption.ReplanToFindObstacleWhenPathPlanFails, true); r.SetOption(Route.RouteOption.IgnoreParent, false); r.SetOption(Route.RouteOption.IgnoreChildren, false); r.SetOption(Route.RouteOption.CreateSubPaths, true); r.SetOption(Route.RouteOption.CheckForFootprintsNearGoals, true); r.SetOption(Route.RouteOption.PenalizeGoalsOnDifferentLevels, true); if (GameUtils.IsInstalled(ProductVersion.EP10)) { IBoat parent = sim.Parent as IBoat; if (parent != null) { flag = true; r.Follower = parent.Proxy; r.FollowerAgeGenderSpecies = (uint)parent.GetBoatSpecies(); r.SetOption2(Route.RouteOption2.EnablePlanningAsBoat, true); r.SetOption2(Route.RouteOption2.BeginAsBoat, true); r.SetOption2(Route.RouteOption2.UseFollowerStartOrientation, true); r.SetOption(Route.RouteOption.OffsetDestinationForLongAnimals, true); r.AddObjectToIgnoreForRoute(sim.ObjectId); } bool flag2 = OccultMermaid.IsEveryOneGroupedWithMeATeenOrAboveMermaid(sim); bool flag3 = false; if (!flag2) { flag3 = ((previousPosture is CarryingChildPosture) || (previousPosture is CarryingPetPosture)) || sim.Autonomy.SituationComponent.InSituationOfType(typeof(GoHereWithSituation)); } bool flag4 = simDescription.ChildOrAbove & !(previousPosture is ScubaDiving); flag4 &= !(sim.InteractionQueue.GetHeadInteraction() is Lifeguard.GiveCPR); flag4 &= !(sim.InteractionQueue.GetHeadInteraction() is Lifeguard.FakeInjury); flag4 &= !(simDescription.CreatedByService is GrimReaper); flag4 &= !flag2 || flag3; flag4 &= !(previousPosture is BeingRiddenPosture) && !(previousPosture is RidingPosture); bool flag5 = simDescription.ChildOrAbove && simDescription.IsHuman; flag5 &= !(previousPosture is CarryingChildPosture) && !(previousPosture is CarryingPetPosture); r.SetOption(Route.RouteOption.EnableWaterPlanning, flag5); r.SetOption2(Route.RouteOption2.DestinationMustBeOnLand, !flag5); r.SetOption2(Route.RouteOption2.EnablePlanningAsBoat, (parent != null) || flag4); if (flag2 && flag5) { r.SetOption2(Route.RouteOption2.RouteAsMermaid, true); } else { r.SetOption2(Route.RouteOption2.RouteAsLifeguard, Lifeguard.ShouldUseRescueSwimWade(sim)); } } // Cut if (GameUtils.IsInstalled(ProductVersion.Undefined | ProductVersion.EP3)) { r.SetOption(Route.RouteOption.EnableSubwayPlanning, true); } if (GameUtils.IsInstalled(ProductVersion.Undefined | ProductVersion.EP5) && ((sim.IsWildAnimal || sim.IsStray) || (sim.IsUnicorn || WildHorses.IsWildHorse(sim)))) { r.SetOption2(Route.RouteOption2.EnablePlanningAsBoat, false); r.SetOption2(Route.RouteOption2.DestinationMustBeOnLand, true); } if (routingComponent.SimSatisfiesSpecialConditions()) { r.SetOption(Route.RouteOption.PassThroughObjects, true); r.SetOption(Route.RouteOption.PassThroughWalls, true); } if (sim.HasGhostBuff && !flag) { r.SetOption(Route.RouteOption.RouteAsGhost, true); } if ((GameUtils.IsInstalled(ProductVersion.Undefined | ProductVersion.EP4) && (sim.CarryingChildPosture != null)) && (Stroller.GetStroller(sim, sim.LotCurrent) != null)) { r.SetOption(Route.RouteOption.PlanUsingStroller, true); } if (sim.IsHuman) { SwimmingInPool pool = previousPosture as SwimmingInPool; if (pool != null) { if (pool.ContainerIsOcean) { r.SetOption(Route.RouteOption.EnableWaterPlanning, true); } } else { Ocean.PondAndOceanRoutingPosture posture2 = previousPosture as Ocean.PondAndOceanRoutingPosture; if ((posture2 != null) && (posture2.WalkStyleToUse == Sim.WalkStyle.Wade)) { r.SetOption(Route.RouteOption.EnableWaterPlanning, true); } } } // Cut if (GameUtils.IsInstalled(ProductVersion.EP8)) { if (SimEx.GetOwnedAndUsableVehicle(sim, sim.LotHome, false, false, false, true) is CarUFO) { r.SetOption(Route.RouteOption.EnableUFOPlanning, true); } if ((sim.IsHuman && sim.SimDescription.ChildOrAbove) && PondManager.ArePondsFrozen()) { bool flag6 = true; while (previousPosture != null) { if (previousPosture.Satisfaction(CommodityKind.Standing, null) <= 0f) { flag6 = false; break; } previousPosture = previousPosture.PreviousPosture; } if (flag6) { r.SetOption(Route.RouteOption.EnablePondPlanning, true); } } } } } finally { msg += Common.NewLine + " B " + span.Duration; } span = Common.TestSpan.CreateSimple(); try { if (!(sim.CurrentInteraction is IHasCustomRouteOptions)) { r.ExitReasonsInterrupt = unchecked ((int)0xffa9bfff); if ((0x0 != (simFlags & 0x3)) && !sim.LotCurrent.IsWorldLot) { r.SetValidRooms(sim.LotCurrent.LotId, null); } if ((sim.IsHorse && sim.SimDescription.AdultOrAbove) && !sim.SimDescription.IsGhost) { r.SetOption(Route.RouteOption.RouteAsLargeAnimal, true); } if (((sim.IsHorse || sim.IsDeer) || (sim.IsFullSizeDog && sim.SimDescription.AdultOrAbove)) && !sim.SimDescription.IsGhost) { r.SetOption(Route.RouteOption.OffsetDestinationForLongAnimals, true); } if (sim.IsHorse && sim.IsInBeingRiddenPosture) { r.SetOption(Route.RouteOption.RouteWhileMounted, true); } if (previousPosture is LeadingHorsePosture) { r.SetOption(Route.RouteOption.EnablePlanningAsCar, false); r.SetOption(Route.RouteOption.RouteAsLargeAnimal, true); r.SetOption(Route.RouteOption.RouteAsSimLeadingHorse, true); } if (sim.IsPet && !sim.IsInBeingRiddenPosture) { r.SetOption(Route.RouteOption.IgnoreSidewalkAndLotRestrictions, true); } } //route = sim.CreateRoute(); } finally { msg += Common.NewLine + " C " + span.Duration; } } } AcademicTextBook book = parameters.mTarget as AcademicTextBook; if (book != null) { Sim a = parameters.mActor as Sim; GreyedOutTooltipCallback greyedOutTooltipCallback = null; if ((a.OccupationAsAcademicCareer != null) || !book.mRequireAcademics) { if (book.TestRockAndRead(a, false, ref greyedOutTooltipCallback)) { msg += Common.NewLine + "A"; } if (a.Inventory.Contains(parameters.mTarget) && !(a.Posture is Sim.StandingPosture)) { if (book.TestReadBook(a, false, ref greyedOutTooltipCallback)) { msg += Common.NewLine + "B"; } } if (a.GetObjectInRightHand() == parameters.mTarget) { if (book.TestReadBook(a, false, ref greyedOutTooltipCallback)) { msg += Common.NewLine + "C"; } } msg += Common.NewLine + "D"; } msg += Common.NewLine + "E"; } CommonDoor door = parameters.mTarget as CommonDoor; if (door != null) { if (door.mObjComponents != null) { msg += Common.NewLine + "Count: " + door.mObjComponents.Count; for (int i = 0x0; i < door.mObjComponents.Count; i++) { msg += Common.NewLine + door.mObjComponents[i].BaseType; if (door.mObjComponents[i].BaseType == typeof(PortalComponent)) { msg += Common.NewLine + " Found"; door.mObjComponents[i].Dispose(); door.mObjComponents.RemoveAt(i); break; } } if (door.mObjComponents.Count == 0x0) { door.mObjComponents = null; } } } HarvestPlant plant = parameters.mTarget as HarvestPlant; if (plant != null) { msg += Common.NewLine + "mBarren: " + plant.mBarren; msg += Common.NewLine + "mGrowthState: " + plant.mGrowthState; msg += Common.NewLine + "mDormant: " + plant.mDormant; msg += Common.NewLine + "mLeaflessState: " + plant.mLeaflessState; msg += Common.NewLine + "mLifetimeHarvestablesYielded: " + plant.mLifetimeHarvestablesYielded; msg += Common.NewLine + "NumLifetimeHarvestables: " + plant.PlantDef.NumLifetimeHarvestables; msg += Common.NewLine + "Yield: " + plant.GetYield(); } } catch (Exception e) { GameHitParameters <GameObject> .Exception(parameters, msg, e); } finally { Common.DebugWriteLog(msg); } return(OptionResult.SuccessClose); }
public override bool Run() { try { if (Actor.LotCurrent != Target) { Vector3 point = World.LotGetPtInside(Target.LotId); if (point == Vector3.Invalid) { return(false); } if (!Actor.RouteToPointRadius(point, 3f) && (!GlobalFunctions.PlaceAtGoodLocation(Actor, new World.FindGoodLocationParams(point), false) || !SimEx.IsPointInLotSafelyRoutable(Actor, Target, Actor.Position))) { Actor.AttemptToPutInSafeLocation(true); } } if (Actor.Posture is SwimmingInPool) { SwimmingInPool posture = Actor.Posture as SwimmingInPool; if (!posture.ContainerPool.RouteToEdge(Actor)) { if (Actor.BridgeOrigin != null) { Actor.BridgeOrigin.MakeRequest(); } Actor.PopPosture(); IGameObject reservedTile = null; Actor.FindRoutablePointInsideNearFrontDoor(Actor.Household.LotHome, out reservedTile); Vector3 position = reservedTile.Position; Terrain.TeleportMeHere here = Terrain.TeleportMeHere.Singleton.CreateInstance(Terrain.Singleton, Actor, new InteractionPriority(InteractionPriorityLevel.Pregnancy), false, false) as Terrain.TeleportMeHere; here.SetAndReserveDestination(reservedTile); try { here.RunInteractionWithoutCleanup(); } catch { Actor.SetPosition(position); } finally { here.Cleanup(); } Actor.LoopIdle(); } } Pregnancy pregnancy = Actor.SimDescription.Pregnancy; GetNewBorns(); AcquirePregnancyStateMachine(); mCurrentStateMachine.SetActor("x", Actor); for (int i = 0; i < mNewborns.Count; i++) { Sim baby = mNewborns[i]; Relationship.Get(Actor, baby, true).LTR.ForceChangeState(LongTermRelationshipTypes.Friend); if (baby.BridgeOrigin != null) { baby.BridgeOrigin.MakeRequest(); baby.BridgeOrigin = null; } InternalHaveAlienBabyHome instance = InternalHaveAlienBabyHome.Singleton.CreateInstance(baby, Actor, GetPriority(), Autonomous, CancellableByPlayer) as InternalHaveAlienBabyHome; instance.TotalCount = mNewborns.Count; instance.BabyIndex = i + 1; instance.mCurrentStateMachine = mCurrentStateMachine; Actor.InteractionQueue.PushAsContinuation(instance, true); } TryDeliverImaginaryFriend(); return(true); } catch (ResetException) { throw; } catch (Exception e) { Logger.WriteExceptionLog(e, this, "HaveAlienBabyHome.Run() Error"); return(false); } }
protected override void PrivatePerformAction(bool prompt) { Overwatch.Log(Name); foreach (Sim createdSim in new List <Sim> (LotManager.Actors)) { StuckSimData other; if (!sData.TryGetValue(createdSim.SimDescription.SimDescriptionId, out other)) { other = new StuckSimData(); sData.Add(createdSim.SimDescription.SimDescriptionId, other); } try { bool wasReset = false; if ((createdSim != null) && (createdSim.InWorld) && (createdSim.Proxy != null) && (!SimTypes.IsSelectable(createdSim))) { bool check = true; if (createdSim.Parent is IBed) { check = false; } if (createdSim.OccultManager != null) { OccultRobot bot = createdSim.OccultManager.GetOccultType(Sims3.UI.Hud.OccultTypes.Robot) as OccultRobot; if (bot != null && bot.IsShutdown) { check = false; } } if (check) { InteractionInstance interaction = createdSim.CurrentInteraction; bool sameInteraction = (object.ReferenceEquals(other.mLastInteraction, interaction)); other.mLastInteraction = interaction; if (createdSim.LotCurrent.IsRoomHidden(createdSim.RoomId)) { ResetTask.Perform(createdSim, Vector3.Invalid, "Unroutable"); wasReset = true; } if ((!wasReset) && (other.mLastPosition != Vector3.Invalid) && (other.mLastPosition == createdSim.Position)) { if ((interaction == null) || (sameInteraction)) { bool success = false; try { success = SimEx.IsPointInLotSafelyRoutable(createdSim, createdSim.LotCurrent, createdSim.PositionOnFloor); } catch (Exception e) { Common.DebugException(createdSim, e); success = false; } if (!success) { ResetTask.Perform(createdSim, Vector3.Invalid, "Unroutable"); wasReset = true; } } } if (other.mLastPosition != createdSim.Position) { other.mLastPosition = createdSim.Position; other.mLastPositionTicks = SimClock.CurrentTicks; } else if ((prompt) || ((other.mLastPositionTicks + SimClock.kSimulatorTicksPerSimDay) < SimClock.CurrentTicks)) { if (!wasReset) { bool reset = false; if (sameInteraction) { reset = true; } if (reset) { ResetTask.Perform(createdSim, Vector3.Invalid, "Stationary"); wasReset = true; } } } } } else { wasReset = true; } if (wasReset) { sData.Remove(createdSim.SimDescription.SimDescriptionId); } } catch (Exception e) { Common.Exception(createdSim, e); } } }
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 static bool Run(Pregnancy.HaveBabyHome ths) { try { if (ths.Actor.LotCurrent != ths.Target) { Vector3 point = World.LotGetPtInside(ths.Target.LotId); if (point == Vector3.Invalid) { return(false); } if (!ths.Actor.RouteToPointRadius(point, 3f) && (!GlobalFunctions.PlaceAtGoodLocation(ths.Actor, new World.FindGoodLocationParams(point), false) || !SimEx.IsPointInLotSafelyRoutable(ths.Actor, ths.Target, ths.Actor.Position))) { ths.Actor.AttemptToPutInSafeLocation(true); } } if (ths.Actor.Posture is SwimmingInPool) { SwimmingInPool posture = ths.Actor.Posture as SwimmingInPool; if (!posture.ContainerPool.RouteToEdge(ths.Actor)) { if (ths.Actor.BridgeOrigin != null) { ths.Actor.BridgeOrigin.MakeRequest(); } ths.Actor.PopPosture(); IGameObject reservedTile = null; ths.Actor.FindRoutablePointInsideNearFrontDoor(ths.Actor.Household.LotHome, out reservedTile); Vector3 position = reservedTile.Position; Terrain.TeleportMeHere here = Terrain.TeleportMeHere.Singleton.CreateInstance(Terrain.Singleton, ths.Actor, new InteractionPriority(InteractionPriorityLevel.Pregnancy), false, false) as Terrain.TeleportMeHere; here.SetAndReserveDestination(reservedTile); try { here.RunInteractionWithoutCleanup(); } catch { ths.Actor.SetPosition(position); } finally { here.Cleanup(); } ths.Actor.LoopIdle(); } } Pregnancy pregnancy = ths.Actor.SimDescription.Pregnancy; if (pregnancy != null) { // Custom EnsureForeignFather(pregnancy); } ths.GetNewBorns(); ths.AcquirePregnancyStateMachine(); ths.mCurrentStateMachine.SetActor("x", ths.Actor); for (int i = 0x0; i < ths.mNewborns.Count; i++) { Sim sim = ths.mNewborns[i]; Relationship.Get(ths.Actor, sim, true).LTR.ForceChangeState(LongTermRelationshipTypes.Friend); if (sim.BridgeOrigin != null) { sim.BridgeOrigin.MakeRequest(); sim.BridgeOrigin = null; } Pregnancy.InternalHaveBabyHome instance = Pregnancy.InternalHaveBabyHome.Singleton.CreateInstance(sim, ths.Actor, ths.GetPriority(), ths.Autonomous, ths.CancellableByPlayer) as Pregnancy.InternalHaveBabyHome; instance.TotalCount = ths.mNewborns.Count; instance.BabyIndex = i + 0x1; instance.mCurrentStateMachine = ths.mCurrentStateMachine; ths.Actor.InteractionQueue.PushAsContinuation(instance, true); } ths.TryDeliverImaginaryFriend(); return(true); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(ths.Actor, ths.Target, e); return(false); } }
public override bool Run() { bool result; try { if (Actor.LotCurrent != Target) { Vector3 point = World.LotGetPtInside(Target.LotId); if (point == Vector3.Invalid) { return(false); } if (!Actor.RouteToPointRadius(point, 3f) && (!GlobalFunctions.PlaceAtGoodLocation(Actor, new World.FindGoodLocationParams(point), false) || !SimEx.IsPointInLotSafelyRoutable(Actor, Target, Actor.Position))) { Actor.AttemptToPutInSafeLocation(true); } } if (Actor.Posture is SwimmingInPool && !(Actor.Posture as SwimmingInPool).ContainerPool.RouteToEdge(Actor)) { if (Actor.BridgeOrigin != null) { Actor.BridgeOrigin.MakeRequest(); } Actor.PopPosture(); IGameObject reservedTile = null; Actor.FindRoutablePointInsideNearFrontDoor(Actor.Household.LotHome, out reservedTile); Vector3 position = reservedTile.Position; Terrain.TeleportMeHere here = Terrain.TeleportMeHere.Singleton.CreateInstance(Terrain.Singleton, Actor, new InteractionPriority(InteractionPriorityLevel.Pregnancy), false, false) as Terrain.TeleportMeHere; here.SetAndReserveDestination(reservedTile); try { here.RunInteractionWithoutCleanup(); } catch { Actor.SetPosition(position); } finally { here.Cleanup(); } Actor.LoopIdle(); } AlienPregnancyProxy pregnancy = new AlienPregnancyProxy(Actor.SimDescription.Pregnancy); Sims3.Gameplay.Gameflow.Singleton.DisableSave(this, "Gameplay/ActorSystems/Pregnancy:DisableSave"); mNewborns = pregnancy.CreateNewborns(0f, Actor.IsSelectable, true); mCurrentStateMachine = StateMachineClient.Acquire(Actor, "Pregnancy"); mCurrentStateMachine.SetActor("x", Actor); for (int i = 0; i < mNewborns.Count; i++) { Sim baby = mNewborns[i]; Relationship.Get(Actor, baby, true).LTR.ForceChangeState(LongTermRelationshipTypes.Friend); if (baby.BridgeOrigin != null) { baby.BridgeOrigin.MakeRequest(); baby.BridgeOrigin = null; } HaveAlienBabyHomeInternal instance = HaveAlienBabyHomeInternal.Singleton.CreateInstance(baby, Actor, GetPriority(), Autonomous, CancellableByPlayer) as HaveAlienBabyHomeInternal; instance.TotalCount = mNewborns.Count; instance.BabyIndex = i + 1; instance.mCurrentStateMachine = mCurrentStateMachine; Actor.InteractionQueue.PushAsContinuation(instance, true); } if (Actor.IsSelectable) { OccultImaginaryFriend.DeliverDollToHousehold(mNewborns); } result = true; } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); result = false; } return(result); }